Name Description Size
bookmark_sync
BookmarkHTMLUtils.sys.mjs This file works on the old-style "bookmarks.html" file. It includes functions to import and export existing bookmarks to this file format. Format ------ Primary heading := h1 Old version used this to set attributes on the bookmarks RDF root, such as the last modified date. We only use H1 to check for the attribute PLACES_ROOT, which tells us that this hierarchy root is the places root. For backwards compatibility, if we don't find this, we assume that the hierarchy is rooted at the bookmarks menu. Heading := any heading other than h1 Old version used this to set attributes on the current container. We only care about the content of the heading container, which contains the title of the bookmark container. Bookmark := a HREF is the destination of the bookmark FEEDURL is the URI of the RSS feed. This is deprecated and no more supported, but some old files may still contain it. LAST_CHARSET is stored as an annotation so that the next time we go to that page we remember the user's preference. ICON will be stored in the favicon service ICON_URI is new for places bookmarks.html, it refers to the original URI of the favicon so we don't have to make up favicon URLs. Text of the <a> container is the name of the bookmark Ignored: LAST_VISIT, ID (writing out non-RDF IDs can confuse Firefox 2) Bookmark comment := dd This affects the previosly added bookmark Separator := hr Insert a separator into the current container The folder hierarchy is defined by <dl>/<ul>/<menu> (the old importing code handles all these cases, when we write, use <dl>). Overall design -------------- We need to emulate a recursive parser. A "Bookmark import frame" is created corresponding to each folder we encounter. These are arranged in a stack, and contain all the state we need to keep track of. A frame is created when we find a heading, which defines a new container. The frame also keeps track of the nesting of <DL>s, (in well-formed bookmarks files, these will have a 1-1 correspondence with frames, but we try to be a little more flexible here). When the nesting count decreases to 0, then we know a frame is complete and to pop back to the previous frame. Note that a lot of things happen when tags are CLOSED because we need to get the text from the content of the tag. For example, link and heading tags both require the content (= title) before actually creating it. 36317
BookmarkJSONUtils.sys.mjs Import bookmarks from a url. @param {string} aSpec url of the bookmark data. @param {boolean} [options.replace] Whether we should erase existing bookmarks before importing. @param {PlacesUtils.bookmarks.SOURCES} [options.source] The bookmark change source, used to determine the sync status for imported bookmarks. Defaults to `RESTORE` if `replace = true`, or `IMPORT` otherwise. @returns {Promise<number>} The number of imported bookmarks, not including folders and separators. @resolves When the new bookmarks have been created. @rejects JavaScript exception. 18233
BookmarkList.sys.mjs A collection of bookmarks that internally stays up-to-date in order to efficiently query whether certain URLs are bookmarked. 7497
Bookmarks.sys.mjs This module provides an asynchronous API for managing bookmarks. Bookmarks are organized in a tree structure, and include URLs, folders and separators. Multiple bookmarks for the same URL are allowed. Note that if you are handling bookmarks operations in the UI, you should not use this API directly, but rather use PlacesTransactions, so that any operation is undo/redo-able. Each bookmark-item is represented by an object having the following properties: - guid (string) The globally unique identifier of the item. - parentGuid (string) The globally unique identifier of the folder containing the item. This will be an empty string for the Places root folder. - index (number) The 0-based position of the item in the parent folder. - dateAdded (Date) The time at which the item was added. - lastModified (Date) The time at which the item was last modified. - type (number) The item's type, either TYPE_BOOKMARK, TYPE_FOLDER or TYPE_SEPARATOR. The following properties are only valid for URLs or folders. - title (string) The item's title, if any. Empty titles and null titles are considered the same. Titles longer than DB_TITLE_LENGTH_MAX will be truncated. The following properties are only valid for URLs: - url (URL, href or nsIURI) The item's URL. Note that while input objects can contains either an URL object, an href string, or an nsIURI, output objects will always contain an URL object. An URL cannot be longer than DB_URL_LENGTH_MAX, methods will throw if a longer value is provided. Each successful operation notifies through the PlacesObservers interface. To listen to such notifications you must register using PlacesUtils.observers.addListener and PlacesUtils.observers.removeListener methods. Note that bookmark addition or order changes won't notify bookmark-moved for items that have their indexes changed. Similarly, lastModified changes not done explicitly (like changing another property) won't fire a bookmark-time-changed notification. @see PlacesObservers 117071
components.conf 5021
Database.cpp Get the filename for a corrupt database. 82758
Database.h Initializes the database connection and the schema. In case of corruption the database is copied to a backup file and replaced. 11154
ExtensionSearchHandler.sys.mjs Registers a keyword. @param {string} keyword The keyword to register. @param {Extension} extension The extension registering the keyword. 11130
FaviconHelpers.cpp Fetches information about a page from the database. @param aDB Database connection to history tables. @param _page Page that should be fetched. 45067
FaviconHelpers.h Indicates when a icon should be fetched from network. 9088
Helpers.cpp 13111
Helpers.h This file contains helper classes used by various bits of Places code. 10228
History.cpp Sets the transition type of the visit, as well as if it was typed. @param aTransitionType The transition type constant to set. Must be one of the TRANSITION_ constants on nsINavHistoryService. 79353
History.h Adds an entry in moz_places with the data in aVisitData. @param aPlace The visit data to use to populate a new row in moz_places. 6418
History.sys.mjs Asynchronous API for managing history. The API makes use of `PageInfo` and `VisitInfo` objects, defined as follows. A `PageInfo` object is any object that contains A SUBSET of the following properties: - guid: (string) The globally unique id of the page. - url: (URL) or (nsIURI) or (string) The full URI of the page. Note that `PageInfo` values passed as argument may hold `nsIURI` or `string` values for property `url`, but `PageInfo` objects returned by this module always hold `URL` values. - title: (string) The title associated with the page, if any. - description: (string) The description of the page, if any. - previewImageURL: (URL) or (nsIURI) or (string) The preview image URL of the page, if any. - frecency: (number) The frecency of the page, if any. See https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Places/Frecency_algorithm Note that this property may not be used to change the actualy frecency score of a page, only to retrieve it. In other words, any `frecency` field passed as argument to a function of this API will be ignored. - visits: (Array<VisitInfo>) All the visits for this page, if any. - annotations: (Map) A map containing key/value pairs of the annotations for this page, if any. See the documentation of individual methods to find out which properties are required for `PageInfo` arguments or returned for `PageInfo` results. A `VisitInfo` object is any object that contains A SUBSET of the following properties: - date: (Date) The time the visit occurred. - transition: (number) How the user reached the page. See constants `TRANSITIONS.*` for the possible transition types. - referrer: (URL) or (nsIURI) or (string) The referring URI of this visit. Note that `VisitInfo` passed as argument may hold `nsIURI` or `string` values for property `referrer`, but `VisitInfo` objects returned by this module always hold `URL` values. See the documentation of individual methods to find out which properties are required for `VisitInfo` arguments or returned for `VisitInfo` results. Each successful operation notifies through the PlacesObservers. To listen to such notifications you must register using PlacesObservers `addListener` and `removeListener` methods. @see PlacesObservers 57854
INativePlacesEventCallback.h 989
moz.build 2381
mozIAsyncHistory.idl The machine-local (internal) id of the visit. 5255
mozIPlacesAutoComplete.idl This interface provides some constants used by the Places AutoComplete search provider as well as methods to track opened pages for AutoComplete purposes. 2859
mozIPlacesPendingOperation.idl Cancels a pending operation, if possible. This will only fail if you try to cancel more than once. 487
mozISyncedBookmarksMirror.idl 4094
NotifyRankingChanged.h 1331
nsCachedFaviconProtocolHandler.cpp Implementation of cached-favicon: URLs for accessing favicons. The urls are sent to the favicon service. If the favicon service doesn't have the data, a stream containing the default favicon will be returned. 11179
nsCachedFaviconProtocolHandler.h Obtains a new channel to be used to get a favicon from the database. This method is asynchronous. @param aURI The URI the channel will be created for. This is the URI that is set as the original URI on the channel. @param aCachedFaviconURI The URI that holds the data needed to get the favicon from the database. @param aLoadInfo The loadinfo that requested the resource load. @returns (via _channel) the channel that will obtain the favicon data. 1997
nsFaviconService.cpp This is the favicon service, which stores favicons for web pages with your history as you browse. It is also used to save the favicons for bookmarks. DANGER: The history query system makes assumptions about the favicon storage so that icons can be quickly generated for history/bookmark result sets. If you change the database layout at all, you will have to update both services. 30728
nsFaviconService.h Obtains the service's object. 4529
nsIFaviconService.idl The limit in bytes of the size of favicons in memory and passed via the favicon protocol. 14961
nsINavBookmarksService.idl The BookmarksService interface provides methods for managing bookmarked history items. Bookmarks consist of a set of user-customizable folders. A URI in history can be contained in one or more such folders. 8935
nsINavHistoryService.idl Using Places services after quit-application is not reliable, so make sure to do any shutdown work on quit-application, or history synchronization could fail, losing latest changes. 40022
nsIPlacesPreviewsHelperService.idl A service which returns information about file paths where the previews for URLs are stored. These previews are used by the moz-page-thumb protocol 649
nsITaggingService.idl Tags a URL with the given set of tags. Current tags set for the URL persist. Tags in aTags which are already set for the given URL are ignored. @param aURI the URL to tag. @param aTags Array of tags to set for the given URL. Each element within the array can be either a tag name (non-empty string) or a concrete itemId of a tag container. @param [optional] aSource A change source constant from nsINavBookmarksService::SOURCE_*. Defaults to SOURCE_DEFAULT if omitted. 2054
nsNavBookmarks.cpp 63067
nsNavBookmarks.h Obtains the service's object. 10469
nsNavHistory.cpp 102641
nsNavHistory.h Obtains the nsNavHistory object. 16549
nsNavHistoryQuery.cpp This file contains the definitions of nsNavHistoryQuery, nsNavHistoryQueryOptions, and those functions in nsINavHistory that directly support queries (specifically QueryStringToQuery and QueryToQueryString). 37591
nsNavHistoryQuery.h The definitions of nsNavHistoryQuery and nsNavHistoryQueryOptions. This header file should only be included from nsNavHistory.h, include that if you want these classes. 4861
nsNavHistoryResult.cpp Returns conditions for query update. QUERYUPDATE_TIME: This query is only limited by an inclusive time range on the first query object. The caller can quickly evaluate the time itself if it chooses. This is even simpler than "simple" below. QUERYUPDATE_SIMPLE: This query is evaluatable using evaluateQueryForNode to do live updating. QUERYUPDATE_COMPLEX: This query is not evaluatable using evaluateQueryForNode. When something happens that this query updates, you will need to re-run the query. QUERYUPDATE_COMPLEX_WITH_BOOKMARKS: A complex query that additionally has dependence on bookmarks. All bookmark-dependent queries fall under this category. QUERYUPDATE_MOBILEPREF: A complex query but only updates when the mobile preference changes. QUERYUPDATE_NONE: A query that never updates, e.g. the left-pane root query. aHasSearchTerms will be set to true if the query has any dependence on keywords. When there is no dependence on keywords, we can handle title change operations as simple instead of complex. 160426
nsNavHistoryResult.h The definitions of objects that make up a history query result set. This file should only be included by nsNavHistory.h, include that if you want these classes. 36598
nsPlacesIndexes.h moz_places 3983
nsPlacesMacros.h Null out ret before _sInstance so the destructor doesn't assert 1616
nsPlacesTables.h 16859
nsPlacesTriggers.h These visit types are excluded from visit_count: 0 - invalid 4 - EMBED 7 - DOWNLOAD 8 - FRAMED_LINK 9 - RELOAD 22571
PageIconProtocolHandler.cpp 13570
PageIconProtocolHandler.h To be called in the parent process to obtain an input stream for the given icon. @param aChildURI a page-icon URI sent from the child. @param aLoadInfo the nsILoadInfo for the load attempt from the child. @param aTerminateSender out param set to true when the params are invalid and indicate the child should be terminated. If |aChildURI| is not a page-icon URI, the child is in an invalid state and should be terminated. This outparam will be set synchronously. @return RemoteStreamPromise The RemoteStreamPromise will resolve with an RemoteStreamInfo on success, and reject with an nsresult on failure. 3523
PlaceInfo.cpp 3464
PlaceInfo.h 1271
PlacesBackups.sys.mjs Appends meta-data information to a given filename. 16640
PlacesDBUtils.sys.mjs Executes integrity check and common maintenance tasks. @return a Map[taskName(String) -> Object]. The Object has the following properties: - succeeded: boolean - logs: an array of strings containing the messages logged by the task. 50378
PlacesExpiration.sys.mjs This component handles history and orphans expiration. Expiration runs: - At idle, but just once, we stop any other kind of expiration during idle to preserve batteries in portable devices. - At shutdown, only if the database is dirty, we should still avoid to expire too heavily on shutdown. - On a repeating timer we expire in small chunks. Expiration algorithm will adapt itself based on: - Memory size of the device. - Status of the database (clean or dirty). 33035
PlacesFrecencyRecalculator.sys.mjs This component handles frecency recalculations and decay on idle. 20559
PlacesPreviews.sys.mjs This extends Set to only keep the latest 100 entries. 13637
PlacesQuery.sys.mjs -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 13613
PlacesSyncUtils.sys.mjs This module exports functions for Sync to use when applying remote records. The calls are similar to those in `Bookmarks.sys.mjs` and `nsINavBookmarksService`, with special handling for tags, keywords, synced annotations, and missing parents. 70968
PlacesTransactions.sys.mjs 58258
PlacesUtils.sys.mjs -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 95460
Shutdown.cpp 6887
Shutdown.h This is most of the code responsible for Places shutdown. PHASE 1 (Legacy clients shutdown) The shutdown procedure begins when the Database singleton receives profile-change-teardown (note that tests will instead notify nsNavHistory, that forwards the notification to the Database instance). Database::Observe first of all checks if initialization was completed properly, to avoid race conditions, then it notifies "places-shutdown" to legacy clients. Legacy clients are supposed to start and complete any shutdown critical work in the same tick, since we won't wait for them. PHASE 2 (Modern clients shutdown) Modern clients should instead register as a blocker by passing a promise to nsINavHistoryService::shutdownClient (for example see Sanitizer.sys.mjs), so they block Places shutdown until the promise is resolved. When profile-change-teardown is observed by async shutdown, it calls ClientsShutdownBlocker::BlockShutdown. This class is registered as a teardown phase blocker in Database::Init (see Database::mClientsShutdown). ClientsShutdownBlocker::BlockShudown waits for all the clients registered through nsINavHistoryService::shutdownClient. When all the clients are done, its `Done` method is invoked, and it stops blocking the shutdown phase, so that it can continue. PHASE 3 (Connection shutdown) ConnectionBlocker is registered as a profile-before-change blocker in Database::Init (see Database::mConnectionShutdown). When profile-before-change is observer by async shutdown, it calls ConnectionShutdownBlocker::BlockShutdown. Then the control is passed to Database::Shutdown, that executes some sanity checks, clears cached statements and proceeds with asyncClose. Once the connection is definitely closed, Database will call back ConnectionBlocker::Complete. At this point a final places-connection-closed notification is sent, for testing purposes. 5764
SQLFunctions.cpp Scan forward through UTF-8 text until the next potential character that could match a given codepoint when lower-cased (false positives are okay). This avoids having to actually parse the UTF-8 text, which is slow. @param aStart An iterator pointing to the first character position considered. It will be updated by this function. @param aEnd An interator pointing to past-the-end of the string. 53210
SQLFunctions.h This file contains functions that Places adds to the database handle that can be accessed by SQL queries. Keep the GUID-related parts of this file in sync with toolkit/downloads/SQLFunctions.[h|cpp]! 19755
SyncedBookmarksMirror.h 865
SyncedBookmarksMirror.sys.mjs This file implements a mirror and two-way merger for synced bookmarks. The mirror matches the complete tree stored on the Sync server, and stages new bookmarks changed on the server since the last sync. The merger walks the local tree in Places and the mirrored remote tree, produces a new merged tree, then updates the local tree to reflect the merged tree. Let's start with an overview of the different classes, and how they fit together. - `SyncedBookmarksMirror` sets up the database, validates and upserts new incoming records, attaches to Places, and applies the changed records. During application, we fetch the local and remote bookmark trees, merge them, and update Places to match. Merging and application happen in a single transaction, so applying the merged tree won't collide with local changes. A failure at this point aborts the merge and leaves Places unchanged. - A `BookmarkTree` is a fully rooted tree that also notes deletions. A `BookmarkNode` represents a local item in Places, or a remote item in the mirror. - A `MergedBookmarkNode` holds a local node, a remote node, and a `MergeState` that indicates which node to prefer when updating Places and the server to match the merged tree. - `BookmarkObserverRecorder` records all changes made to Places during the merge, then dispatches `PlacesObservers` notifications. Places uses these notifications to update the UI and internal caches. We can't dispatch during the merge because observers won't see the changes until the merge transaction commits and the database is consistent again. - After application, we flag all applied incoming items as merged, create Sync records for the locally new and updated items in Places, and upload the records to the server. At this point, all outgoing items are flagged as changed in Places, so the next sync can resume cleanly if the upload is interrupted or fails. - Once upload succeeds, we update the mirror with the uploaded records, so that the mirror matches the server again. An interruption or error here will leave the uploaded items flagged as changed in Places, so we'll merge them again on the next sync. This is redundant work, but shouldn't cause issues. 90861
TaggingService.sys.mjs The Places Tagging Service 17388
tests
VisitInfo.cpp 1461
VisitInfo.h 882