2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Places code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Google Inc.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Brett Wilson <brettw@gmail.com> (original author)
|
2008-02-28 08:04:13 -08:00
|
|
|
* Edward Lee <edward.lee@engineering.uiuc.edu>
|
2008-10-19 14:14:59 -07:00
|
|
|
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
2009-10-09 03:30:12 -07:00
|
|
|
* Marco Bonardo <mak77@bonardo.net>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsNavHistory_h_
|
|
|
|
#define nsNavHistory_h_
|
|
|
|
|
|
|
|
#include "nsINavHistoryService.h"
|
2008-08-16 15:21:23 -07:00
|
|
|
#include "nsPIPlacesDatabase.h"
|
2009-03-03 10:27:01 -08:00
|
|
|
#include "nsPIPlacesHistoryListenersNotifier.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIBrowserHistory.h"
|
|
|
|
#include "nsIGlobalHistory.h"
|
|
|
|
#include "nsIGlobalHistory3.h"
|
2007-12-21 18:27:11 -08:00
|
|
|
#include "nsIDownloadHistory.h"
|
2009-11-11 03:04:18 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPrefService.h"
|
2010-01-15 08:40:19 -08:00
|
|
|
#include "nsIPrefBranch2.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIObserverService.h"
|
2009-11-11 03:04:18 -08:00
|
|
|
#include "nsICollation.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsMaybeWeakPtr.h"
|
2009-03-25 13:31:36 -07:00
|
|
|
#include "nsCategoryCache.h"
|
2009-11-11 03:04:18 -08:00
|
|
|
#include "nsICharsetResolver.h"
|
|
|
|
#include "nsNetCID.h"
|
2009-12-01 05:00:45 -08:00
|
|
|
#include "nsToolkitCompsCID.h"
|
2009-11-11 03:04:18 -08:00
|
|
|
|
|
|
|
#include "nsINavBookmarksService.h"
|
|
|
|
#include "nsIPrivateBrowsingService.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsNavHistoryResult.h"
|
|
|
|
#include "nsNavHistoryQuery.h"
|
|
|
|
|
2009-11-11 03:04:18 -08:00
|
|
|
#include "mozilla/storage.h"
|
2008-10-19 14:14:59 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// define to enable lazy link adding
|
|
|
|
#define LAZY_ADD
|
|
|
|
|
|
|
|
#define QUERYUPDATE_TIME 0
|
|
|
|
#define QUERYUPDATE_SIMPLE 1
|
|
|
|
#define QUERYUPDATE_COMPLEX 2
|
|
|
|
#define QUERYUPDATE_COMPLEX_WITH_BOOKMARKS 3
|
2008-02-26 20:48:51 -08:00
|
|
|
#define QUERYUPDATE_HOST 4
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-19 14:14:59 -07:00
|
|
|
// This magic number specified an uninitialized value for the
|
|
|
|
// mInPrivateBrowsing member
|
|
|
|
#define PRIVATEBROWSING_NOTINITED (PRBool(0xffffffff))
|
|
|
|
|
2009-12-22 04:05:14 -08:00
|
|
|
// Clamp title and URL to generously large, but not too large, length.
|
|
|
|
// See bug 319004 for details.
|
|
|
|
#define URI_LENGTH_MAX 65536
|
|
|
|
#define TITLE_LENGTH_MAX 4096
|
|
|
|
|
2008-11-12 12:45:53 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class mozIAnnotationService;
|
|
|
|
class nsNavHistory;
|
|
|
|
class nsNavBookmarks;
|
|
|
|
class QueryKeyValuePair;
|
2008-02-06 20:18:17 -08:00
|
|
|
class nsIEffectiveTLDService;
|
|
|
|
class nsIIDNService;
|
2008-02-26 20:48:51 -08:00
|
|
|
class PlacesSQLQueryBuilder;
|
2009-07-13 12:19:03 -07:00
|
|
|
class nsIAutoCompleteController;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsNavHistory
|
|
|
|
|
2009-03-03 10:27:01 -08:00
|
|
|
class nsNavHistory : public nsSupportsWeakReference
|
|
|
|
, public nsINavHistoryService
|
|
|
|
, public nsIObserver
|
|
|
|
, public nsIBrowserHistory
|
|
|
|
, public nsIGlobalHistory3
|
|
|
|
, public nsIDownloadHistory
|
|
|
|
, public nsICharsetResolver
|
2008-08-16 15:21:23 -07:00
|
|
|
, public nsPIPlacesDatabase
|
2009-03-03 10:27:01 -08:00
|
|
|
, public nsPIPlacesHistoryListenersNotifier
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-02-26 20:48:51 -08:00
|
|
|
friend class PlacesSQLQueryBuilder;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
nsNavHistory();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_NSINAVHISTORYSERVICE
|
|
|
|
NS_DECL_NSIGLOBALHISTORY2
|
|
|
|
NS_DECL_NSIGLOBALHISTORY3
|
2007-12-21 18:27:11 -08:00
|
|
|
NS_DECL_NSIDOWNLOADHISTORY
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIBROWSERHISTORY
|
|
|
|
NS_DECL_NSIOBSERVER
|
2008-08-16 15:21:23 -07:00
|
|
|
NS_DECL_NSPIPLACESDATABASE
|
2009-03-03 10:27:01 -08:00
|
|
|
NS_DECL_NSPIPLACESHISTORYLISTENERSNOTIFIER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-17 19:36:32 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtains the nsNavHistory object.
|
|
|
|
*/
|
2009-12-02 08:39:16 -08:00
|
|
|
static nsNavHistory *GetSingleton();
|
2008-02-17 19:36:32 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the nsNavHistory object. This should only be called once.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used by other components in the places directory such as the annotation
|
|
|
|
* service to get a reference to this history object. Returns a pointer to
|
|
|
|
* the service if it exists. Otherwise creates one. Returns NULL on error.
|
|
|
|
*/
|
2009-12-02 08:39:16 -08:00
|
|
|
static nsNavHistory *GetHistoryService()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-12-01 05:00:45 -08:00
|
|
|
if (!gHistoryService) {
|
|
|
|
nsCOMPtr<nsINavHistoryService> serv =
|
|
|
|
do_GetService(NS_NAVHISTORYSERVICE_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(serv, nsnull);
|
|
|
|
NS_ASSERTION(gHistoryService, "Should have static instance pointer now");
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return gHistoryService;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef LAZY_ADD
|
|
|
|
/**
|
|
|
|
* Adds a lazy message for adding a favicon. Used by the favicon service so
|
|
|
|
* that favicons are handled lazily just like page adds.
|
|
|
|
*/
|
|
|
|
nsresult AddLazyLoadFaviconMessage(nsIURI* aPage, nsIURI* aFavicon,
|
|
|
|
PRBool aForceReload);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the database ID for the given URI, or 0 if not found and autoCreate
|
|
|
|
* is false.
|
|
|
|
*/
|
|
|
|
nsresult GetUrlIdFor(nsIURI* aURI, PRInt64* aEntryID,
|
|
|
|
PRBool aAutoCreate);
|
|
|
|
|
2008-03-26 21:05:25 -07:00
|
|
|
nsresult CalculateFullVisitCount(PRInt64 aPlaceId, PRInt32 *aVisitCount);
|
2008-01-25 09:11:14 -08:00
|
|
|
|
2009-04-23 14:12:51 -07:00
|
|
|
nsresult UpdateFrecency(PRInt64 aPlaceId, PRBool aIsBookmark);
|
|
|
|
nsresult UpdateFrecencyInternal(PRInt64 aPlaceId, PRInt32 aTyped,
|
|
|
|
PRInt32 aHidden, PRInt32 aOldFrecency,
|
|
|
|
PRBool aIsBookmark);
|
2008-01-25 09:11:14 -08:00
|
|
|
|
2009-04-10 08:24:10 -07:00
|
|
|
/**
|
|
|
|
* Calculate frecencies for places that don't have a valid value yet
|
|
|
|
*/
|
|
|
|
nsresult FixInvalidFrecencies();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the frecencies of excluded places so they don't show up in queries
|
|
|
|
*/
|
2008-01-25 09:11:14 -08:00
|
|
|
nsresult FixInvalidFrecenciesForExcludedPlaces();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Returns a pointer to the storage connection used by history. This
|
|
|
|
* connection object is also used by the annotation service and bookmarks, so
|
|
|
|
* that things can be grouped into transactions across these components.
|
|
|
|
*
|
|
|
|
* NOT ADDREFed.
|
|
|
|
*
|
|
|
|
* This connection can only be used in the thread that created it the
|
|
|
|
* history service!
|
|
|
|
*/
|
|
|
|
mozIStorageConnection* GetStorageConnection()
|
|
|
|
{
|
|
|
|
return mDBConn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* These functions return non-owning references to the locale-specific
|
2008-10-27 15:52:21 -07:00
|
|
|
* objects for places components.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2008-10-27 15:52:22 -07:00
|
|
|
nsIStringBundle* GetBundle();
|
2009-03-23 05:42:03 -07:00
|
|
|
nsIStringBundle* GetDateFormatBundle();
|
2008-10-27 15:52:21 -07:00
|
|
|
nsICollation* GetCollation();
|
2008-02-26 20:48:51 -08:00
|
|
|
void GetStringFromName(const PRUnichar* aName, nsACString& aResult);
|
2008-10-27 15:52:22 -07:00
|
|
|
void GetAgeInDaysString(PRInt32 aInt, const PRUnichar *aName,
|
|
|
|
nsACString& aResult);
|
2009-03-23 05:42:03 -07:00
|
|
|
void GetMonthName(PRInt32 aIndex, nsACString& aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-15 08:40:14 -08:00
|
|
|
// Returns whether history is enabled or not.
|
|
|
|
PRBool IsHistoryDisabled() {
|
2010-01-15 08:40:19 -08:00
|
|
|
return !mHistoryEnabled || InPrivateBrowsingMode();
|
2010-01-15 08:40:14 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Constants for the columns returned by the above statement.
|
|
|
|
static const PRInt32 kGetInfoIndex_PageID;
|
|
|
|
static const PRInt32 kGetInfoIndex_URL;
|
|
|
|
static const PRInt32 kGetInfoIndex_Title;
|
|
|
|
static const PRInt32 kGetInfoIndex_RevHost;
|
|
|
|
static const PRInt32 kGetInfoIndex_VisitCount;
|
2007-05-10 01:05:19 -07:00
|
|
|
static const PRInt32 kGetInfoIndex_ItemId;
|
2007-05-18 17:40:55 -07:00
|
|
|
static const PRInt32 kGetInfoIndex_ItemDateAdded;
|
|
|
|
static const PRInt32 kGetInfoIndex_ItemLastModified;
|
2009-10-05 03:12:38 -07:00
|
|
|
static const PRInt32 kGetInfoIndex_ItemTags;
|
|
|
|
static const PRInt32 kGetInfoIndex_ItemParentId;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// select a history row by id
|
2009-12-02 08:39:16 -08:00
|
|
|
mozIStorageStatement *DBGetIdPageInfo() { return mDBGetIdPageInfo; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-02 08:39:16 -08:00
|
|
|
mozIStorageStatement *DBGetTags() { return mDBGetTags; }
|
2008-11-05 10:20:00 -08:00
|
|
|
PRInt64 GetTagsFolder();
|
|
|
|
|
2009-08-20 11:56:10 -07:00
|
|
|
mozIStorageStatement *DBGetIsVisited() { return mDBIsPageVisited; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Constants for the columns returned by the above statement
|
|
|
|
// (in addition to the ones above).
|
|
|
|
static const PRInt32 kGetInfoIndex_VisitDate;
|
|
|
|
static const PRInt32 kGetInfoIndex_FaviconURL;
|
|
|
|
|
|
|
|
// used in execute queries to get session ID info (only for visits)
|
|
|
|
static const PRInt32 kGetInfoIndex_SessionId;
|
|
|
|
|
|
|
|
// this actually executes a query and gives you results, it is used by
|
|
|
|
// nsNavHistoryQueryResultNode
|
2007-06-19 22:19:06 -07:00
|
|
|
nsresult GetQueryResults(nsNavHistoryQueryResultNode *aResultNode,
|
|
|
|
const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsNavHistoryQueryOptions *aOptions,
|
|
|
|
nsCOMArray<nsNavHistoryResultNode>* aResults);
|
|
|
|
|
|
|
|
// Take a row of kGetInfoIndex_* columns and construct a ResultNode.
|
|
|
|
// The row must contain the full set of columns.
|
|
|
|
nsresult RowToResult(mozIStorageValueArray* aRow,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsNavHistoryResultNode** aResult);
|
2007-09-01 14:23:36 -07:00
|
|
|
nsresult QueryRowToResult(PRInt64 aItemId, const nsACString& aURI,
|
|
|
|
const nsACString& aTitle,
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint32 aAccessCount, PRTime aTime,
|
|
|
|
const nsACString& aFavicon,
|
|
|
|
nsNavHistoryResultNode** aNode);
|
|
|
|
|
|
|
|
nsresult VisitIdToResultNode(PRInt64 visitId,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsNavHistoryResultNode** aResult);
|
2008-01-04 21:16:27 -08:00
|
|
|
|
2007-04-25 14:03:29 -07:00
|
|
|
nsresult BookmarkIdToResultNode(PRInt64 aBookmarkId,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsNavHistoryResultNode** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// used by other places components to send history notifications (for example,
|
|
|
|
// when the favicon has changed)
|
|
|
|
void SendPageChangedNotification(nsIURI* aURI, PRUint32 aWhat,
|
2009-03-25 13:31:36 -07:00
|
|
|
const nsAString& aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-22 04:05:04 -08:00
|
|
|
/**
|
|
|
|
* Returns current number of days stored in history.
|
|
|
|
*/
|
|
|
|
PRInt32 GetDaysOfHistory();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// used by query result nodes to update: see comment on body of CanLiveUpdateQuery
|
|
|
|
static PRUint32 GetUpdateRequirements(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
PRBool* aHasSearchTerms);
|
|
|
|
PRBool EvaluateQueryForNode(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsNavHistoryResultNode* aNode);
|
|
|
|
|
|
|
|
static nsresult AsciiHostNameFromHostString(const nsACString& aHostName,
|
|
|
|
nsACString& aAscii);
|
2008-02-06 20:18:17 -08:00
|
|
|
void DomainNameFromURI(nsIURI* aURI,
|
|
|
|
nsACString& aDomainName);
|
2007-03-22 10:30:00 -07:00
|
|
|
static PRTime NormalizeTime(PRUint32 aRelative, PRTime aOffset);
|
|
|
|
|
2007-05-31 17:44:43 -07:00
|
|
|
// Don't use these directly, inside nsNavHistory use UpdateBatchScoper,
|
|
|
|
// else use nsINavHistoryService::RunInBatchMode
|
|
|
|
nsresult BeginUpdateBatch();
|
|
|
|
nsresult EndUpdateBatch();
|
|
|
|
|
2007-08-14 07:20:42 -07:00
|
|
|
// the level of nesting of batches, 0 when no batches are open
|
|
|
|
PRInt32 mBatchLevel;
|
|
|
|
|
|
|
|
// true if the outermost batch has an associated transaction that should
|
|
|
|
// be committed when our batch level reaches 0 again.
|
|
|
|
PRBool mBatchHasTransaction;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// better alternative to QueryStringToQueries (in nsNavHistoryQuery.cpp)
|
|
|
|
nsresult QueryStringToQueryArray(const nsACString& aQueryString,
|
|
|
|
nsCOMArray<nsNavHistoryQuery>* aQueries,
|
|
|
|
nsNavHistoryQueryOptions** aOptions);
|
|
|
|
|
2008-03-12 16:36:24 -07:00
|
|
|
// Import-friendly version of AddVisit.
|
2007-03-22 10:30:00 -07:00
|
|
|
// This method adds a page to history along with a single last visit.
|
|
|
|
// aLastVisitDate can be -1 if there is no last visit date to record.
|
2007-11-20 10:23:38 -08:00
|
|
|
//
|
2009-01-13 02:48:25 -08:00
|
|
|
// This is only for use by the import of history.dat on first-run of Places,
|
|
|
|
// which currently occurs if no places.sqlite file previously exists.
|
|
|
|
nsresult AddPageWithVisits(nsIURI *aURI,
|
|
|
|
const nsString &aTitle,
|
|
|
|
PRInt32 aVisitCount,
|
|
|
|
PRInt32 aTransitionType,
|
|
|
|
PRTime aFirstVisitDate,
|
|
|
|
PRTime aLastVisitDate);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Checks the database for any duplicate URLs. If any are found,
|
|
|
|
// all but the first are removed. This must be called after using
|
2009-01-13 02:48:25 -08:00
|
|
|
// AddPageWithVisits, to ensure that the database is in a consistent state.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult RemoveDuplicateURIs();
|
|
|
|
|
2007-05-02 12:07:57 -07:00
|
|
|
// sets the schema version in the database to match SCHEMA_VERSION
|
|
|
|
nsresult UpdateSchemaVersion();
|
|
|
|
|
2008-10-19 14:14:59 -07:00
|
|
|
// Returns true if we are currently in private browsing mode
|
|
|
|
PRBool InPrivateBrowsingMode()
|
|
|
|
{
|
|
|
|
if (mInPrivateBrowsing == PRIVATEBROWSING_NOTINITED) {
|
|
|
|
mInPrivateBrowsing = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIPrivateBrowsingService> pbs =
|
|
|
|
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
|
|
|
if (pbs) {
|
|
|
|
pbs->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mInPrivateBrowsing;
|
|
|
|
}
|
|
|
|
|
2008-03-19 14:08:10 -07:00
|
|
|
typedef nsDataHashtable<nsCStringHashKey, nsCString> StringHash;
|
|
|
|
|
2008-11-13 22:45:49 -08:00
|
|
|
/**
|
|
|
|
* Helper method to finalize a statement
|
|
|
|
*/
|
|
|
|
static nsresult
|
|
|
|
FinalizeStatement(mozIStorageStatement *aStatement) {
|
|
|
|
nsresult rv;
|
|
|
|
if (aStatement) {
|
|
|
|
rv = aStatement->Finalize();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-03-25 13:31:36 -07:00
|
|
|
/**
|
|
|
|
* Indicates if it is OK to notify history observers or not.
|
|
|
|
*
|
|
|
|
* @returns true if it is OK to notify, false otherwise.
|
|
|
|
*/
|
|
|
|
bool canNotify() { return mCanNotify; }
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
~nsNavHistory();
|
|
|
|
|
|
|
|
// used by GetHistoryService
|
2009-12-01 05:00:45 -08:00
|
|
|
static nsNavHistory *gHistoryService;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2010-01-15 08:40:19 -08:00
|
|
|
nsCOMPtr<nsIPrefBranch2> mPrefBranch; // MAY BE NULL when we are shutting down
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDataHashtable<nsStringHashKey, int> gExpandedItems;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Database stuff
|
|
|
|
//
|
|
|
|
nsCOMPtr<mozIStorageService> mDBService;
|
|
|
|
nsCOMPtr<mozIStorageConnection> mDBConn;
|
2007-06-27 13:57:56 -07:00
|
|
|
nsCOMPtr<nsIFile> mDBFile;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetURLPageInfo; // kGetInfoIndex_* results
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetIdPageInfo; // kGetInfoIndex_* results
|
|
|
|
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBRecentVisitOfURL; // converts URL into most recent visit ID/session ID
|
2008-08-16 15:28:28 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBRecentVisitOfPlace; // converts placeID into most recent visit ID/session ID
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBInsertVisit; // used by AddVisit
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetPageVisitStats; // used by AddVisit
|
2008-03-28 23:48:28 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBIsPageVisited; // used by IsURIStringVisited
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBUpdatePageVisitStats; // used by AddVisit
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBAddNewPage; // used by InternalAddNewPage
|
2009-10-05 03:12:38 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetTags; // used by GetTags
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetItemsWithAnno; // used by AutoComplete::StartSearch and FilterResultSet
|
2008-10-27 15:52:21 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBSetPlaceTitle; // used by SetPageTitleInternal
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// these are used by VisitIdToResultNode for making new result nodes from IDs
|
2008-10-27 15:52:23 -07:00
|
|
|
// Consumers need to use the getters since these statements are lazily created
|
|
|
|
mozIStorageStatement *GetDBVisitToURLResult();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBVisitToURLResult; // kGetInfoIndex_* results
|
2008-10-27 15:52:23 -07:00
|
|
|
mozIStorageStatement *GetDBVisitToVisitResult();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBVisitToVisitResult; // kGetInfoIndex_* results
|
2008-10-27 15:52:23 -07:00
|
|
|
mozIStorageStatement *GetDBBookmarkToUrlResult();
|
2007-04-25 14:03:29 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-13 22:45:49 -08:00
|
|
|
/**
|
|
|
|
* Finalize all internal statements.
|
|
|
|
*/
|
2009-12-22 04:05:14 -08:00
|
|
|
nsresult FinalizeStatements();
|
2008-11-13 22:45:49 -08:00
|
|
|
|
2009-09-14 04:06:45 -07:00
|
|
|
/**
|
|
|
|
* Analyzes the database and VACUUM it, if needed.
|
|
|
|
*/
|
2009-12-22 04:05:14 -08:00
|
|
|
nsresult DecayFrecency();
|
2009-09-14 04:06:45 -07:00
|
|
|
/**
|
|
|
|
* Decays frecency and inputhistory values.
|
|
|
|
*/
|
2009-12-22 04:05:14 -08:00
|
|
|
nsresult VacuumDatabase();
|
2009-09-14 04:06:45 -07:00
|
|
|
|
2009-10-14 02:53:13 -07:00
|
|
|
/**
|
|
|
|
* Finalizes all Places internal statements, allowing to safely close the
|
|
|
|
* database connection.
|
|
|
|
*/
|
2009-12-22 04:05:14 -08:00
|
|
|
nsresult FinalizeInternalStatements();
|
2009-10-14 02:53:13 -07:00
|
|
|
|
2008-04-08 11:41:04 -07:00
|
|
|
// nsICharsetResolver
|
|
|
|
NS_DECL_NSICHARSETRESOLVER
|
|
|
|
|
2008-01-25 09:11:14 -08:00
|
|
|
nsresult CalculateFrecency(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, nsCAutoString &aURL, PRInt32 *aFrecency);
|
|
|
|
nsresult CalculateFrecencyInternal(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, PRBool aIsBookmarked, PRInt32 *aFrecency);
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBVisitsForFrecency;
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBUpdateFrecencyAndHidden;
|
|
|
|
nsCOMPtr<mozIStorageStatement> mDBGetPlaceVisitStats;
|
2008-03-26 21:05:25 -07:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBFullVisitCount;
|
2008-01-25 09:11:14 -08:00
|
|
|
|
2008-02-06 10:10:39 -08:00
|
|
|
/**
|
|
|
|
* Initializes the database file. If the database does not exist, was
|
|
|
|
* corrupted, or aForceInit is true, we recreate the database. We also backup
|
|
|
|
* the database if it was corrupted or aForceInit is true.
|
|
|
|
*
|
|
|
|
* @param aForceInit
|
|
|
|
* Indicates if we should close an open database connection or not.
|
2008-02-09 11:15:45 -08:00
|
|
|
* Note: A valid database connection must be opened if this is true.
|
2008-02-06 10:10:39 -08:00
|
|
|
*/
|
2007-06-27 13:57:56 -07:00
|
|
|
nsresult InitDBFile(PRBool aForceInit);
|
2008-02-06 10:10:39 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the database. This performs any necessary migrations for the
|
|
|
|
* database. All migration is done inside a transaction that is rolled back
|
|
|
|
* if any error occurs. Upon initialization, history is imported, and some
|
|
|
|
* preferences that are used are set.
|
|
|
|
*/
|
2008-12-30 13:42:23 -08:00
|
|
|
nsresult InitDB();
|
2009-05-18 16:06:46 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes additional database items like: views, temp tables, functions
|
|
|
|
* and statements.
|
|
|
|
*/
|
|
|
|
nsresult InitAdditionalDBItems();
|
2008-10-27 15:52:19 -07:00
|
|
|
nsresult InitTempTables();
|
|
|
|
nsresult InitViews();
|
2008-02-26 20:48:51 -08:00
|
|
|
nsresult InitFunctions();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult InitStatements();
|
2007-04-04 10:21:03 -07:00
|
|
|
nsresult ForceMigrateBookmarksDB(mozIStorageConnection *aDBConn);
|
2007-04-22 14:48:52 -07:00
|
|
|
nsresult MigrateV3Up(mozIStorageConnection *aDBConn);
|
2007-07-26 09:23:11 -07:00
|
|
|
nsresult MigrateV6Up(mozIStorageConnection *aDBConn);
|
2008-08-04 09:59:56 -07:00
|
|
|
nsresult MigrateV7Up(mozIStorageConnection *aDBConn);
|
2008-10-27 15:52:20 -07:00
|
|
|
nsresult MigrateV8Up(mozIStorageConnection *aDBConn);
|
2009-05-14 16:28:03 -07:00
|
|
|
nsresult MigrateV9Up(mozIStorageConnection *aDBConn);
|
2009-06-24 01:59:14 -07:00
|
|
|
nsresult MigrateV10Up(mozIStorageConnection *aDBConn);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-08 14:13:29 -08:00
|
|
|
nsresult RemovePagesInternal(const nsCString& aPlaceIdsQueryString);
|
2009-05-16 19:32:13 -07:00
|
|
|
nsresult PreparePlacesForVisitsDelete(const nsCString& aPlaceIdsQueryString);
|
|
|
|
nsresult CleanupPlacesOnVisitsDelete(const nsCString& aPlaceIdsQueryString);
|
2008-02-08 14:13:29 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult AddURIInternal(nsIURI* aURI, PRTime aTime, PRBool aRedirect,
|
|
|
|
PRBool aToplevel, nsIURI* aReferrer);
|
|
|
|
|
|
|
|
nsresult AddVisitChain(nsIURI* aURI, PRTime aTime,
|
|
|
|
PRBool aToplevel, PRBool aRedirect,
|
|
|
|
nsIURI* aReferrer, PRInt64* aVisitID,
|
|
|
|
PRInt64* aSessionID, PRInt64* aRedirectBookmark);
|
|
|
|
nsresult InternalAddNewPage(nsIURI* aURI, const nsAString& aTitle,
|
|
|
|
PRBool aHidden, PRBool aTyped,
|
2008-01-25 09:11:14 -08:00
|
|
|
PRInt32 aVisitCount, PRBool aCalculateFrecency,
|
|
|
|
PRInt64* aPageID);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult InternalAddVisit(PRInt64 aPageID, PRInt64 aReferringVisit,
|
|
|
|
PRInt64 aSessionID, PRTime aTime,
|
|
|
|
PRInt32 aTransitionType, PRInt64* aVisitID);
|
|
|
|
PRBool FindLastVisit(nsIURI* aURI, PRInt64* aVisitID,
|
|
|
|
PRInt64* aSessionID);
|
|
|
|
PRBool IsURIStringVisited(const nsACString& url);
|
2008-02-06 10:10:39 -08:00
|
|
|
|
|
|
|
/**
|
2010-01-15 08:40:19 -08:00
|
|
|
* Loads all of the preferences that we use into member variables.
|
2008-02-06 10:10:39 -08:00
|
|
|
*
|
2010-01-15 08:40:19 -08:00
|
|
|
* @note If mPrefBranch is NULL, this does nothing.
|
2008-02-06 10:10:39 -08:00
|
|
|
*/
|
2010-01-15 08:40:19 -08:00
|
|
|
void LoadPrefs();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-22 04:05:06 -08:00
|
|
|
/**
|
|
|
|
* Calculates and returns value for mCachedNow.
|
|
|
|
* This is an hack to avoid calling PR_Now() too often, as is the case when
|
|
|
|
* we're asked the ageindays of many history entries in a row. A timer is
|
|
|
|
* set which will clear our valid flag after a short timeout.
|
|
|
|
*/
|
|
|
|
PRTime GetNow();
|
|
|
|
PRTime mCachedNow;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsITimer> mExpireNowTimer;
|
2009-12-22 04:05:06 -08:00
|
|
|
/**
|
|
|
|
* Called when the cached now value is expired and needs renewal.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
static void expireNowTimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
|
|
|
|
#ifdef LAZY_ADD
|
|
|
|
// lazy add committing
|
|
|
|
struct LazyMessage {
|
|
|
|
enum MessageType { Type_Invalid, Type_AddURI, Type_Title, Type_Favicon };
|
|
|
|
LazyMessage()
|
|
|
|
{
|
|
|
|
type = Type_Invalid;
|
|
|
|
isRedirect = PR_FALSE;
|
|
|
|
isToplevel = PR_FALSE;
|
|
|
|
time = 0;
|
|
|
|
alwaysLoadFavicon = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// call this with common parms to initialize. Caller is responsible for
|
|
|
|
// setting other elements manually depending on type.
|
|
|
|
nsresult Init(MessageType aType, nsIURI* aURI)
|
|
|
|
{
|
2007-11-21 13:41:17 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
type = aType;
|
|
|
|
nsresult rv = aURI->Clone(getter_AddRefs(uri));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return uri->GetSpec(uriSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
// common elements
|
|
|
|
MessageType type;
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsCString uriSpec; // stringified version of URI, for quick isVisited
|
|
|
|
|
|
|
|
// valid when type == Type_AddURI
|
|
|
|
nsCOMPtr<nsIURI> referrer;
|
|
|
|
PRBool isRedirect;
|
|
|
|
PRBool isToplevel;
|
|
|
|
PRTime time;
|
|
|
|
|
|
|
|
// valid when type == Type_Title
|
|
|
|
nsString title;
|
|
|
|
|
|
|
|
// valid when type == LAZY_FAVICON
|
|
|
|
nsCOMPtr<nsIURI> favicon;
|
|
|
|
PRBool alwaysLoadFavicon;
|
|
|
|
};
|
|
|
|
nsTArray<LazyMessage> mLazyMessages;
|
|
|
|
nsCOMPtr<nsITimer> mLazyTimer;
|
|
|
|
PRBool mLazyTimerSet;
|
|
|
|
PRUint32 mLazyTimerDeferments; // see StartLazyTimer
|
|
|
|
nsresult StartLazyTimer();
|
|
|
|
nsresult AddLazyMessage(const LazyMessage& aMessage);
|
|
|
|
static void LazyTimerCallback(nsITimer* aTimer, void* aClosure);
|
2009-12-22 04:05:14 -08:00
|
|
|
void CommitLazyMessages(PRBool aIsShutdown = PR_FALSE);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2007-07-26 14:39:06 -07:00
|
|
|
nsresult ConstructQueryString(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
2008-03-19 14:08:10 -07:00
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
2008-02-26 20:48:51 -08:00
|
|
|
nsCString& queryString,
|
2008-03-19 14:08:10 -07:00
|
|
|
PRBool& aParamsPresent,
|
|
|
|
StringHash& aAddParams);
|
2007-07-26 14:39:06 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult QueryToSelectClause(nsNavHistoryQuery* aQuery,
|
2007-04-25 14:03:29 -07:00
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
2008-03-19 14:08:10 -07:00
|
|
|
PRInt32 aQueryIndex,
|
|
|
|
nsCString* aClause);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult BindQueryClauseParameters(mozIStorageStatement* statement,
|
2008-03-19 14:08:10 -07:00
|
|
|
PRInt32 aQueryIndex,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsNavHistoryQuery* aQuery,
|
2008-03-19 14:08:10 -07:00
|
|
|
nsNavHistoryQueryOptions* aOptions);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult ResultsAsList(mozIStorageStatement* statement,
|
|
|
|
nsNavHistoryQueryOptions* aOptions,
|
|
|
|
nsCOMArray<nsNavHistoryResultNode>* aResults);
|
|
|
|
|
|
|
|
void TitleForDomain(const nsCString& domain, nsACString& aTitle);
|
|
|
|
|
2007-07-26 09:23:11 -07:00
|
|
|
nsresult SetPageTitleInternal(nsIURI* aURI, const nsAString& aTitle);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-01 14:23:36 -07:00
|
|
|
nsresult FilterResultSet(nsNavHistoryQueryResultNode *aParentNode,
|
|
|
|
const nsCOMArray<nsNavHistoryResultNode>& aSet,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<nsNavHistoryResultNode>* aFiltered,
|
2007-10-01 10:36:18 -07:00
|
|
|
const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
|
|
|
nsNavHistoryQueryOptions* aOptions);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// observers
|
|
|
|
nsMaybeWeakPtrArray<nsINavHistoryObserver> mObservers;
|
|
|
|
|
2008-02-06 20:18:17 -08:00
|
|
|
// effective tld service
|
|
|
|
nsCOMPtr<nsIEffectiveTLDService> mTLDService;
|
|
|
|
nsCOMPtr<nsIIDNService> mIDNService;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// localization
|
|
|
|
nsCOMPtr<nsIStringBundle> mBundle;
|
2009-03-23 05:42:03 -07:00
|
|
|
nsCOMPtr<nsIStringBundle> mDateFormatBundle;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsICollation> mCollation;
|
|
|
|
|
|
|
|
// annotation service : MAY BE NULL!
|
|
|
|
//nsCOMPtr<mozIAnnotationService> mAnnotationService;
|
|
|
|
|
|
|
|
// recent events
|
|
|
|
typedef nsDataHashtable<nsCStringHashKey, PRInt64> RecentEventHash;
|
|
|
|
RecentEventHash mRecentTyped;
|
|
|
|
RecentEventHash mRecentBookmark;
|
|
|
|
|
|
|
|
PRBool CheckIsRecentEvent(RecentEventHash* hashTable,
|
|
|
|
const nsACString& url);
|
|
|
|
void ExpireNonrecentEvents(RecentEventHash* hashTable);
|
|
|
|
|
|
|
|
// redirect tracking. See GetRedirectFor for a description of how this works.
|
|
|
|
struct RedirectInfo {
|
|
|
|
nsCString mSourceURI;
|
|
|
|
PRTime mTimeCreated;
|
|
|
|
PRUint32 mType; // one of TRANSITION_REDIRECT_[TEMPORARY,PERMANENT]
|
|
|
|
};
|
|
|
|
typedef nsDataHashtable<nsCStringHashKey, RedirectInfo> RedirectHash;
|
|
|
|
RedirectHash mRecentRedirects;
|
2008-10-10 08:04:34 -07:00
|
|
|
static PLDHashOperator ExpireNonrecentRedirects(
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg);
|
|
|
|
PRBool GetRedirectFor(const nsACString& aDestination, nsACString& aSource,
|
|
|
|
PRTime* aTime, PRUint32* aRedirectType);
|
|
|
|
|
2009-12-22 04:05:08 -08:00
|
|
|
// Sessions tracking.
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt64 mLastSessionID;
|
2009-12-22 04:05:08 -08:00
|
|
|
PRInt64 GetNewSessionID();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-13 12:19:03 -07:00
|
|
|
#ifdef MOZ_XUL
|
2007-03-22 10:30:00 -07:00
|
|
|
// AutoComplete stuff
|
2009-12-02 08:39:16 -08:00
|
|
|
mozIStorageStatement *GetDBFeedbackIncrease();
|
2008-02-25 13:35:57 -08:00
|
|
|
nsCOMPtr<mozIStorageStatement> mDBFeedbackIncrease;
|
2007-09-06 22:35:10 -07:00
|
|
|
|
2008-02-25 13:35:57 -08:00
|
|
|
nsresult AutoCompleteFeedback(PRInt32 aIndex,
|
|
|
|
nsIAutoCompleteController *aController);
|
2008-01-18 22:58:21 -08:00
|
|
|
#endif
|
2008-01-25 09:11:14 -08:00
|
|
|
|
2010-01-15 08:40:14 -08:00
|
|
|
// Whether history is enabled or not.
|
|
|
|
// Will mimic value of the places.history.enabled preference.
|
|
|
|
PRBool mHistoryEnabled;
|
|
|
|
|
2009-12-22 04:05:08 -08:00
|
|
|
// Frecency preferences.
|
2008-01-25 09:11:14 -08:00
|
|
|
PRInt32 mNumVisitsForFrecency;
|
|
|
|
PRInt32 mFirstBucketCutoffInDays;
|
|
|
|
PRInt32 mSecondBucketCutoffInDays;
|
|
|
|
PRInt32 mThirdBucketCutoffInDays;
|
|
|
|
PRInt32 mFourthBucketCutoffInDays;
|
|
|
|
PRInt32 mFirstBucketWeight;
|
|
|
|
PRInt32 mSecondBucketWeight;
|
|
|
|
PRInt32 mThirdBucketWeight;
|
|
|
|
PRInt32 mFourthBucketWeight;
|
|
|
|
PRInt32 mDefaultWeight;
|
|
|
|
PRInt32 mEmbedVisitBonus;
|
|
|
|
PRInt32 mLinkVisitBonus;
|
|
|
|
PRInt32 mTypedVisitBonus;
|
|
|
|
PRInt32 mBookmarkVisitBonus;
|
|
|
|
PRInt32 mDownloadVisitBonus;
|
|
|
|
PRInt32 mPermRedirectVisitBonus;
|
|
|
|
PRInt32 mTempRedirectVisitBonus;
|
|
|
|
PRInt32 mDefaultVisitBonus;
|
|
|
|
PRInt32 mUnvisitedBookmarkBonus;
|
|
|
|
PRInt32 mUnvisitedTypedBonus;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// in nsNavHistoryQuery.cpp
|
|
|
|
nsresult TokensToQueries(const nsTArray<QueryKeyValuePair>& aTokens,
|
|
|
|
nsCOMArray<nsNavHistoryQuery>* aQueries,
|
|
|
|
nsNavHistoryQueryOptions* aOptions);
|
|
|
|
|
2007-11-19 18:01:53 -08:00
|
|
|
PRInt64 mTagsFolder;
|
2008-10-19 14:14:59 -07:00
|
|
|
|
|
|
|
PRBool mInPrivateBrowsing;
|
2008-11-12 12:45:53 -08:00
|
|
|
|
2008-12-13 01:57:30 -08:00
|
|
|
PRUint16 mDatabaseStatus;
|
2009-03-25 13:31:36 -07:00
|
|
|
|
|
|
|
// Used to enable and disable the observer notifications
|
|
|
|
bool mCanNotify;
|
|
|
|
nsCategoryCache<nsINavHistoryObserver> mCacheObservers;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shared between the places components, this function binds the given URI as
|
|
|
|
* UTF8 to the given parameter for the statement.
|
|
|
|
*/
|
|
|
|
nsresult BindStatementURI(mozIStorageStatement* statement, PRInt32 index,
|
|
|
|
nsIURI* aURI);
|
|
|
|
|
|
|
|
#define PLACES_URI_PREFIX "place:"
|
|
|
|
|
|
|
|
/* Returns true if the given URI represents a history query. */
|
|
|
|
inline PRBool IsQueryURI(const nsCString &uri)
|
|
|
|
{
|
|
|
|
return StringBeginsWith(uri, NS_LITERAL_CSTRING(PLACES_URI_PREFIX));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extracts the query string from a query URI. */
|
|
|
|
inline const nsDependentCSubstring QueryURIToQuery(const nsCString &uri)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(IsQueryURI(uri), "should only be called for query URIs");
|
|
|
|
return Substring(uri, NS_LITERAL_CSTRING(PLACES_URI_PREFIX).Length());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // nsNavHistory_h_
|