Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsGlobalHistory Class Reference

#include <nsGlobalHistory.h>

Inheritance diagram for nsGlobalHistory:
Inheritance graph
[legend]
Collaboration diagram for nsGlobalHistory:
Collaboration graph
[legend]

List of all members.

Classes

class  AutoCompleteEnumerator
struct  AutoCompleteSortClosure
class  SearchEnumerator
class  URLEnumerator

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIGLOBALHISTORY2
NS_DECL_NSIBROWSERHISTORY
NS_DECL_NSIOBSERVER
NS_DECL_NSIRDFDATASOURCE
NS_DECL_NSIRDFREMOTEDATASOURCE
NS_DECL_NSIAUTOCOMPLETESEARCH
NS_METHOD 
Init ()
 nsGlobalHistory (void)
virtual ~nsGlobalHistory ()
PRBool MatchExpiration (nsIMdbRow *row, PRTime *expirationDate)
PRBool MatchHost (nsIMdbRow *row, matchHost_t *hostInfo)
PRBool RowMatches (nsIMdbRow *aRow, searchQuery *aQuery, PRBool caseSensitive)
NS_DECL_ISUPPORTS
NS_DECL_NSIGLOBALHISTORY2
NS_DECL_NSIBROWSERHISTORY
NS_DECL_NSIOBSERVER
NS_DECL_NSIRDFDATASOURCE
NS_DECL_NSIRDFREMOTEDATASOURCE
NS_DECL_NSIAUTOCOMPLETESESSION
NS_METHOD 
Init ()
 nsGlobalHistory (void)
virtual ~nsGlobalHistory ()
PRBool MatchExpiration (nsIMdbRow *row, PRTime *expirationDate)
PRBool MatchHost (nsIMdbRow *row, matchHost_t *hostInfo)
PRBool RowMatches (nsIMdbRow *aRow, searchQuery *aQuery)
PRTime GetNow ()
PRTime NormalizeTime (PRTime aTime)
PRInt32 GetAgeInDays (PRTime aDate)
void onStartLookup (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener)
void onStopLookup ()
void onAutoComplete (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener)
void addPageWithDetails (in nsIURI aURI, in wstring aTitle, in long long aLastVisited)
 addPageWithDetails Adds a page to history with specific time stamp information.
void removePage (in nsIURI aURI)
 remove a page from history
void removePage (in nsIURI aURI)
 remove a page from history
void removePagesFromHost (in AUTF8String aHost, in boolean aEntireDomain)
 removePagesFromHost Remove all pages from the given host.
void removePagesFromHost (in AUTF8String aHost, in boolean aEntireDomain)
 removePagesFromHost Remove all pages from the given host.
void removeAllPages ()
 removeAllPages Remove all pages from global history
void removeAllPages ()
 removeAllPages Remove all pages from global history
void hidePage (in nsIURI aURI)
 hidePage Hide the specified URL from being enumerated (and thus displayed in the UI)
void hidePage (in nsIURI aURI)
 hidePage Hide the specified URL from being enumerated (and thus displayed in the UI)
void markPageAsTyped (in nsIURI aURI)
 markPageAsTyped Designate the url as having been explicitly typed in by the user, so it's okay to be an autocomplete result.
void markPageAsTyped (in nsIURI aURI)
 markPageAsTyped Designate the url as having been explicitly typed in by the user, so it's okay to be an autocomplete result.
void addURI (in nsIURI aURI, in boolean aRedirect, in boolean aToplevel, in nsIURI aReferrer)
 Add a URI to global history.
boolean isVisited (in nsIURI aURI)
 Checks to see whether the given URI is in history.
void setPageTitle (in nsIURI aURI, in AString aTitle)
 Set the page title for the given uri.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.
nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find an RDF resource that points to a given node over the specified arc & truth value.
nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find all RDF resources that point to a given node over the specified arc & truth value.
nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find a child of that is related to the source by the given arc arc and truth value.
nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find all children of that are related to the source by the given arc arc and truth value.
void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Add an assertion to the graph.
void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 Remove an assertion from the graph.
void Change (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aOldTarget, in nsIRDFNode aNewTarget)
 Change an assertion from.
void Move (in nsIRDFResource aOldSource, in nsIRDFResource aNewSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 'Move' an assertion from
boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Query whether an assertion exists in this graph.
void AddObserver (in nsIRDFObserver aObserver)
 Add an observer to this data source.
void RemoveObserver (in nsIRDFObserver aObserver)
 Remove an observer from this data source.
nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode)
 Get a cursor to iterate over all the arcs that point into a node.
nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource)
 Get a cursor to iterate over all the arcs that originate in a resource.
nsISimpleEnumerator GetAllResources ()
 Retrieve all of the resources that the data source currently refers to.
boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Returns whether a given command is enabled for a set of sources.
void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Perform the specified command on set of sources.
nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource)
 Returns the set of all commands defined for a given source.
boolean hasArcIn (in nsIRDFNode aNode, in nsIRDFResource aArc)
 Returns true if the specified node is pointed to by the specified arc.
boolean hasArcOut (in nsIRDFResource aSource, in nsIRDFResource aArc)
 Returns true if the specified node has the specified outward arc.
void beginUpdateBatch ()
 Notify observers that the datasource is about to send several notifications at once.
void endUpdateBatch ()
 Notify observers that the datasource has completed issuing a notification group.
void Init (in string aURI)
 Specify the URI for the data source: this is the prefix that will be used to register the data source in the data source registry.
void Refresh (in boolean aBlocking)
 Refresh the remote datasource, re-loading its contents from the URI.
void Flush ()
 Request that a data source write it's contents out to permanent storage, if applicable.
void FlushTo (in string aURI)
void startSearch (in AString searchString, in AString searchParam, in nsIAutoCompleteResult previousResult, in nsIAutoCompleteObserver listener)
void stopSearch ()

Public Attributes

readonly attribute AUTF8String lastPageVisited
 lastPageVisited The last page that was visited in a top-level window.
readonly attribute PRUint32 count
 count The number of entries in global history
readonly attribute unsigned long count
 count The number of entries in global history
readonly attribute string URI
 The "URI" of the data source.
readonly attribute boolean loaded
 This value is true when the datasource has fully loaded itself.

Protected Types

enum  eCommitType {
  kLargeCommit = 0, kSessionCommit = 1, kCompressCommit = 2, kLargeCommit = 0,
  kSessionCommit = 1, kCompressCommit = 2
}
enum  eCommitType {
  kLargeCommit = 0, kSessionCommit = 1, kCompressCommit = 2, kLargeCommit = 0,
  kSessionCommit = 1, kCompressCommit = 2
}

Protected Member Functions

nsresult OpenDB ()
nsresult OpenExistingFile (nsIMdbFactory *factory, const char *filePath)
nsresult OpenNewFile (nsIMdbFactory *factory, const char *filePath)
nsresult CreateTokens ()
nsresult CloseDB ()
nsresult CheckHostnameEntries ()
nsresult Commit (eCommitType commitType)
nsresult ExpireEntries (PRBool notify)
nsresult RemoveMatchingRows (rowMatchCallback aMatchFunc, void *aClosure, PRBool notify)
nsresult GetRootDayQueries (nsISimpleEnumerator **aResult, PRBool aBySite)
nsresult GetFindUriName (const char *aURL, nsIRDFNode **aResult)
nsresult CreateFindEnumerator (nsIRDFResource *aSource, nsISimpleEnumerator **aResult)
void GetFindUriPrefix (const searchQuery &aQuery, const PRBool aDoGroupBy, nsACString &aResult)
nsresult TokenListToSearchQuery (const nsVoidArray &tokens, searchQuery &aResult)
nsresult FindUrlToSearchQuery (const char *aURL, searchQuery &aResult)
nsresult NotifyFindAssertions (nsIRDFResource *aSource, nsIMdbRow *aRow)
nsresult NotifyFindUnassertions (nsIRDFResource *aSource, nsIMdbRow *aRow)
nsresult AutoCompleteTypedSearch (nsIAutoCompleteMdbResult2 **aResult)
nsresult AutoCompleteSearch (const nsAString &aSearchString, AutocompleteExclude *aExclude, nsIAutoCompleteMdbResult2 *aPrevResult, nsIAutoCompleteMdbResult2 **aResult)
void AutoCompleteCutPrefix (nsAString &aURL, AutocompleteExclude *aExclude)
void AutoCompleteGetExcludeInfo (const nsAString &aURL, AutocompleteExclude *aExclude)
nsString AutoCompletePrefilter (const nsAString &aSearchString)
PRBool AutoCompleteCompare (nsAString &aHistoryURL, const nsAString &aUserURL, AutocompleteExclude *aExclude)
 AutoCompleteSortComparison (nsIMdbRow *row1, nsIMdbRow *row2, void *closureVoid)
PRTime GetNow ()
void ExpireNow ()
void Sync ()
nsresult SetDirty ()
PRBool IsURLInHistory (nsIRDFResource *aResource)
nsresult NotifyAssert (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aValue)
nsresult NotifyUnassert (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aValue)
nsresult NotifyChange (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aOldValue, nsIRDFNode *aNewValue)
nsresult AddPageToDatabase (nsIURI *aURI, PRBool aRedirect, PRBool aTopLevel, PRTime aLastVisitDate, nsIURI *aReferrer)
nsresult AddExistingPageToDatabase (nsIMdbRow *row, PRTime aDate, nsIURI *aReferrer, PRTime *aOldDate, PRInt32 *aOldCount)
nsresult AddNewPageToDatabase (nsIURI *aURI, PRTime aDate, PRBool aRedirect, PRBool aTopLevel, nsIURI *aReferrer, nsIMdbRow **aResult)
nsresult RemovePageInternal (const char *aSpec)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRTime &aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRInt32 aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const char *aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRUnichar *aValue)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, nsAString &aResult)
nsresult SaveByteOrder (const char *aByteOrder)
nsresult GetByteOrder (char **_retval)
nsresult InitByteOrder (PRBool aForce)
void SwapBytes (const PRUnichar *source, PRUnichar *dest, PRInt32 aLen)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, nsACString &aResult)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, PRTime *aResult)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, PRInt32 *aResult)
nsresult FindRow (mdb_column aCol, const char *aURL, nsIMdbRow **aResult)
nsresult OpenDB ()
nsresult OpenExistingFile (nsIMdbFactory *factory, const char *filePath)
nsresult OpenNewFile (nsIMdbFactory *factory, const char *filePath)
nsresult CreateTokens ()
nsresult CloseDB ()
nsresult CheckHostnameEntries ()
nsresult Commit (eCommitType commitType)
nsresult ExpireEntries (PRBool notify)
nsresult RemoveMatchingRows (rowMatchCallback aMatchFunc, void *aClosure, PRBool notify)
nsresult GetRootDayQueries (nsISimpleEnumerator **aResult)
nsresult GetFindUriName (const char *aURL, nsIRDFNode **aResult)
nsresult CreateFindEnumerator (nsIRDFResource *aSource, nsISimpleEnumerator **aResult)
void GetFindUriPrefix (const searchQuery &aQuery, const PRBool aDoGroupBy, nsACString &aResult)
nsresult TokenListToSearchQuery (const nsVoidArray &tokens, searchQuery &aResult)
nsresult FindUrlToSearchQuery (const char *aURL, searchQuery &aResult)
nsresult NotifyFindAssertions (nsIRDFResource *aSource, nsIMdbRow *aRow)
nsresult NotifyFindUnassertions (nsIRDFResource *aSource, nsIMdbRow *aRow)
nsresult AutoCompleteSearch (const nsAString &aSearchString, AutocompleteExclude *aExclude, nsIAutoCompleteResults *aPrevResults, nsIAutoCompleteResults *aResults)
void AutoCompleteCutPrefix (nsAString &aURL, AutocompleteExclude *aExclude)
void AutoCompleteGetExcludeInfo (const nsAString &aURL, AutocompleteExclude *aExclude)
nsString AutoCompletePrefilter (const nsAString &aSearchString)
PRBool AutoCompleteCompare (nsAString &aHistoryURL, const nsAString &aUserURL, AutocompleteExclude *aExclude)
 AutoCompleteSortComparison (const void *v1, const void *v2, void *unused)
void ExpireNow ()
void Sync ()
nsresult SetDirty ()
PRBool IsURLInHistory (nsIRDFResource *aResource)
nsresult NotifyAssert (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aValue)
nsresult NotifyUnassert (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aValue)
nsresult NotifyChange (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aOldValue, nsIRDFNode *aNewValue)
nsresult AddExistingPageToDatabase (nsIMdbRow *row, PRTime aDate, const char *aReferrer, PRTime *aOldDate, PRInt32 *aOldCount)
nsresult AddNewPageToDatabase (const char *aURL, PRTime aDate, const char *aReferrer, nsIMdbRow **aResult)
nsresult RemovePageInternal (const char *aSpec)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRTime &aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRInt32 aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const char *aValue)
nsresult SetRowValue (nsIMdbRow *aRow, mdb_column aCol, const PRUnichar *aValue)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, nsAString &aResult)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, nsACString &aResult)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, PRTime *aResult)
nsresult GetRowValue (nsIMdbRow *aRow, mdb_column aCol, PRInt32 *aResult)
nsresult FindRow (mdb_column aCol, const char *aURL, nsIMdbRow **aResult)
nsresult SaveByteOrder (const char *aByteOrder)
nsresult GetByteOrder (char **_retval)
nsresult InitByteOrder (PRBool aForce)
void SwapBytes (const PRUnichar *source, PRUnichar *dest, PRInt32 aLen)

Static Protected Member Functions

static nsresult FindUrlToTokenList (const char *aURL, nsVoidArray &aResult)
static void FreeTokenList (nsVoidArray &tokens)
static void FreeSearchQuery (searchQuery &aQuery)
static PRBool IsFindResource (nsIRDFResource *aResource)
static void expireNowTimer (nsITimer *aTimer, void *aClosure)
static void fireSyncTimer (nsITimer *aTimer, void *aClosure)
static nsresult FindUrlToTokenList (const char *aURL, nsVoidArray &aResult)
static void FreeTokenList (nsVoidArray &tokens)
static void FreeSearchQuery (searchQuery &aQuery)
static PRBool IsFindResource (nsIRDFResource *aResource)
static void expireNowTimer (nsITimer *aTimer, void *aClosure)
static void fireSyncTimer (nsITimer *aTimer, void *aClosure)

Protected Attributes

PRInt64 mFileSizeOnDisk
PRInt32 mExpireDays
PRBool mAutocompleteOnlyTyped
nsStringArray mIgnoreSchemes
nsStringArray mIgnoreHostnames
PRTime mLastNow
PRInt32 mBatchesInProgress
PRBool mNowValid
nsCOMPtr< nsITimermExpireNowTimer
PRBool mDirty
nsCOMPtr< nsITimermSyncTimer
nsCOMPtr< nsISupportsArraymObservers
nsIMdbEnvmEnv
nsIMdbStoremStore
nsIMdbTablemTable
nsCOMPtr< nsIMdbRowmMetaRow
mdb_scope kToken_HistoryRowScope
mdb_kind kToken_HistoryKind
mdb_column kToken_URLColumn
mdb_column kToken_ReferrerColumn
mdb_column kToken_LastVisitDateColumn
mdb_column kToken_FirstVisitDateColumn
mdb_column kToken_VisitCountColumn
mdb_column kToken_NameColumn
mdb_column kToken_HostnameColumn
mdb_column kToken_HiddenColumn
mdb_column kToken_TypedColumn
mdb_column kToken_ByteOrder
mdb_column kToken_LastPageVisited
nsCStringHashSet mTypedHiddenURIs
PRBool mReverseByteOrder
nsCOMPtr< nsIStringBundlemBundle
PRInt64 mCachedGMTOffset

Static Protected Attributes

static PRInt32 gRefCnt
static nsIRDFServicegRDFService
static nsIRDFResourcekNC_Page
static nsIRDFResourcekNC_Date
static nsIRDFResourcekNC_FirstVisitDate
static nsIRDFResourcekNC_VisitCount
static nsIRDFResourcekNC_AgeInDays
static nsIRDFResourcekNC_Name
static nsIRDFResourcekNC_NameSort
static nsIRDFResourcekNC_Hostname
static nsIRDFResourcekNC_Referrer
static nsIRDFResourcekNC_child
static nsIRDFResourcekNC_URL
static nsIRDFResourcekNC_HistoryRoot
static nsIRDFResourcekNC_HistoryByDate
static nsIRDFResourcekNC_HistoryByDateAndSite
static nsIRDFResourcekNC_DayFolderIndex
static nsIMdbFactorygMdbFactory = nsnull
static nsIPrefBranchgPrefBranch = nsnull

Friends

class URLEnumerator
class SearchEnumerator
class AutoCompleteEnumerator

Detailed Description

Definition at line 130 of file nsGlobalHistory.h.


Class Documentation

struct nsGlobalHistory::AutoCompleteSortClosure

Definition at line 232 of file nsGlobalHistory.h.

Collaboration diagram for nsGlobalHistory::AutoCompleteSortClosure:
Class Members
nsGlobalHistory * history
size_t prefixCount
const nsAFlatString * prefixes

Member Enumeration Documentation

enum nsGlobalHistory::eCommitType [protected]
Enumerator:
kLargeCommit 
kSessionCommit 
kCompressCommit 
kLargeCommit 
kSessionCommit 
kCompressCommit 

Definition at line 163 of file nsGlobalHistory.h.

enum nsGlobalHistory::eCommitType [protected]
Enumerator:
kLargeCommit 
kSessionCommit 
kCompressCommit 
kLargeCommit 
kSessionCommit 
kCompressCommit 

Definition at line 164 of file nsGlobalHistory.h.


Constructor & Destructor Documentation

Definition at line 473 of file nsGlobalHistory.cpp.

  : mExpireDays(9), // make default be nine days
    mAutocompleteOnlyTyped(PR_FALSE),
    mBatchesInProgress(0),
    mNowValid(PR_FALSE),
    mDirty(PR_FALSE),
    mEnv(nsnull),
    mStore(nsnull),
    mTable(nsnull)
{
  LL_I2L(mFileSizeOnDisk, 0);
  
  // commonly used prefixes that should be chopped off all 
  // history and input urls before comparison

  mIgnoreSchemes.AppendString(NS_LITERAL_STRING("http://"));
  mIgnoreSchemes.AppendString(NS_LITERAL_STRING("https://"));
  mIgnoreSchemes.AppendString(NS_LITERAL_STRING("ftp://"));
  mIgnoreHostnames.AppendString(NS_LITERAL_STRING("www."));
  mIgnoreHostnames.AppendString(NS_LITERAL_STRING("ftp."));
  
  mTypedHiddenURIs.Init(3);
}
virtual nsGlobalHistory::~nsGlobalHistory ( ) [virtual]

Member Function Documentation

nsresult nsGlobalHistory::AddExistingPageToDatabase ( nsIMdbRow row,
PRTime  aDate,
const char *  aReferrer,
PRTime aOldDate,
PRInt32 aOldCount 
) [protected]

Definition at line 719 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  nsCAutoString oldReferrer;
  
  // Update last visit date.
  // First get the old date so we can update observers...
  rv = GetRowValue(row, kToken_LastVisitDateColumn, aOldDate);
  if (NS_FAILED(rv)) return rv;

  // get the old count, so we can update it
  rv = GetRowValue(row, kToken_VisitCountColumn, aOldCount);
  if (NS_FAILED(rv) || *aOldCount < 1)
    *aOldCount = 1;             // assume we've visited at least once

  // ...now set the new date.
  SetRowValue(row, kToken_LastVisitDateColumn, aDate);
  SetRowValue(row, kToken_VisitCountColumn, (*aOldCount) + 1);

  if (aReferrer && *aReferrer) {
    rv = GetRowValue(row, kToken_ReferrerColumn, oldReferrer);
    // No referrer? Now there is!
    if (NS_FAILED(rv) || oldReferrer.IsEmpty())
      SetRowValue(row, kToken_ReferrerColumn, aReferrer);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::AddExistingPageToDatabase ( nsIMdbRow row,
PRTime  aDate,
nsIURI aReferrer,
PRTime aOldDate,
PRInt32 aOldCount 
) [protected]

Definition at line 687 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  nsCAutoString oldReferrer;
  
  nsCAutoString URISpec;
  rv = GetRowValue(row, kToken_URLColumn, URISpec);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString referrerSpec;
  if (aReferrer) {
    rv = aReferrer->GetSpec(referrerSpec);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  // if the page was typed, unhide it now because it's
  // known to be valid
  if (HasCell(mEnv, row, kToken_TypedColumn)) {
    mTypedHiddenURIs.Remove(URISpec);
    row->CutColumn(mEnv, kToken_HiddenColumn);
  }

  // Update last visit date.
  // First get the old date so we can update observers...
  rv = GetRowValue(row, kToken_LastVisitDateColumn, aOldDate);
  if (NS_FAILED(rv)) return rv;

  // get the old count, so we can update it
  rv = GetRowValue(row, kToken_VisitCountColumn, aOldCount);
  if (NS_FAILED(rv) || *aOldCount < 1)
    *aOldCount = 1;             // assume we've visited at least once

  // ...now set the new date.
  SetRowValue(row, kToken_LastVisitDateColumn, aDate);
  SetRowValue(row, kToken_VisitCountColumn, (*aOldCount) + 1);

  if (aReferrer) {
    rv = GetRowValue(row, kToken_ReferrerColumn, oldReferrer);
    // No referrer? Now there is!
    if ((NS_FAILED(rv) || oldReferrer.IsEmpty()))
       SetRowValue(row, kToken_ReferrerColumn, referrerSpec.get());
  }

  // Notify observers
  nsCOMPtr<nsIRDFResource> url;
  rv = gRDFService->GetResource(URISpec, getter_AddRefs(url));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIRDFDate> date;
  rv = gRDFService->GetDateLiteral(aDate, getter_AddRefs(date));
  NS_ENSURE_SUCCESS(rv, rv);

  // visit date
  nsCOMPtr<nsIRDFDate> oldDateLiteral;
  rv = gRDFService->GetDateLiteral(*aOldDate, getter_AddRefs(oldDateLiteral));
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = NotifyChange(url, kNC_Date, oldDateLiteral, date);
  NS_ENSURE_SUCCESS(rv, rv);

  // visit count
  nsCOMPtr<nsIRDFInt> oldCountLiteral;
  rv = gRDFService->GetIntLiteral(*aOldCount, getter_AddRefs(oldCountLiteral));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIRDFInt> newCountLiteral;
  rv = gRDFService->GetIntLiteral(*aOldCount+1,
                                  getter_AddRefs(newCountLiteral));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = NotifyChange(url, kNC_VisitCount, oldCountLiteral, newCountLiteral);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::AddNewPageToDatabase ( const char *  aURL,
PRTime  aDate,
const char *  aReferrer,
nsIMdbRow **  aResult 
) [protected]

Definition at line 753 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  // Create a new row
  mdbOid rowId;
  rowId.mOid_Scope = kToken_HistoryRowScope;
  rowId.mOid_Id    = mdb_id(-1);
  
  NS_PRECONDITION(mTable != nsnull, "not initialized");
  if (! mTable)
    return NS_ERROR_NOT_INITIALIZED;

  nsCOMPtr<nsIMdbRow> row;
  err = mTable->NewRow(mEnv, &rowId, getter_AddRefs(row));
  if (err != 0) return NS_ERROR_FAILURE;

  // Set the URL
  SetRowValue(row, kToken_URLColumn, aURL);
  
  // Set the date.
  SetRowValue(row, kToken_LastVisitDateColumn, aDate);
  SetRowValue(row, kToken_FirstVisitDateColumn, aDate);

  // Set the referrer if there is one.
  if (aReferrer && *aReferrer)
    SetRowValue(row, kToken_ReferrerColumn, aReferrer);

  nsCOMPtr<nsIURI> uri;
  NS_NewURI(getter_AddRefs(uri), nsDependentCString(aURL), nsnull, nsnull);
  nsCAutoString hostname;
  if (uri)
      uri->GetHost(hostname);

  SetRowValue(row, kToken_HostnameColumn, hostname.get());

  *aResult = row;
  NS_ADDREF(*aResult);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::AddNewPageToDatabase ( nsIURI aURI,
PRTime  aDate,
PRBool  aRedirect,
PRBool  aTopLevel,
nsIURI aReferrer,
nsIMdbRow **  aResult 
) [protected]

Definition at line 768 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  NS_ENSURE_SUCCESS(OpenDB(), NS_ERROR_NOT_INITIALIZED);

  nsCAutoString URISpec;
  nsresult rv = aURI->GetSpec(URISpec);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString referrerSpec;
  if (aReferrer) {
    rv = aReferrer->GetSpec(referrerSpec);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  // Create a new row
  mdbOid rowId;
  rowId.mOid_Scope = kToken_HistoryRowScope;
  rowId.mOid_Id    = mdb_id(-1);
  
  NS_PRECONDITION(mTable != nsnull, "not initialized");
  if (! mTable)
    return NS_ERROR_NOT_INITIALIZED;

  nsCOMPtr<nsIMdbRow> row;
  err = mTable->NewRow(mEnv, &rowId, getter_AddRefs(row));
  if (err != 0) return NS_ERROR_FAILURE;

  // Set the URL
  SetRowValue(row, kToken_URLColumn, URISpec.get());
  
  // Set the date.
  SetRowValue(row, kToken_LastVisitDateColumn, aDate);
  SetRowValue(row, kToken_FirstVisitDateColumn, aDate);

  // Set the referrer if there is one.
  if (aReferrer)
    SetRowValue(row, kToken_ReferrerColumn, referrerSpec.get());

  nsCOMPtr<nsIURI> uri;
  NS_NewURI(getter_AddRefs(uri), URISpec, nsnull, nsnull);
  nsCAutoString hostname;
  if (uri)
      uri->GetHost(hostname);

  // Strip www.
  if (Substring(hostname, 0, 4).EqualsLiteral("www."))
    hostname.Cut(0, 4);

  SetRowValue(row, kToken_HostnameColumn, hostname.get());

  *aResult = row;
  NS_ADDREF(*aResult);

  PRBool isJavascript;
  rv = aURI->SchemeIs("javascript", &isJavascript);
  NS_ENSURE_SUCCESS(rv, rv);

  if (isJavascript || aRedirect || !aTopLevel) {
    // if this is a JS url, or a redirected URI or in a frame, hide it in
    // global history so that it doesn't show up in the autocomplete
    // dropdown. AddExistingPageToDatabase has logic to override this
    // behavior for URIs which were typed. See bug 197127 and bug 161531
    // for details.
    rv = SetRowValue(row, kToken_HiddenColumn, 1);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  else {
    // Notify observers
    nsCOMPtr<nsIRDFResource> url;
    rv = gRDFService->GetResource(URISpec, getter_AddRefs(url));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIRDFDate> date;
    rv = gRDFService->GetDateLiteral(aDate, getter_AddRefs(date));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = NotifyAssert(url, kNC_Date, date);
    if (NS_FAILED(rv)) return rv;

    rv = NotifyAssert(kNC_HistoryRoot, kNC_child, url);
    if (NS_FAILED(rv)) return rv;
  
    NotifyFindAssertions(url, row);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Add an observer to this data source.

If the datasource supports observers, the datasource source should hold a strong reference to the observer.

Here is the caller graph for this function:

nsresult nsGlobalHistory::AddPageToDatabase ( nsIURI aURI,
PRBool  aRedirect,
PRBool  aTopLevel,
PRTime  aLastVisitDate,
nsIURI aReferrer 
) [protected]

Definition at line 572 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG_POINTER(aURI);

  // If history is set to expire after 0 days,
  // then it's technically disabled. Don't even
  // bother adding the page
  if (mExpireDays == 0) {
    NS_WARNING("mExpireDays == 0");
    return NS_OK;
  }

  // filter out unwanted URIs such as chrome: mailbox: etc
  // The model is really if we don't know differently then add which basically
  // means we are suppose to try all the things we know not to allow in and
  // then if we don't bail go on and allow it in.  But here lets compare
  // against the most common case we know to allow in and go on and say yes
  // to it.

  PRBool isHTTP = PR_FALSE;
  PRBool isHTTPS = PR_FALSE;

  NS_ENSURE_SUCCESS(rv = aURI->SchemeIs("http", &isHTTP), rv);
  NS_ENSURE_SUCCESS(rv = aURI->SchemeIs("https", &isHTTPS), rv);

  if (!isHTTP && !isHTTPS) {
    PRBool isAbout, isImap, isNews, isMailbox, isViewSource, isChrome, isData;

    rv = aURI->SchemeIs("about", &isAbout);
    rv |= aURI->SchemeIs("imap", &isImap);
    rv |= aURI->SchemeIs("news", &isNews);
    rv |= aURI->SchemeIs("mailbox", &isMailbox);
    rv |= aURI->SchemeIs("view-source", &isViewSource);
    rv |= aURI->SchemeIs("chrome", &isChrome);
    rv |= aURI->SchemeIs("data", &isData);
    NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

    if (isAbout || isImap || isNews || isMailbox || isViewSource || isChrome || isData) {
#ifdef DEBUG_bsmedberg
      printf("Filtering out unwanted scheme.\n");
#endif
      return NS_OK;
    }
  }

  rv = OpenDB();
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString URISpec;
  rv = aURI->GetSpec(URISpec);
  NS_ENSURE_SUCCESS(rv, rv);

  if (URISpec.Length() > HISTORY_URI_LENGTH_MAX)
     return NS_OK;

#ifdef DEBUG_bsmedberg
  printf("AddURI: %s%s%s",
         URISpec.get(),
         aRedirect ? ", redirect" : "",
         aTopLevel ? ", toplevel" : "");
#endif

  nsCOMPtr<nsIMdbRow> row;
  rv = FindRow(kToken_URLColumn, URISpec.get(), getter_AddRefs(row));

  if (NS_SUCCEEDED(rv)) {
    // update the database, and get the old info back
    PRTime oldDate;
    PRInt32 oldCount;
    rv = AddExistingPageToDatabase(row, aLastVisitDate, aReferrer, &oldDate, &oldCount);
    NS_ASSERTION(NS_SUCCEEDED(rv), "AddExistingPageToDatabase failed; see bug 88961");
    if (NS_FAILED(rv)) return rv;
    
#ifdef DEBUG_bsmedberg
    printf("Existing page succeeded.\n");
#endif
  }
  else {
    rv = AddNewPageToDatabase(aURI, aLastVisitDate, aRedirect, 
                              aTopLevel, aReferrer, getter_AddRefs(row));
    NS_ASSERTION(NS_SUCCEEDED(rv), "AddNewPageToDatabase failed; see bug 88961");
    if (NS_FAILED(rv)) return rv;

#ifdef DEBUG_bsmedberg
    printf("New page succeeded.\n");
#endif
  }

  // Store last visited page if we have the pref set accordingly
  if (aTopLevel) {
    PRInt32 choice = 0;
    if (NS_SUCCEEDED(gPrefBranch->GetIntPref("startup.page", &choice))) {
      if (choice != 2) {
        if (NS_SUCCEEDED(gPrefBranch->GetIntPref("windows.loadOnNewWindow", &choice))) {
          if (choice != 2) {
            gPrefBranch->GetIntPref("tabs.loadOnNewTab", &choice);
          }
        }
      }
    }
    if (choice == 2) {
      NS_ENSURE_STATE(mMetaRow);

      SetRowValue(mMetaRow, kToken_LastPageVisited, URISpec.get());
    }
  }
 
  SetDirty();
  
  return NS_OK;
}

Here is the call graph for this function:

void nsIBrowserHistory::addPageWithDetails ( in nsIURI  aURI,
in wstring  aTitle,
in long long  aLastVisited 
) [inherited]

addPageWithDetails Adds a page to history with specific time stamp information.

This is used in the History migrator.

void nsIGlobalHistory2::addURI ( in nsIURI  aURI,
in boolean  aRedirect,
in boolean  aToplevel,
in nsIURI  aReferrer 
) [inherited]

Add a URI to global history.

Parameters:
aURIthe URI of the page
aRedirectwhether the URI was redirected to another location; this is 'true' for the original URI which is redirected.
aToplevelwhether the URI is loaded in a top-level window
aReferrerthe URI of the referring page
Note:
Docshell will not filter out URI schemes like chrome: data: about: and view-source:. Embedders should consider filtering out these schemes and others, e.g. mailbox: for the main URI and the referrer.

Get a cursor to iterate over all the arcs that point into a node.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

Get a cursor to iterate over all the arcs that originate in a resource.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

void nsIRDFDataSource::Assert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Add an assertion to the graph.

Here is the caller graph for this function:

PRBool nsGlobalHistory::AutoCompleteCompare ( nsAString &  aHistoryURL,
const nsAString &  aUserURL,
AutocompleteExclude aExclude 
) [protected]

Definition at line 4502 of file nsGlobalHistory.cpp.

{
  AutoCompleteCutPrefix(aHistoryURL, aExclude);
  
  return Substring(aHistoryURL, 0, aUserURL.Length()).Equals(aUserURL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsGlobalHistory::AutoCompleteCompare ( nsAString &  aHistoryURL,
const nsAString &  aUserURL,
AutocompleteExclude aExclude 
) [protected]
void nsGlobalHistory::AutoCompleteCutPrefix ( nsAString &  aURL,
AutocompleteExclude aExclude 
) [protected]
void nsGlobalHistory::AutoCompleteCutPrefix ( nsAString &  aURL,
AutocompleteExclude aExclude 
) [protected]

Definition at line 4445 of file nsGlobalHistory.cpp.

{
  // This comparison is case-sensitive.  Therefore, it assumes that aUserURL is a 
  // potential URL whose host name is in all lower case.
  PRInt32 idx = 0;
  PRInt32 i;
  for (i = 0; i < mIgnoreSchemes.Count(); ++i) {
    if (aExclude && i == aExclude->schemePrefix)
      continue;
    nsString* string = mIgnoreSchemes.StringAt(i);    
    if (Substring(aURL, 0, string->Length()).Equals(*string)) {
      idx = string->Length();
      break;
    }
  }

  if (idx > 0)
    aURL.Cut(0, idx);

  idx = 0;
  for (i = 0; i < mIgnoreHostnames.Count(); ++i) {
    if (aExclude && i == aExclude->hostnamePrefix)
      continue;
    nsString* string = mIgnoreHostnames.StringAt(i);    
    if (Substring(aURL, 0, string->Length()).Equals(*string)) {
      idx = string->Length();
      break;
    }
  }

  if (idx > 0)
    aURL.Cut(0, idx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsGlobalHistory::AutoCompleteGetExcludeInfo ( const nsAString &  aURL,
AutocompleteExclude aExclude 
) [protected]
void nsGlobalHistory::AutoCompleteGetExcludeInfo ( const nsAString &  aURL,
AutocompleteExclude aExclude 
) [protected]

Definition at line 4417 of file nsGlobalHistory.cpp.

{
  aExclude->schemePrefix = -1;
  aExclude->hostnamePrefix = -1;
  
  PRInt32 index = 0;
  PRInt32 i;
  for (i = 0; i < mIgnoreSchemes.Count(); ++i) {
    nsString* string = mIgnoreSchemes.StringAt(i);    
    if (Substring(aURL, 0, string->Length()).Equals(*string)) {
      aExclude->schemePrefix = i;
      index = string->Length();
      break;
    }
  }
  
  for (i = 0; i < mIgnoreHostnames.Count(); ++i) {
    nsString* string = mIgnoreHostnames.StringAt(i);    
    if (Substring(aURL, index, string->Length()).Equals(*string)) {
      aExclude->hostnamePrefix = i;
      break;
    }
  }
}

Here is the call graph for this function:

nsString nsGlobalHistory::AutoCompletePrefilter ( const nsAString &  aSearchString) [protected]
nsString nsGlobalHistory::AutoCompletePrefilter ( const nsAString &  aSearchString) [protected]

Definition at line 4480 of file nsGlobalHistory.cpp.

{
  nsAutoString url(aSearchString);

  PRInt32 slash = url.FindChar('/', 0);
  if (slash >= 0) {
    // if user is typing a url but has already typed past the host,
    // then convert the host to lowercase
    nsAutoString host;
    url.Left(host, slash);
    ToLowerCase(host);
    url.Assign(host + Substring(url, slash, url.Length()-slash));
  } else {
    // otherwise, assume the user could still be typing the host, and
    // convert everything to lowercase
    ToLowerCase(url);
  }
  
  return nsString(url);
}

Here is the call graph for this function:

nsresult nsGlobalHistory::AutoCompleteSearch ( const nsAString &  aSearchString,
AutocompleteExclude aExclude,
nsIAutoCompleteResults aPrevResults,
nsIAutoCompleteResults aResults 
) [protected]

Definition at line 4195 of file nsGlobalHistory.cpp.

{
  // determine if we can skip searching the whole history and only search
  // through the previous search results
  PRBool searchPrevious = PR_FALSE;
  if (aPrevResults) {
    nsXPIDLString prevURL;
    aPrevResults->GetSearchString(getter_Copies(prevURL));
    // if search string begins with the previous search string, it's a go
    searchPrevious = StringBeginsWith(aSearchString, prevURL);
  }
    
  nsCOMPtr<nsISupportsArray> resultItems;
  nsresult rv = aResults->GetItems(getter_AddRefs(resultItems));

  if (searchPrevious) {
    // searching through the previous results...
    
    nsCOMPtr<nsISupportsArray> prevResultItems;
    aPrevResults->GetItems(getter_AddRefs(prevResultItems));
    
    PRUint32 count;
    prevResultItems->Count(&count);
    for (PRUint32 i = 0; i < count; ++i) {
      nsCOMPtr<nsIAutoCompleteItem> item;
      prevResultItems->GetElementAt(i, getter_AddRefs(item));

      // make a copy of the value because AutoCompleteCompare
      // is destructive
      nsAutoString url;
      item->GetValue(url);
      
      if (AutoCompleteCompare(url, aSearchString, aExclude))
        resultItems->AppendElement(item);
    }    
  } else {
    // searching through the entire history...
        
    // prepare the search enumerator
    AutoCompleteEnumerator* enumerator;
    enumerator = new AutoCompleteEnumerator(this, kToken_URLColumn, 
                                            kToken_NameColumn,
                                            kToken_HiddenColumn,
                                            kToken_TypedColumn,
                                            mAutocompleteOnlyTyped,
                                            aSearchString, aExclude);
    
    nsCOMPtr<nsISupports> kungFuDeathGrip(enumerator);

    rv = enumerator->Init(mEnv, mTable);
    if (NS_FAILED(rv)) return rv;
  
    // store hits in an auto array initially
    nsAutoVoidArray array;
      
    // not using nsCOMPtr here to avoid time spent
    // refcounting while passing these around between the 3 arrays
    nsISupports* entry; 

    // step through the enumerator to get the items into 'array'
    // because we don't know how many items there will be
    PRBool hasMore;
    while (PR_TRUE) {
      enumerator->HasMoreElements(&hasMore);
      if (!hasMore) break;
      
      // addref's each entry as it enters 'array'
      enumerator->GetNext(&entry);
      array.AppendElement(entry);
    }

    // turn auto array into flat array for quick sort, now that we
    // know how many items there are
    PRUint32 count = array.Count();
    nsIAutoCompleteItem** items = new nsIAutoCompleteItem*[count];
    PRUint32 i;
    for (i = 0; i < count; ++i)
      items[i] = (nsIAutoCompleteItem*)array.ElementAt(i);
    
    // Setup the structure we pass into the sort function,
    // including a set of url prefixes to ignore.   These prefixes 
    // must match with the logic in nsGlobalHistory::nsGlobalHistory().
    NS_NAMED_LITERAL_STRING(prefixHWStr, "http://www.");
    NS_NAMED_LITERAL_STRING(prefixHStr, "http://");
    NS_NAMED_LITERAL_STRING(prefixHSWStr, "https://www.");
    NS_NAMED_LITERAL_STRING(prefixHSStr, "https://");
    NS_NAMED_LITERAL_STRING(prefixFFStr, "ftp://ftp.");
    NS_NAMED_LITERAL_STRING(prefixFStr, "ftp://");

    // note: the number of prefixes stored in the closure below 
    // must match with the constant AUTOCOMPLETE_PREFIX_LIST_COUNT
    AutoCompleteSortClosure closure;
    closure.history = this;
    closure.prefixCount = AUTOCOMPLETE_PREFIX_LIST_COUNT;
    closure.prefixes[0] = &prefixHWStr;
    closure.prefixes[1] = &prefixHStr;
    closure.prefixes[2] = &prefixHSWStr;
    closure.prefixes[3] = &prefixHSStr;
    closure.prefixes[4] = &prefixFFStr;
    closure.prefixes[5] = &prefixFStr;

    // sort it
    NS_QuickSort(items, count, sizeof(nsIAutoCompleteItem*),
                 AutoCompleteSortComparison,
                 NS_STATIC_CAST(void*, &closure));
  
    // place the sorted array into the autocomplete results
    for (i = 0; i < count; ++i) {
      nsISupports* item = (nsISupports*)items[i];
      resultItems->AppendElement(item);
      NS_IF_RELEASE(item); // release manually since we didn't use nsCOMPtr above
    }
    
    delete[] items;
  }
    
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::AutoCompleteSearch ( const nsAString &  aSearchString,
AutocompleteExclude aExclude,
nsIAutoCompleteMdbResult2 aPrevResult,
nsIAutoCompleteMdbResult2 **  aResult 
) [protected]

Definition at line 4297 of file nsGlobalHistory.cpp.

{
  // determine if we can skip searching the whole history and only search
  // through the previous search results
  PRBool searchPrevious = PR_FALSE;
  if (aPrevResult) {
    nsAutoString prevURLStr;
    aPrevResult->GetSearchString(prevURLStr);
    // if search string begins with the previous search string, it's a go
    searchPrevious = Substring(aSearchString, 0, prevURLStr.Length()).Equals(prevURLStr);
  }
    
  if (searchPrevious) {
    // Search through the previous result
    PRUint32 matchCount;
    aPrevResult->GetMatchCount(&matchCount);
    for (PRInt32 i = matchCount-1; i >= 0; --i) {
      // Make a copy of the value because AutoCompleteCompare is destructive
      nsAutoString url;
      aPrevResult->GetValueAt(i, url);
      
      if (!AutoCompleteCompare(url, aSearchString, aExclude))
        aPrevResult->RemoveValueAt(i, PR_FALSE);
    }
    
    NS_ADDREF(*aResult = aPrevResult);
  } else {
    // Search through the entire history
        
    // Create and initialize a new result object
    nsresult rv = NS_OK;
    nsCOMPtr<nsIAutoCompleteMdbResult2> result = do_CreateInstance("@mozilla.org/autocomplete/mdb-result;1", &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    result->Init(mEnv, mTable);
    result->SetTokens(kToken_URLColumn, nsIAutoCompleteMdbResult2::kCharType, kToken_NameColumn, nsIAutoCompleteMdbResult2::kUnicharType);
    result->SetReverseByteOrder(mReverseByteOrder);
    result->SetSearchString(aSearchString);

    // Get a cursor to iterate through all rows in the database
    nsCOMPtr<nsIMdbTableRowCursor> rowCursor;
    mdb_err err = mTable->GetTableRowCursor(mEnv, -1, getter_AddRefs(rowCursor));
    NS_ENSURE_TRUE(!err, NS_ERROR_FAILURE);

    // Store hits in an nsIArray initially
    nsCOMArray<nsIMdbRow> resultArray;

    nsCOMPtr<nsIMdbRow> row;
    mdb_pos pos;
    do {
      rowCursor->NextRow(mEnv, getter_AddRefs(row), &pos);
      if (!row) break;
      
      if (!HasCell(mEnv, row, kToken_TypedColumn))
        if (mAutocompleteOnlyTyped || HasCell(mEnv, row, kToken_HiddenColumn))
          continue;

      nsCAutoString url;
      GetRowValue(row, kToken_URLColumn, url);

      NS_ConvertUTF8toUCS2 utf8Url(url);
      if (AutoCompleteCompare(utf8Url, aSearchString, aExclude))
        resultArray.AppendObject(row);
    } while (row);
    
    // Setup the structure we pass into the sort function,
    // including a set of url prefixes to ignore.   These prefixes 
    // must match with the logic in nsGlobalHistory::nsGlobalHistory().
    NS_NAMED_LITERAL_STRING(prefixHWStr, "http://www.");
    NS_NAMED_LITERAL_STRING(prefixHStr, "http://");
    NS_NAMED_LITERAL_STRING(prefixHSWStr, "https://www.");
    NS_NAMED_LITERAL_STRING(prefixHSStr, "https://");
    NS_NAMED_LITERAL_STRING(prefixFFStr, "ftp://ftp.");
    NS_NAMED_LITERAL_STRING(prefixFStr, "ftp://");

    // note: the number of prefixes stored in the closure below 
    // must match with the constant AUTOCOMPLETE_PREFIX_LIST_COUNT
    AutoCompleteSortClosure closure;
    closure.history = this;
    closure.prefixCount = AUTOCOMPLETE_PREFIX_LIST_COUNT;
    closure.prefixes[0] = &prefixHWStr;
    closure.prefixes[1] = &prefixHStr;
    closure.prefixes[2] = &prefixHSWStr;
    closure.prefixes[3] = &prefixHSStr;
    closure.prefixes[4] = &prefixFFStr;
    closure.prefixes[5] = &prefixFStr;

    // sort it
    resultArray.Sort(AutoCompleteSortComparison, NS_STATIC_CAST(void*, &closure));

    // place the sorted array into the autocomplete results
    PRUint32 count = resultArray.Count();
    PRUint32 i;
    for (i = 0; i < count; ++i) {
      result->AddRow(resultArray[i]);
    }

    // Determine the result of the search
    PRUint32 matchCount;
    rv = result->GetMatchCount(&matchCount);
    if (matchCount > 0) {
      result->SetSearchResult(nsIAutoCompleteResult::RESULT_SUCCESS);
      result->SetDefaultIndex(0);
    } else {
      result->SetSearchResult(nsIAutoCompleteResult::RESULT_NOMATCH);
      result->SetDefaultIndex(-1);
    }
    
    *aResult = result;
    NS_ADDREF(*aResult);
  }
    
  return NS_OK;
}

Here is the call graph for this function:

int PR_CALLBACK nsGlobalHistory::AutoCompleteSortComparison ( nsIMdbRow row1,
nsIMdbRow row2,
void closureVoid 
) [protected]

Definition at line 4512 of file nsGlobalHistory.cpp.

{
  //
  // NOTE: The design and reasoning behind the following autocomplete 
  // sort implementation is documented in bug 78270.
  //
  // cast our function parameters back into their real form
  AutoCompleteSortClosure* closure = 
      NS_STATIC_CAST(AutoCompleteSortClosure*, closureVoid);

  // get visit counts - we're ignoring all errors from GetRowValue(), 
  // and relying on default values
  PRInt32 item1visits = 0, item2visits = 0;
  closure->history->GetRowValue(row1, 
                                closure->history->kToken_VisitCountColumn, 
                                &item1visits);
  closure->history->GetRowValue(row2, 
                                closure->history->kToken_VisitCountColumn, 
                                &item2visits);

  // get URLs
  nsAutoString url1, url2;
  closure->history->GetRowValue(row1, closure->history->kToken_URLColumn, url1);
  closure->history->GetRowValue(row2, closure->history->kToken_URLColumn, url2);

  // Favour websites and webpaths more than webpages by boosting 
  // their visit counts.  This assumes that URLs have been normalized, 
  // appending a trailing '/'.
  // 
  // We use addition to boost the visit count rather than multiplication 
  // since we want URLs with large visit counts to remain pretty much 
  // in raw visit count order - we assume the user has visited these urls
  // often for a reason and there shouldn't be a problem with putting them 
  // high in the autocomplete list regardless of whether they are sites/
  // paths or pages.  However for URLs visited only a few times, sites 
  // & paths should be presented before pages since they are generally 
  // more likely to be visited again.
  //
  PRBool isPath1 = PR_FALSE, isPath2 = PR_FALSE;
  if (!url1.IsEmpty())
  {
    // url is a site/path if it has a trailing slash
    isPath1 = (url1.Last() == PRUnichar('/'));
    if (isPath1)
      item1visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  }
  if (!url2.IsEmpty())
  {
    // url is a site/path if it has a trailing slash
    isPath2 = (url2.Last() == PRUnichar('/'));
    if (isPath2)
      item2visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  }

  if (HasCell(closure->history->mEnv, row1, closure->history->kToken_TypedColumn))
    item1visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  if (HasCell(closure->history->mEnv, row2, closure->history->kToken_TypedColumn))
    item2visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  
  // primary sort by visit count
  if (item1visits != item2visits)
  {
    // return visit count comparison
    return item2visits - item1visits;
  }
  else
  {
    // Favour websites and webpaths more than webpages
    if (isPath1 && !isPath2) return -1; // url1 is a website/path, url2 isn't
    if (!isPath1 && isPath2) return  1; // url1 isn't a website/path, url2 is

    // We have two websites/paths.. ignore "http[s]://[www.]" & "ftp://[ftp.]"
    // prefixes.  Find a starting position in the string, just past any of the 
    // above prefixes.  Only check for the prefix once, in the far left of the 
    // string - it is assumed there is no whitespace.
    PRInt32 postPrefix1 = 0, postPrefix2 = 0;

    size_t i;
    // iterate through our prefixes looking for a match
    for (i=0; i<closure->prefixCount; i++)
    {
      // Check if string is prefixed.  Note: the parameters of the Find() 
      // method specify the url is searched at the 0th character and if there
      // is no match the rest of the url is not searched.
      if (url1.Find((*closure->prefixes[i]), 0, 1) == 0)
      {
        // found a match - record post prefix position
        postPrefix1 = closure->prefixes[i]->Length();
        // bail out of the for loop
        break;
      }
    }

    // iterate through our prefixes looking for a match
    for (i=0; i<closure->prefixCount; i++)
    {
      // Check if string is prefixed.  Note: the parameters of the Find() 
      // method specify the url is searched at the 0th character and if there
      // is no match the rest of the url is not searched.
      if (url2.Find((*closure->prefixes[i]), 0, 1) == 0)
      {
        // found a match - record post prefix position
        postPrefix2 = closure->prefixes[i]->Length();
        // bail out of the for loop
        break;
      }
    }

    // compare non-prefixed urls
    PRInt32 ret = Compare(
      Substring(url1, postPrefix1, url1.Length()),
      Substring(url2, postPrefix2, url2.Length()));
    if (ret != 0) return ret;

    // sort http://xyz.com before http://www.xyz.com
    return postPrefix1 - postPrefix2;
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PR_CALLBACK nsGlobalHistory::AutoCompleteSortComparison ( const void v1,
const void v2,
void unused 
) [protected]

Definition at line 4415 of file nsGlobalHistory.cpp.

{
  //
  // NOTE: The design and reasoning behind the following autocomplete 
  // sort implementation is documented in bug 78270.
  //

  // cast our function parameters back into their real form
  nsIAutoCompleteItem *item1 = *(nsIAutoCompleteItem**) v1;
  nsIAutoCompleteItem *item2 = *(nsIAutoCompleteItem**) v2;
  AutoCompleteSortClosure* closure = 
      NS_STATIC_CAST(AutoCompleteSortClosure*, closureVoid);

  // get history rows
  nsCOMPtr<nsIMdbRow> row1, row2;
  item1->GetParam(getter_AddRefs(row1));
  item2->GetParam(getter_AddRefs(row2));

  // get visit counts - we're ignoring all errors from GetRowValue(), 
  // and relying on default values
  PRInt32 item1visits = 0, item2visits = 0;
  closure->history->GetRowValue(row1, 
                                closure->history->kToken_VisitCountColumn, 
                                &item1visits);
  closure->history->GetRowValue(row2, 
                                closure->history->kToken_VisitCountColumn, 
                                &item2visits);

  // get URLs
  nsAutoString url1, url2;
  item1->GetValue(url1);
  item2->GetValue(url2);

  // Favour websites and webpaths more than webpages by boosting 
  // their visit counts.  This assumes that URLs have been normalized, 
  // appending a trailing '/'.
  // 
  // We use addition to boost the visit count rather than multiplication 
  // since we want URLs with large visit counts to remain pretty much 
  // in raw visit count order - we assume the user has visited these urls
  // often for a reason and there shouldn't be a problem with putting them 
  // high in the autocomplete list regardless of whether they are sites/
  // paths or pages.  However for URLs visited only a few times, sites 
  // & paths should be presented before pages since they are generally 
  // more likely to be visited again.
  //
  PRBool isPath1 = PR_FALSE, isPath2 = PR_FALSE;
  if (!url1.IsEmpty())
  {
    // url is a site/path if it has a trailing slash
    isPath1 = (url1.Last() == PRUnichar('/'));
    if (isPath1)
      item1visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  }
  if (!url2.IsEmpty())
  {
    // url is a site/path if it has a trailing slash
    isPath2 = (url2.Last() == PRUnichar('/'));
    if (isPath2)
      item2visits += AUTOCOMPLETE_NONPAGE_VISIT_COUNT_BOOST;
  }

  // primary sort by visit count
  if (item1visits != item2visits)
  {
    // return visit count comparison
    return item2visits - item1visits;
  }
  else
  {
    // Favour websites and webpaths more than webpages
    if (isPath1 && !isPath2) return -1; // url1 is a website/path, url2 isn't
    if (!isPath1 && isPath2) return  1; // url1 isn't a website/path, url2 is

    // We have two websites/paths.. ignore "http[s]://[www.]" & "ftp://[ftp.]"
    // prefixes.  Find a starting position in the string, just past any of the 
    // above prefixes.  Only check for the prefix once, in the far left of the 
    // string - it is assumed there is no whitespace.
    PRInt32 postPrefix1 = 0, postPrefix2 = 0;

    size_t i;
    // iterate through our prefixes looking for a match
    for (i=0; i<closure->prefixCount; i++)
    {
      // Check if string is prefixed.  Note: the parameters of the Find() 
      // method specify the url is searched at the 0th character and if there
      // is no match the rest of the url is not searched.
      if (url1.Find((*closure->prefixes[i]), 0, 1) == 0)
      {
        // found a match - record post prefix position
        postPrefix1 = closure->prefixes[i]->Length();
        // bail out of the for loop
        break;
      }
    }

    // iterate through our prefixes looking for a match
    for (i=0; i<closure->prefixCount; i++)
    {
      // Check if string is prefixed.  Note: the parameters of the Find() 
      // method specify the url is searched at the 0th character and if there
      // is no match the rest of the url is not searched.
      if (url2.Find((*closure->prefixes[i]), 0, 1) == 0)
      {
        // found a match - record post prefix position
        postPrefix2 = closure->prefixes[i]->Length();
        // bail out of the for loop
        break;
      }
    }

    // compare non-prefixed urls
    PRInt32 ret = Compare(
      Substring(url1, postPrefix1, url1.Length()),
      Substring(url2, postPrefix2, url2.Length()));
    if (ret != 0) return ret;

    // sort http://xyz.com before http://www.xyz.com
    return postPrefix1 - postPrefix2;
  }
}

Here is the call graph for this function:

Definition at line 4251 of file nsGlobalHistory.cpp.

{
  mdb_count count;
  mdb_err err = mTable->GetCount(mEnv, &count);

  // Get a cursor to iterate through all rows in the database
  nsCOMPtr<nsIMdbTableRowCursor> rowCursor;
   err = mTable->GetTableRowCursor(mEnv, count, getter_AddRefs(rowCursor));
  NS_ENSURE_TRUE(!err, NS_ERROR_FAILURE);

  nsresult rv;
  nsCOMPtr<nsIAutoCompleteMdbResult2> result = do_CreateInstance("@mozilla.org/autocomplete/mdb-result;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  result->Init(mEnv, mTable);
  result->SetTokens(kToken_URLColumn, nsIAutoCompleteMdbResult2::kCharType, kToken_NameColumn, nsIAutoCompleteMdbResult2::kUnicharType);
  result->SetReverseByteOrder(mReverseByteOrder);

  nsCOMPtr<nsIMdbRow> row;
  mdb_pos pos;
  do {
    rowCursor->PrevRow(mEnv, getter_AddRefs(row), &pos);
    if (!row) break;
    
    if (HasCell(mEnv, row, kToken_TypedColumn)) {
      result->AddRow(row);
    }
  } while (row);

  // Determine the result of the search
  PRUint32 matchCount;
  rv = result->GetMatchCount(&matchCount);
  if (matchCount > 0) {
    result->SetSearchResult(nsIAutoCompleteResult::RESULT_SUCCESS);
    result->SetDefaultIndex(0);
  } else {
    result->SetSearchResult(nsIAutoCompleteResult::RESULT_NOMATCH);
    result->SetDefaultIndex(-1);
  }

  *aResult = result;
  NS_ADDREF(*aResult);
  
  return NS_OK;
}

Here is the call graph for this function:

Notify observers that the datasource is about to send several notifications at once.

This must be followed by calling endUpdateBatch(), otherwise viewers will get out of sync.

void nsIRDFDataSource::Change ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aOldTarget,
in nsIRDFNode  aNewTarget 
) [inherited]

Change an assertion from.

[aSource]--[aProperty]-->[aOldTarget]

to

[aSource]--[aProperty]-->[aNewTarget]

Here is the caller graph for this function:

Definition at line 2853 of file nsGlobalHistory.cpp.

{
  nsresult rv = NS_OK;

  mdb_err err;

  nsCOMPtr<nsIMdbTableRowCursor> cursor;
  nsCOMPtr<nsIMdbRow> row;
 
  err = mTable->GetTableRowCursor(mEnv, -1, getter_AddRefs(cursor));
  if (err != 0) return NS_ERROR_FAILURE;

  int marker;
  err = mTable->StartBatchChangeHint(mEnv, &marker);
  NS_ASSERTION(err == 0, "unable to start batch");
  if (err != 0) return NS_ERROR_FAILURE;
  
  mdb_pos pos;
  err = cursor->NextRow(mEnv, getter_AddRefs(row), &pos);
  if (err != 0) return NS_ERROR_FAILURE;

  // comment out this code to rebuild the hostlist at startup
#if 1
  // bail early if the first row has a hostname
  if (row) {
    nsCAutoString hostname;
    rv = GetRowValue(row, kToken_HostnameColumn, hostname);
    if (NS_SUCCEEDED(rv) && !hostname.IsEmpty())
      return NS_OK;
  }
#endif
  
  // cached variables used in the loop
  nsCAutoString url;
  nsXPIDLCString hostname;

  nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID);
  if (!ioService) return NS_ERROR_FAILURE;
  

  while (row) {
#if 0
    rv = GetRowValue(row, kToken_URLColumn, url);
    if (NS_FAILED(rv)) break;

    ioService->ExtractUrlPart(url, nsIIOService::url_Host, 0, 0, getter_Copies(hostname));

    SetRowValue(row, kToken_HostnameColumn, hostname);
    
#endif

    // to be turned on when we're confident in mork's ability
    // to handle yarn forms properly
#if 0
    nsAutoString title;
    rv = GetRowValue(row, kToken_NameColumn, title);
    // reencode back into UTF8
    if (NS_SUCCEEDED(rv))
      SetRowValue(row, kToken_NameColumn, title.get());
#endif
    cursor->NextRow(mEnv, getter_AddRefs(row), &pos);
  }

  // Finish the batch.
  err = mTable->EndBatchChangeHint(mEnv, &marker);
  NS_ASSERTION(err == 0, "error ending batch");
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3068 of file nsGlobalHistory.cpp.

{
  mdb_err err;

  ExpireEntries(PR_FALSE /* don't notify */);
  err = Commit(kSessionCommit);

  // order is important here - logically smallest objects first
  mMetaRow = nsnull;
  
  if (mTable)
    mTable->Release();

  if (mStore)
    mStore->Release();

  if (mEnv)
    mEnv->Release();

  mTable = nsnull; mEnv = nsnull; mStore = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::Commit ( eCommitType  commitType) [protected]

Definition at line 2972 of file nsGlobalHistory.cpp.

{
  if (!mStore || !mTable)
    return NS_OK;

  nsresult  err = NS_OK;
  nsCOMPtr<nsIMdbThumb> thumb;

  if (commitType == kLargeCommit || commitType == kSessionCommit)
  {
    mdb_percent outActualWaste = 0;
    mdb_bool outShould;
    if (mStore) 
    {
      // check how much space would be saved by doing a compress commit.
      // If it's more than 30%, go for it.
      // N.B. - I'm not sure this calls works in Mork for all cases.
      err = mStore->ShouldCompress(mEnv, 30, &outActualWaste, &outShould);
      if (NS_SUCCEEDED(err) && outShould)
      {
          commitType = kCompressCommit;
      }
      else
      {
        mdb_count count;
        err = mTable->GetCount(mEnv, &count);
        // Since Mork's shouldCompress doesn't work, we need to look
        // at the file size and the number of rows, and make a stab
        // at guessing if we've got a lot of deleted rows. The file
        // size is the size when we opened the db, and we really want
        // it to be the size after we've written out the file,
        // but I think this is a good enough approximation.
        if (count > 0)
        {
          PRInt64 numRows;
          PRInt64 bytesPerRow;
          PRInt64 desiredAvgRowSize;

          LL_UI2L(numRows, count);
          LL_DIV(bytesPerRow, mFileSizeOnDisk, numRows);
          LL_I2L(desiredAvgRowSize, 400);
          if (LL_CMP(bytesPerRow, >, desiredAvgRowSize))
            commitType = kCompressCommit;
        }
      }
    }
  }
  switch (commitType)
  {
  case kLargeCommit:
    err = mStore->LargeCommit(mEnv, getter_AddRefs(thumb));
    break;
  case kSessionCommit:
    err = mStore->SessionCommit(mEnv, getter_AddRefs(thumb));
    break;
  case kCompressCommit:
    err = mStore->CompressCommit(mEnv, getter_AddRefs(thumb));
    break;
  }
  if (err == 0) {
    mdb_count total;
    mdb_count current;
    mdb_bool done;
    mdb_bool broken;

    do {
      err = thumb->DoMore(mEnv, &total, &current, &done, &broken);
    } while ((err == 0) && !broken && !done);
  }
  if (err != 0) // mork doesn't return NS error codes. Yet.
    return NS_ERROR_FAILURE;
  else
    return NS_OK;

}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::Commit ( eCommitType  commitType) [protected]

Definition at line 2817 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  // make sure this was a find query
  if (!IsFindResource(aSource))
    return NS_ERROR_FAILURE;

  const char* uri;
  rv = aSource->GetValueConst(&uri);
  if (NS_FAILED(rv)) return rv;

  // convert uri to a query
  searchQuery* query = new searchQuery;
  if (!query) return NS_ERROR_OUT_OF_MEMORY;
  FindUrlToSearchQuery(uri, *query);

  // the enumerator will take ownership of the query
  SearchEnumerator *result =
    new SearchEnumerator(query, kToken_HiddenColumn, this);
  if (!result) return NS_ERROR_OUT_OF_MEMORY;

  rv = result->Init(mEnv, mTable);
  if (NS_FAILED(rv)) return rv;

  // return the value
  *aResult = result;
  NS_ADDREF(*aResult);
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2924 of file nsGlobalHistory.cpp.

{
  mdb_err err;

  NS_PRECONDITION(mStore != nsnull, "not initialized");
  if (! mStore)
    return NS_ERROR_NOT_INITIALIZED;

  err = mStore->StringToToken(mEnv, "ns:history:db:row:scope:history:all", &kToken_HistoryRowScope);
  if (err != 0) return NS_ERROR_FAILURE;
  
  err = mStore->StringToToken(mEnv, "ns:history:db:table:kind:history", &kToken_HistoryKind);
  if (err != 0) return NS_ERROR_FAILURE;
  
  err = mStore->StringToToken(mEnv, "URL", &kToken_URLColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "Referrer", &kToken_ReferrerColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "LastVisitDate", &kToken_LastVisitDateColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "FirstVisitDate", &kToken_FirstVisitDateColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "VisitCount", &kToken_VisitCountColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "Name", &kToken_NameColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "Hostname", &kToken_HostnameColumn);
  if (err != 0) return NS_ERROR_FAILURE;
  
  err = mStore->StringToToken(mEnv, "Hidden", &kToken_HiddenColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  err = mStore->StringToToken(mEnv, "Typed", &kToken_TypedColumn);
  if (err != 0) return NS_ERROR_FAILURE;

  // meta-data tokens
  err = mStore->StringToToken(mEnv, "LastPageVisited", &kToken_LastPageVisited);
  err = mStore->StringToToken(mEnv, "ByteOrder", &kToken_ByteOrder);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFDataSource::DoCommand ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Perform the specified command on set of sources.

Here is the caller graph for this function:

Notify observers that the datasource has completed issuing a notification group.

Definition at line 3050 of file nsGlobalHistory.cpp.

{
  PRTime expirationDate;
  PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInExpireDays;
  
  LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
  LL_UI2L(secondsInDays, 60 * 60 * 24 * mExpireDays);
  LL_MUL(microSecondsInExpireDays, secondsInDays, microSecondsPerSecond);
  LL_SUB(expirationDate, GetNow(), microSecondsInExpireDays);

  matchExpiration_t expiration;
  expiration.history = this;
  expiration.expirationDate = &expirationDate;
  
  return RemoveMatchingRows(matchExpirationCallback, (void *)&expiration, notify);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1930 of file nsGlobalHistory.cpp.

static void nsGlobalHistory::expireNowTimer ( nsITimer aTimer,
void aClosure 
) [inline, static, protected]

Definition at line 249 of file nsGlobalHistory.h.

  {((nsGlobalHistory *)aClosure)->ExpireNow(); }

Here is the caller graph for this function:

static void nsGlobalHistory::expireNowTimer ( nsITimer aTimer,
void aClosure 
) [inline, static, protected]

Definition at line 250 of file nsGlobalHistory.h.

  {((nsGlobalHistory *)aClosure)->ExpireNow(); }
nsresult nsGlobalHistory::FindRow ( mdb_column  aCol,
const char *  aURL,
nsIMdbRow **  aResult 
) [protected]
nsresult nsGlobalHistory::FindRow ( mdb_column  aCol,
const char *  aURL,
nsIMdbRow **  aResult 
) [protected]

Definition at line 3093 of file nsGlobalHistory.cpp.

{
  if (! mStore)
    return NS_ERROR_NOT_INITIALIZED;

  mdb_err err;
  PRInt32 len = PL_strlen(aValue);
  mdbYarn yarn = { (void*) aValue, len, len, 0, 0, nsnull };

  mdbOid rowId;
  nsCOMPtr<nsIMdbRow> row;
  if (aResult) {
    err = mStore->FindRow(mEnv, kToken_HistoryRowScope,
                          aCol, &yarn, &rowId, getter_AddRefs(row));

    if (!row) return NS_ERROR_NOT_AVAILABLE;
  } else {
    err = mStore->FindRow(mEnv, kToken_HistoryRowScope,
                          aCol, &yarn, &rowId, nsnull);
  }

  // make sure it's actually stored in the main table
  mdb_bool hasRow;
  mTable->HasOid(mEnv, &rowId, &hasRow);

  if (!hasRow) return NS_ERROR_NOT_AVAILABLE;
  
  if (aResult) {
    *aResult = row;
    (*aResult)->AddRef();
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::FindUrlToSearchQuery ( const char *  aURL,
searchQuery aResult 
) [protected]

Definition at line 3462 of file nsGlobalHistory.cpp.

{

  nsresult rv;
  // convert uri to list of tokens
  nsVoidArray tokenPairs;
  rv = FindUrlToTokenList(aUrl, tokenPairs);
  if (NS_FAILED(rv)) return rv;

  // now convert the tokens to a query
  rv = TokenListToSearchQuery(tokenPairs, aResult);
  
  FreeTokenList(tokenPairs);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::FindUrlToSearchQuery ( const char *  aURL,
searchQuery aResult 
) [protected]
nsresult nsGlobalHistory::FindUrlToTokenList ( const char *  aURL,
nsVoidArray aResult 
) [static, protected]

Definition at line 3285 of file nsGlobalHistory.cpp.

{
  if (PL_strncmp(aURL, "find:", 5) != 0)
    return NS_ERROR_UNEXPECTED;
  
  const char *curpos = aURL + 5;
  const char *tokenstart = curpos;

  // this is where we will store the current name and value
  const char *tokenName = nsnull;
  const char *tokenValue = nsnull;
  PRUint32 tokenNameLength=0;
  PRUint32 tokenValueLength=0;
  
  PRBool haveValue = PR_FALSE;  // needed because some values are 0-length
  while (PR_TRUE) {
    while (*curpos && (*curpos != '&') && (*curpos != '='))
      curpos++;

    if (*curpos == '=')  {        // just found a token name
      tokenName = tokenstart;
      tokenNameLength = (curpos - tokenstart);
    }
    else if ((!*curpos || *curpos == '&') &&
             (tokenNameLength>0)) { // found a value, and we have a
                                    // name
      tokenValue = tokenstart;
      tokenValueLength = (curpos - tokenstart);
      haveValue = PR_TRUE;
    }

    // once we have a name/value pair, store it away
    // note we're looking at lengths, so that
    // "find:&a=b" doesn't connect with a=""
    if (tokenNameLength>0 && haveValue) {

      tokenPair *tokenStruct = new tokenPair(tokenName, tokenNameLength,
                                             tokenValue, tokenValueLength);
      if (tokenStruct)
        aResult.AppendElement((void *)tokenStruct);

      // reset our state
      tokenName = tokenValue = nsnull;
      tokenNameLength = tokenValueLength = 0;
      haveValue = PR_FALSE;
    }

    // the test has to be here to catch empty values
    if (!*curpos) break;
    
    curpos++;
    tokenstart = curpos;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult nsGlobalHistory::FindUrlToTokenList ( const char *  aURL,
nsVoidArray aResult 
) [static, protected]
static void nsGlobalHistory::fireSyncTimer ( nsITimer aTimer,
void aClosure 
) [inline, static, protected]

Definition at line 261 of file nsGlobalHistory.h.

  {((nsGlobalHistory *)aClosure)->Sync(); }

Here is the caller graph for this function:

static void nsGlobalHistory::fireSyncTimer ( nsITimer aTimer,
void aClosure 
) [inline, static, protected]

Definition at line 262 of file nsGlobalHistory.h.

  {((nsGlobalHistory *)aClosure)->Sync(); }

Request that a data source write it's contents out to permanent storage, if applicable.

Implemented in LocalStoreImpl.

Here is the caller graph for this function:

void nsGlobalHistory::FreeSearchQuery ( searchQuery aQuery) [static, protected]

Definition at line 3354 of file nsGlobalHistory.cpp.

{
  // free up the token pairs
  PRInt32 i;
  for (i=0; i<aQuery.terms.Count(); i++) {
    searchTerm *term = (searchTerm*)aQuery.terms.ElementAt(i);
    delete term;
  }
  // clean out the array, just for good measure
  aQuery.terms.Clear();
}

Here is the caller graph for this function:

static void nsGlobalHistory::FreeSearchQuery ( searchQuery aQuery) [static, protected]
void nsGlobalHistory::FreeTokenList ( nsVoidArray tokens) [static, protected]

Definition at line 3343 of file nsGlobalHistory.cpp.

{
  PRUint32 length = tokens.Count();
  PRUint32 i;
  for (i=0; i<length; i++) {
    tokenPair *token = (tokenPair*)tokens[i];
    delete token;
  }
  tokens.Clear();
}

Here is the caller graph for this function:

static void nsGlobalHistory::FreeTokenList ( nsVoidArray tokens) [static, protected]

Definition at line 244 of file nsGlobalHistory.cpp.

{
  PRTime timeNow      = GetNow();
  PRTime dateMidnight = NormalizeTime(aDate);

  PRTime diff;
  LL_SUB(diff, timeNow, dateMidnight);
  PRInt64 ageInDays;
  LL_DIV(ageInDays, diff, MSECS_PER_DAY);
  PRInt32 retval;
  LL_L2I(retval, ageInDays);

  return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the set of all commands defined for a given source.

Here is the caller graph for this function:

Retrieve all of the resources that the data source currently refers to.

Here is the caller graph for this function:

nsresult nsGlobalHistory::GetByteOrder ( char **  _retval) [protected]

Definition at line 1394 of file nsGlobalHistory.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::GetByteOrder ( char **  _retval) [protected]
nsresult nsGlobalHistory::GetFindUriName ( const char *  aURL,
nsIRDFNode **  aResult 
) [protected]

Definition at line 3669 of file nsGlobalHistory.cpp.

{

  nsresult rv;

  searchQuery query;
  rv = FindUrlToSearchQuery(aURL, query);

  // can't exactly get a name if there's nothing to search for
  if (query.terms.Count() < 1)
    return NS_OK;

  // now build up a string from the query (using only the last term)
  searchTerm *term = (searchTerm*)query.terms[query.terms.Count()-1];

  // automatically build up string in the form
  // findurl-<property>-<method>[-<text>]
  // such as "finduri-AgeInDays-is" or "find-uri-AgeInDays-is-0"
  nsAutoString stringName(NS_LITERAL_STRING("finduri-"));

  // property
  stringName.Append(NS_ConvertASCIItoUCS2(term->property));
  stringName.Append(PRUnichar('-'));

  // and now the method, such as "is" or "isgreater"
  stringName.Append(NS_ConvertASCIItoUCS2(term->method));

  // try adding -<text> to see if there's a match
  // for example, to match
  // finduri-LastVisitDate-is-0=Today
  PRInt32 preTextLength = stringName.Length();
  stringName.Append(PRUnichar('-'));
  stringName.Append(term->text);
  stringName.Append(PRUnichar(0));

  // try to find a localizable string
  const PRUnichar *strings[] = {
    term->text.get()
  };
  nsXPIDLString value;

  // first with the search text
  rv = mBundle->FormatStringFromName(stringName.get(),
                                     strings, 1, getter_Copies(value));

  // ok, try it without the -<text>, to match
  // finduri-LastVisitDate-is=%S days ago
  if (NS_FAILED(rv)) {
    stringName.Truncate(preTextLength);
    rv = mBundle->FormatStringFromName(stringName.get(),
                                       strings, 1, getter_Copies(value));
  }

  nsCOMPtr<nsIRDFLiteral> literal;
  if (NS_SUCCEEDED(rv)) {
    rv = gRDFService->GetLiteral(value, getter_AddRefs(literal));
  } else {
    // ok, no such string, so just put the match text itself there
    rv = gRDFService->GetLiteral(term->text.get(),
                                 getter_AddRefs(literal));
  }
  FreeSearchQuery(query);
    
  if (NS_FAILED(rv)) return rv;
  
  *aResult = literal;
  NS_ADDREF(*aResult);
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::GetFindUriName ( const char *  aURL,
nsIRDFNode **  aResult 
) [protected]
void nsGlobalHistory::GetFindUriPrefix ( const searchQuery aQuery,
const PRBool  aDoGroupBy,
nsACString &  aResult 
) [protected]

Definition at line 3868 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  aResult.Assign("find:");
  PRUint32 length = aQuery.terms.Count();
  PRUint32 i;
  
  for (i=0; i<length; i++) {
    searchTerm *term = (searchTerm*)aQuery.terms[i];
    if (i != 0)
      aResult.Append('&');
    aResult.Append("datasource=");
    aResult.Append(term->datasource);
    
    aResult.Append("&match=");
    aResult.Append(term->property);
    
    aResult.Append("&method=");
    aResult.Append(term->method);

    aResult.Append("&text=");
    aResult.Append(NS_ConvertUCS2toUTF8(term->text));
  }

  if (aQuery.groupBy == 0) return;

  // find out the name of the column we're grouping by
  char groupby[100];
  mdbYarn yarn = { groupby, 0, sizeof(groupby), 0, 0, nsnull };
  err = mStore->TokenToString(mEnv, aQuery.groupBy, &yarn);
  
  // put a "groupby=<colname>"
  if (aDoGroupBy) {
    aResult.Append("&groupby=");
    if (err == 0)
      aResult.Append((const char*)yarn.mYarn_Buf, yarn.mYarn_Fill);
  }

  // put &datasource=history&match=<colname>&method=is&text=
  else {
    // if the query has a groupby=<foo> then we want to append that
    // field as the last field to match.. caller has to be sure to
    // append that!
    aResult.Append("&datasource=history");
    
    aResult.Append("&match=");
    if (err == 0)
      aResult.Append((const char*)yarn.mYarn_Buf, yarn.mYarn_Fill);
    // herep  
    aResult.Append("&method=is");
    aResult.Append("&text=");
  }
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsGlobalHistory::GetFindUriPrefix ( const searchQuery aQuery,
const PRBool  aDoGroupBy,
nsACString &  aResult 
) [protected]

Definition at line 1963 of file nsGlobalHistory.cpp.

{
  if (!mNowValid) {             // not dirty, mLastNow is crufty
    mLastNow = PR_Now();
    mNowValid = PR_TRUE;
    if (!mExpireNowTimer)
      mExpireNowTimer = do_CreateInstance("@mozilla.org/timer;1");

    if (mExpireNowTimer)
      mExpireNowTimer->InitWithFuncCallback(expireNowTimer, this, HISTORY_EXPIRE_NOW_TIMEOUT,
                                            nsITimer::TYPE_ONE_SHOT);
  }
  
  return mLastNow;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::GetRootDayQueries ( nsISimpleEnumerator **  aResult,
PRBool  aBySite 
) [protected]

Definition at line 3233 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  nsCOMPtr<nsISupportsArray> dayArray;
  NS_NewISupportsArray(getter_AddRefs(dayArray));
  
  PRInt32 i;
  nsCOMPtr<nsIRDFResource> finduri;
  nsDependentCString
    prefix(FIND_BY_AGEINDAYS_PREFIX "is" "&text=");
  nsCAutoString uri;
  nsCOMPtr<nsISimpleEnumerator> findEnumerator;
  PRBool hasMore = PR_FALSE;
  for (i=0; i<7; i++) {
    uri = prefix;
    uri.AppendInt(i);
    if (aBySite)
      uri.Append("&groupby=Hostname");
    rv = gRDFService->GetResource(uri, getter_AddRefs(finduri));
    if (NS_FAILED(rv)) continue;
    rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator));
    if (NS_FAILED(rv)) continue;
    rv = findEnumerator->HasMoreElements(&hasMore);
    if (NS_SUCCEEDED(rv) && hasMore)
      dayArray->AppendElement(finduri);
  }

  uri = FIND_BY_AGEINDAYS_PREFIX "isgreater" "&text=";
  uri.AppendInt(i-1);
  if (aBySite)
    uri.Append("&groupby=Hostname");
  rv = gRDFService->GetResource(uri, getter_AddRefs(finduri));
  if (NS_SUCCEEDED(rv)) {
    rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator));
    if (NS_SUCCEEDED(rv)) {
      rv = findEnumerator->HasMoreElements(&hasMore);
      if (NS_SUCCEEDED(rv) && hasMore)
        dayArray->AppendElement(finduri);
    }
  }

  return NS_NewArrayEnumerator(aResult, dayArray);
}

Here is the call graph for this function:

Definition at line 3144 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  nsCOMPtr<nsISupportsArray> dayArray;
  NS_NewISupportsArray(getter_AddRefs(dayArray));
  
  PRInt32 i;
  nsCOMPtr<nsIRDFResource> finduri;
  nsDependentCString
    prefix(FIND_BY_AGEINDAYS_PREFIX "is" "&text=");
  nsCAutoString uri;
  nsCOMPtr<nsISimpleEnumerator> findEnumerator;
  PRBool hasMore = PR_FALSE;
  for (i=0; i<7; i++) {
    uri = prefix;
    uri.AppendInt(i);
    uri.Append("&groupby=Hostname");
    rv = gRDFService->GetResource(uri, getter_AddRefs(finduri));
    if (NS_FAILED(rv)) continue;
    rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator));
    if (NS_FAILED(rv)) continue;
    rv = findEnumerator->HasMoreElements(&hasMore);
    if (NS_SUCCEEDED(rv) && hasMore)
      dayArray->AppendElement(finduri);
  }

  uri = FIND_BY_AGEINDAYS_PREFIX "isgreater" "&text=";
  uri.AppendInt(i-1);
  uri.Append("&groupby=Hostname");
  rv = gRDFService->GetResource(uri, getter_AddRefs(finduri));
  if (NS_SUCCEEDED(rv)) {
    rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator));
    if (NS_SUCCEEDED(rv)) {
      rv = findEnumerator->HasMoreElements(&hasMore);
      if (NS_SUCCEEDED(rv) && hasMore)
        dayArray->AppendElement(finduri);
    }
  }

  return NS_NewArrayEnumerator(aResult, dayArray);
}

Here is the call graph for this function:

nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
nsAString &  aResult 
) [protected]
nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
nsACString &  aResult 
) [protected]
nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
PRTime aResult 
) [protected]
nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
PRInt32 aResult 
) [protected]
nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
nsAString &  aResult 
) [protected]

Definition at line 977 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, aCol, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  aResult.Truncate(0);
  if (!yarn.mYarn_Fill)
    return NS_OK;
  
  switch (yarn.mYarn_Form) {
  case 0:                       // unicode
    if (mReverseByteOrder) {
      // The file is other-endian; we must byte-swap the result.
      PRUnichar *swapval;
      int len = yarn.mYarn_Fill / sizeof(PRUnichar);
      swapval = (PRUnichar *)malloc(yarn.mYarn_Fill);
      if (!swapval)
        return NS_ERROR_OUT_OF_MEMORY;
      SwapBytes((const PRUnichar *)yarn.mYarn_Buf, swapval, len);
      aResult.Assign(swapval, len);
      free(swapval);
    }
    else
      aResult.Assign((const PRUnichar *)yarn.mYarn_Buf, yarn.mYarn_Fill/sizeof(PRUnichar));
    break;

    // eventually we'll be supporting this in SetRowValue()
  case 1:                       // UTF8
    aResult.Assign(NS_ConvertUTF8toUCS2((const char*)yarn.mYarn_Buf, yarn.mYarn_Fill));
    break;

  default:
    return NS_ERROR_UNEXPECTED;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
nsACString &  aResult 
) [protected]

Definition at line 1076 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, aCol, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  const char* startPtr = (const char*)yarn.mYarn_Buf;
  if (startPtr)
    aResult.Assign(Substring(startPtr, startPtr + yarn.mYarn_Fill));
  else
    aResult.Truncate();
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
PRTime aResult 
) [protected]

Definition at line 1038 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, aCol, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  *aResult = LL_ZERO;
  
  if (!yarn.mYarn_Fill || !yarn.mYarn_Buf)
    return NS_OK;

  PR_sscanf((const char*)yarn.mYarn_Buf, "%lld", aResult);
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::GetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
PRInt32 aResult 
) [protected]

Definition at line 1058 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, aCol, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  if (yarn.mYarn_Buf)
    *aResult = atoi((char *)yarn.mYarn_Buf);
  else
    *aResult = 0;
  
  return NS_OK;
}

Here is the call graph for this function:

nsIRDFResource nsIRDFDataSource::GetSource ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find an RDF resource that points to a given node over the specified arc & truth value.

Returns:
NS_RDF_NO_VALUE if there is no source that leads to the target with the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetSources ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find all RDF resources that point to a given node over the specified arc & truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

nsIRDFNode nsIRDFDataSource::GetTarget ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find a child of that is related to the source by the given arc arc and truth value.

Returns:
NS_RDF_NO_VALUE if there is no target accessable from the source via the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetTargets ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find all children of that are related to the source by the given arc arc and truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

boolean nsIRDFDataSource::hasArcIn ( in nsIRDFNode  aNode,
in nsIRDFResource  aArc 
) [inherited]

Returns true if the specified node is pointed to by the specified arc.

Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.

Returns true if the specified node has the specified outward arc.

Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.

boolean nsIRDFDataSource::HasAssertion ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Query whether an assertion exists in this graph.

Here is the caller graph for this function:

void nsIBrowserHistory::hidePage ( in nsIURI  aURI) [inherited]

hidePage Hide the specified URL from being enumerated (and thus displayed in the UI)

if the page hasn't been visited yet, then it will be added as if it was visited, and then marked as hidden

void nsIBrowserHistory::hidePage ( in nsIURI  aURI) [inherited]

hidePage Hide the specified URL from being enumerated (and thus displayed in the UI)

if the page hasn't been visited yet, then it will be added as if it was visited, and then marked as hidden

void nsIRDFRemoteDataSource::Init ( in string  aURI) [inherited]

Specify the URI for the data source: this is the prefix that will be used to register the data source in the data source registry.

Parameters:
aURIthe URI to load
NS_DECL_ISUPPORTS NS_DECL_NSIGLOBALHISTORY2 NS_DECL_NSIBROWSERHISTORY NS_DECL_NSIOBSERVER NS_DECL_NSIRDFDATASOURCE NS_DECL_NSIRDFREMOTEDATASOURCE NS_DECL_NSIAUTOCOMPLETESESSION NS_METHOD nsGlobalHistory::Init ( )

Definition at line 2530 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  // we'd like to get this pref when we need it, but at that point,
  // we can't get the pref service. register a pref observer so we update
  // if the pref changes

  if (!gPrefBranch) {
    nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = prefs->GetBranch(PREF_BRANCH_BASE, &gPrefBranch);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  gPrefBranch->GetIntPref(PREF_BROWSER_HISTORY_EXPIRE_DAYS, &mExpireDays);
  gPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_ONLY_TYPED, &mAutocompleteOnlyTyped);
  nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(gPrefBranch);
  if (pbi) {
    pbi->AddObserver(PREF_AUTOCOMPLETE_ONLY_TYPED, this, PR_FALSE);
    pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS, this, PR_FALSE);
  }

  if (gRefCnt++ == 0) {
    rv = CallGetService(kRDFServiceCID, &gRDFService);

    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
    if (NS_FAILED(rv)) return rv;

    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Page"),        &kNC_Page);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Date"),        &kNC_Date);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FirstVisitDate"),
                             &kNC_FirstVisitDate);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "VisitCount"),  &kNC_VisitCount);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "AgeInDays"),  &kNC_AgeInDays);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"),        &kNC_Name);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name?sort=true"), &kNC_NameSort);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Hostname"),    &kNC_Hostname);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Referrer"),    &kNC_Referrer);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"),       &kNC_child);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"),         &kNC_URL);
    gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "DayFolderIndex"), &kNC_DayFolderIndex);
    gRDFService->GetResource(NS_LITERAL_CSTRING("NC:HistoryRoot"),               &kNC_HistoryRoot);
    gRDFService->GetResource(NS_LITERAL_CSTRING("NC:HistoryByDateAndSite"),           &kNC_HistoryByDateAndSite);
    gRDFService->GetResource(NS_LITERAL_CSTRING("NC:HistoryByDate"),           &kNC_HistoryByDate);
  }

  // register this as a named data source with the RDF service
  rv = gRDFService->RegisterDataSource(this, PR_FALSE);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIStringBundleService> bundleService =
    do_GetService(kStringBundleServiceCID, &rv);
  
  if (NS_SUCCEEDED(rv)) {
    rv = bundleService->CreateBundle("chrome://global/locale/history/history.properties", getter_AddRefs(mBundle));
  }

  // register to observe profile changes
  nsCOMPtr<nsIObserverService> observerService = 
           do_GetService("@mozilla.org/observer-service;1", &rv);
  NS_ASSERTION(observerService, "failed to get observer service");
  if (observerService) {
    observerService->AddObserver(this, "profile-before-change", PR_TRUE);
    observerService->AddObserver(this, "profile-do-change", PR_TRUE);
    observerService->AddObserver(this, "quit-application", PR_TRUE);
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 2786 of file nsGlobalHistory.cpp.

{
#ifdef IS_LITTLE_ENDIAN
  NS_NAMED_LITERAL_CSTRING(machine_byte_order, "LE");
#endif
#ifdef IS_BIG_ENDIAN
  NS_NAMED_LITERAL_CSTRING(machine_byte_order, "BE");
#endif
  nsXPIDLCString file_byte_order;
  nsresult rv = NS_OK;

  if (!aForce)
    rv = GetByteOrder(getter_Copies(file_byte_order));
  if (aForce || NS_FAILED(rv) ||
      !(file_byte_order.Equals(NS_LITERAL_CSTRING("BE")) ||
        file_byte_order.Equals(NS_LITERAL_CSTRING("LE")))) {
    // Byte order is not yet set, or needs to be reset; initialize it.
    mReverseByteOrder = PR_FALSE;
    rv = SaveByteOrder(machine_byte_order.get());
    if (NS_FAILED(rv))
      return rv;
  }
  else
    mReverseByteOrder = !file_byte_order.Equals(machine_byte_order);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIRDFDataSource::IsCommandEnabled ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Returns whether a given command is enabled for a set of sources.

Here is the caller graph for this function:

PRBool nsGlobalHistory::IsFindResource ( nsIRDFResource aResource) [static, protected]

Definition at line 3370 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  const char *value;
  rv = aResource->GetValueConst(&value);
  if (NS_FAILED(rv)) return PR_FALSE;

  return (PL_strncmp(value, "find:", 5)==0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool nsGlobalHistory::IsFindResource ( nsIRDFResource aResource) [static, protected]

Definition at line 3130 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  const char* url;
  rv = aResource->GetValueConst(&url);
  if (NS_FAILED(rv)) return PR_FALSE;

  rv = FindRow(kToken_URLColumn, url, nsnull);
  return (NS_SUCCEEDED(rv)) ? PR_TRUE : PR_FALSE;
}

Here is the call graph for this function:

Checks to see whether the given URI is in history.

Parameters:
aURIthe uri to the page
Returns:
true if a URI has been visited

markPageAsTyped Designate the url as having been explicitly typed in by the user, so it's okay to be an autocomplete result.

markPageAsTyped Designate the url as having been explicitly typed in by the user, so it's okay to be an autocomplete result.

PRBool nsGlobalHistory::MatchExpiration ( nsIMdbRow row,
PRTime expirationDate 
)
PRBool nsGlobalHistory::MatchExpiration ( nsIMdbRow row,
PRTime expirationDate 
)

Definition at line 273 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  
  // hidden and typed urls always match because they're invalid,
  // so we want to expire them asap.  (if they were valid, they'd
  // have been unhidden -- see AddExistingPageToDatabase)
  if (HasCell(mEnv, row, kToken_HiddenColumn) && HasCell(mEnv, row, kToken_TypedColumn))
    return PR_TRUE;

  PRTime lastVisitedTime;
  rv = GetRowValue(row, kToken_LastVisitDateColumn, &lastVisitedTime);

  if (NS_FAILED(rv)) 
    return PR_FALSE;
  
  return LL_CMP(lastVisitedTime, <, *expirationDate);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1202 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  nsresult rv;

  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, kToken_URLColumn, &yarn);
  if (err != 0) return PR_FALSE;

  nsCOMPtr<nsIURI> uri;
  // do smart zero-termination
  const char* startPtr = (const char *)yarn.mYarn_Buf;
  rv = NS_NewURI(getter_AddRefs(uri),
                 Substring(startPtr, startPtr + yarn.mYarn_Fill));
  if (NS_FAILED(rv)) return PR_FALSE;

  nsCAutoString urlHost;
  rv = uri->GetHost(urlHost);
  if (NS_FAILED(rv)) return PR_FALSE;

  if (PL_strcmp(urlHost.get(), hostInfo->host) == 0)
    return PR_TRUE;

  // now try for a domain match, if necessary
  if (hostInfo->entireDomain) {
    // do a reverse-search to match the end of the string
    const char *domain = PL_strrstr(urlHost.get(), hostInfo->host);
    
    // now verify that we're matching EXACTLY the domain, and
    // not some random string inside the hostname
    if (domain && (PL_strcmp(domain, hostInfo->host) == 0))
      return PR_TRUE;
  }
  
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFDataSource::Move ( in nsIRDFResource  aOldSource,
in nsIRDFResource  aNewSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

'Move' an assertion from

[aOldSource]--[aProperty]-->[aTarget]

to

[aNewSource]--[aProperty]-->[aTarget]

Here is the caller graph for this function:

Definition at line 224 of file nsGlobalHistory.cpp.

{
  // we can optimize this by converting the time to local time, rounding
  // down to the previous day boundary, and then converting back to UTC.
  // This avoids two costly calls to localtime()

  // we calculate (gmtTime - (gmtTime % MSECS_PER_DAY)) - mCachedGMTOffset
  PRTime gmtTime;
  LL_ADD(gmtTime, aTime, mCachedGMTOffset);
  PRInt64 curDayUSec;
  LL_MOD(curDayUSec, gmtTime, MSECS_PER_DAY);
  PRTime gmtMidnight;
  LL_SUB(gmtMidnight, gmtTime, curDayUSec);
  PRTime localMidnight;
  LL_SUB(localMidnight, gmtMidnight, mCachedGMTOffset);
  
  return localMidnight;
}

Here is the caller graph for this function:

nsresult nsGlobalHistory::NotifyAssert ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aValue 
) [protected]

Definition at line 3144 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  if (mObservers) {
    PRUint32 count;
    rv = mObservers->Count(&count);
    if (NS_FAILED(rv)) return rv;

    for (PRInt32 i = 0; i < PRInt32(count); ++i) {
      nsIRDFObserver* observer = NS_STATIC_CAST(nsIRDFObserver*, mObservers->ElementAt(i));

      NS_ASSERTION(observer != nsnull, "null ptr");
      if (! observer)
        continue;

      rv = observer->OnAssert(this, aSource, aProperty, aValue);
      NS_RELEASE(observer);
    }
  }

  return NS_OK;
}

Here is the caller graph for this function:

nsresult nsGlobalHistory::NotifyAssert ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aValue 
) [protected]
nsresult nsGlobalHistory::NotifyChange ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aOldValue,
nsIRDFNode aNewValue 
) [protected]

Definition at line 3201 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  if (mObservers) {
    PRUint32 count;
    rv = mObservers->Count(&count);
    if (NS_FAILED(rv)) return rv;

    for (PRInt32 i = 0; i < PRInt32(count); ++i) {
      nsIRDFObserver* observer = NS_STATIC_CAST(nsIRDFObserver*, mObservers->ElementAt(i));

      NS_ASSERTION(observer != nsnull, "null ptr");
      if (! observer)
        continue;

      rv = observer->OnChange(this, aSource, aProperty, aOldValue, aNewValue);
      NS_RELEASE(observer);
    }
  }

  return NS_OK;
}

Here is the caller graph for this function:

nsresult nsGlobalHistory::NotifyChange ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aOldValue,
nsIRDFNode aNewValue 
) [protected]

Definition at line 3493 of file nsGlobalHistory.cpp.

{
  // we'll construct a bunch of sample queries, and then do
  // appropriate assertions

  // first pull out the appropriate values
  PRTime lastVisited;
  GetRowValue(aRow, kToken_LastVisitDateColumn, &lastVisited);

  PRInt32 ageInDays = GetAgeInDays(NormalizeTime(GetNow()), lastVisited);
  nsCAutoString ageString; ageString.AppendInt(ageInDays);

  nsCAutoString hostname;
  GetRowValue(aRow, kToken_HostnameColumn, hostname);
  
  // construct some terms that we'll use later
  
  // Hostname=<hostname>
  searchTerm hostterm("history", sizeof("history")-1,
                      "Hostname", sizeof("Hostname")-1,
                      "is", sizeof("is")-1,
                      hostname.get(), hostname.Length());

  // AgeInDays=<age>
  searchTerm ageterm("history", sizeof("history") -1,
                     "AgeInDays", sizeof("AgeInDays")-1,
                     "is", sizeof("is")-1,
                     ageString.get(), ageString.Length());

  searchQuery query;
  nsCAutoString findUri;
  nsCOMPtr<nsIRDFResource> childFindResource;
  nsCOMPtr<nsIRDFResource> parentFindResource;

  // 2) NC:HistoryByDate -> AgeInDays=<age>&groupby=Hostname
  query.groupBy = kToken_HostnameColumn;
  query.terms.AppendElement((void *)&ageterm);

  GetFindUriPrefix(query, PR_TRUE, findUri);
  gRDFService->GetResource(findUri, getter_AddRefs(childFindResource));
  NotifyAssert(kNC_HistoryByDateAndSite, kNC_child, childFindResource);
  parentFindResource = childFindResource;
  
  query.terms.Clear();

  query.groupBy = 0;
  query.terms.AppendElement((void *)&ageterm);

  GetFindUriPrefix(query, PR_TRUE, findUri);
  gRDFService->GetResource(findUri, getter_AddRefs(childFindResource));
  NotifyAssert(kNC_HistoryByDate, kNC_child, childFindResource);

  query.terms.Clear();
  

  query.groupBy = 0;
  query.terms.AppendElement((void *)&ageterm);

  GetFindUriPrefix(query, PR_TRUE, findUri);
  gRDFService->GetResource(findUri, getter_AddRefs(childFindResource));
  NotifyAssert(childFindResource, kNC_child, aSource);

  query.terms.Clear();

  // 3) AgeInDays=<age>&groupby=Hostname ->
  //    AgeInDays=<age>&Hostname=<host>
  

  query.groupBy = 0;            // create AgeInDays=<age>&Hostname=<host>
  query.terms.AppendElement((void *)&ageterm);
  query.terms.AppendElement((void *)&hostterm);
  
  GetFindUriPrefix(query, PR_FALSE, findUri);
  gRDFService->GetResource(findUri, getter_AddRefs(childFindResource));
  NotifyAssert(parentFindResource, kNC_child, childFindResource);
  
  query.terms.Clear();

  // 4) AgeInDays=<age>&Hostname=<host> -> uri
  parentFindResource = childFindResource; // AgeInDays=<age>&hostname=<host>
  NotifyAssert(childFindResource, kNC_child, aSource);
  
  // 5) groupby=Hostname -> Hostname=<host>
  query.groupBy = kToken_HostnameColumn; // create groupby=Hostname
  
  GetFindUriPrefix(query, PR_TRUE, findUri);
  gRDFService->GetResource(findUri, getter_AddRefs(parentFindResource));

  query.groupBy = 0;            // create Hostname=<host>
  query.terms.AppendElement((void *)&hostterm);
  GetFindUriPrefix(query, PR_FALSE, findUri);
  findUri.Append(hostname);     // append <host>
  gRDFService->GetResource(findUri, getter_AddRefs(childFindResource));
  
  NotifyAssert(parentFindResource, kNC_child, childFindResource);

  // 6) Hostname=<host> -> uri
  parentFindResource = childFindResource; // Hostname=<host>
  NotifyAssert(parentFindResource, kNC_child, aSource);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3605 of file nsGlobalHistory.cpp.

{
  // 1) NC:HistoryRoot
  NotifyUnassert(kNC_HistoryRoot, kNC_child, aSource);

  //    first get age in days
  PRTime lastVisited;
  GetRowValue(aRow, kToken_LastVisitDateColumn, &lastVisited);
  PRInt32 ageInDays = GetAgeInDays(NormalizeTime(GetNow()), lastVisited);
  nsCAutoString ageString; ageString.AppendInt(ageInDays);

  //    now get hostname
  nsCAutoString hostname;
  GetRowValue(aRow, kToken_HostnameColumn, hostname);

  //    construct some terms
  //    Hostname=<hostname>
  searchTerm hostterm("history", sizeof("history")-1,
                      "Hostname", sizeof("Hostname")-1,
                      "is", sizeof("is")-1,
                      hostname.get(), hostname.Length());
  
  //    AgeInDays=<age>
  searchTerm ageterm("history", sizeof("history") -1,
                     "AgeInDays", sizeof("AgeInDays")-1,
                     "is", sizeof("is")-1,
                     ageString.get(), ageString.Length());

  searchQuery query;
  query.groupBy = 0;
  
  nsCAutoString findUri;
  nsCOMPtr<nsIRDFResource> findResource;
  
  // 2) AgeInDays=<age>&Hostname=<host>
  query.terms.AppendElement((void *)&ageterm);
  query.terms.AppendElement((void *)&hostterm);
  GetFindUriPrefix(query, PR_FALSE, findUri);
  
  gRDFService->GetResource(findUri, getter_AddRefs(findResource));
  
  NotifyUnassert(findResource, kNC_child, aSource);

  // 3) Hostname=<host>
  query.terms.Clear();
  
  query.terms.AppendElement((void *)&hostterm);
  GetFindUriPrefix(query, PR_FALSE, findUri);
  
  gRDFService->GetResource(findUri, getter_AddRefs(findResource));
  NotifyUnassert(findResource, kNC_child, aSource);

  query.terms.Clear();

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::NotifyUnassert ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aValue 
) [protected]

Definition at line 3172 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  if (mObservers) {
    PRUint32 count;
    rv = mObservers->Count(&count);
    if (NS_FAILED(rv)) return rv;

    for (PRInt32 i = 0; i < PRInt32(count); ++i) {
      nsIRDFObserver* observer = NS_STATIC_CAST(nsIRDFObserver*, mObservers->ElementAt(i));

      NS_ASSERTION(observer != nsnull, "null ptr");
      if (! observer)
        continue;

      rv = observer->OnUnassert(this, aSource, aProperty, aValue);
      NS_RELEASE(observer);
    }
  }

  return NS_OK;
}

Here is the caller graph for this function:

nsresult nsGlobalHistory::NotifyUnassert ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aValue 
) [protected]
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIAutoCompleteSession::onAutoComplete ( in wstring  searchString,
in nsIAutoCompleteResults  previousSearchResult,
in nsIAutoCompleteListener  listener 
) [inherited]
void nsIAutoCompleteSession::onStartLookup ( in wstring  searchString,
in nsIAutoCompleteResults  previousSearchResult,
in nsIAutoCompleteListener  listener 
) [inherited]

Definition at line 2603 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  if (mStore) return NS_OK;
  
  nsCOMPtr <nsIFile> historyFile;
  rv = NS_GetSpecialDirectory(NS_APP_HISTORY_50_FILE, getter_AddRefs(historyFile));
  NS_ENSURE_SUCCESS(rv, rv);

  static NS_DEFINE_CID(kMorkCID, NS_MORK_CID);
  nsCOMPtr<nsIMdbFactoryFactory> factoryfactory =
      do_CreateInstance(kMorkCID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = factoryfactory->GetMdbFactory(&gMdbFactory);
  NS_ENSURE_SUCCESS(rv, rv);

  mdb_err err;

  err = gMdbFactory->MakeEnv(nsnull, &mEnv);
  mEnv->SetAutoClear(PR_TRUE);
  NS_ASSERTION((err == 0), "unable to create mdb env");
  if (err != 0) return NS_ERROR_FAILURE;

  // MDB requires native file paths

  nsCAutoString filePath;
  rv = historyFile->GetNativePath(filePath);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool exists = PR_TRUE;

  historyFile->Exists(&exists);
    
  if (!exists || NS_FAILED(rv = OpenExistingFile(gMdbFactory, filePath.get()))) {

    // we couldn't open the file, so it's either corrupt or doesn't exist.
    // attempt to delete the file, but ignore the error
    historyFile->Remove(PR_FALSE);
    rv = OpenNewFile(gMdbFactory, filePath.get());
  }

  NS_ENSURE_SUCCESS(rv, rv);

  // get the initial filesize. Used in Commit() to determine type of commit.
  rv = historyFile->GetFileSize(&mFileSizeOnDisk);
  if (NS_FAILED(rv)) {
    LL_I2L(mFileSizeOnDisk, 0);
  }
  
  // See if we need to byte-swap.
  InitByteOrder(PR_FALSE);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::OpenExistingFile ( nsIMdbFactory factory,
const char *  filePath 
) [protected]

Definition at line 2661 of file nsGlobalHistory.cpp.

{

  mdb_err err;
  nsresult rv;
  mdb_bool canopen = 0;
  mdbYarn outfmt = { nsnull, 0, 0, 0, 0, nsnull };

  nsIMdbHeap* dbHeap = 0;
  mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable
  nsCOMPtr<nsIMdbFile> oldFile; // ensures file is released
  err = factory->OpenOldFile(mEnv, dbHeap, filePath,
                             dbFrozen, getter_AddRefs(oldFile));

  // don't assert, the file might just not be there
  if ((err !=0) || !oldFile) return NS_ERROR_FAILURE;

  err = factory->CanOpenFilePort(mEnv, oldFile, // the file to investigate
                                 &canopen, &outfmt);

  // XXX possible that format out of date, in which case we should
  // just re-write the file.
  if ((err !=0) || !canopen) return NS_ERROR_FAILURE;

  nsIMdbThumb* thumb = nsnull;
  mdbOpenPolicy policy = { { 0, 0 }, 0, 0 };

  err = factory->OpenFileStore(mEnv, dbHeap, oldFile, &policy, &thumb);
  if ((err !=0) || !thumb) return NS_ERROR_FAILURE;

  mdb_count total;
  mdb_count current;
  mdb_bool done;
  mdb_bool broken;

  do {
    err = thumb->DoMore(mEnv, &total, &current, &done, &broken);
  } while ((err == 0) && !broken && !done);

  if ((err == 0) && done) {
    err = factory->ThumbToOpenStore(mEnv, thumb, &mStore);
  }

  NS_IF_RELEASE(thumb);

  if (err != 0) return NS_ERROR_FAILURE;

  rv = CreateTokens();
  NS_ENSURE_SUCCESS(rv, rv);

  mdbOid oid = { kToken_HistoryRowScope, 1 };
  err = mStore->GetTable(mEnv, &oid, &mTable);
  NS_ENSURE_TRUE(err == 0, NS_ERROR_FAILURE);
  if (!mTable) {
    NS_WARNING("Your history file is somehow corrupt.. deleting it.");
    return NS_ERROR_FAILURE;
  }

  err = mTable->GetMetaRow(mEnv, &oid, nsnull, getter_AddRefs(mMetaRow));
  if (err != 0)
    NS_WARNING("Could not get meta row\n");

  CheckHostnameEntries();

  if (err != 0) return NS_ERROR_FAILURE;
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::OpenExistingFile ( nsIMdbFactory factory,
const char *  filePath 
) [protected]
nsresult nsGlobalHistory::OpenNewFile ( nsIMdbFactory factory,
const char *  filePath 
) [protected]

Definition at line 2731 of file nsGlobalHistory.cpp.

{
  nsresult rv;
  mdb_err err;
  
  nsIMdbHeap* dbHeap = 0;
  nsCOMPtr<nsIMdbFile> newFile; // ensures file is released
  err = factory->CreateNewFile(mEnv, dbHeap, filePath,
                               getter_AddRefs(newFile));

  if ((err != 0) || !newFile) return NS_ERROR_FAILURE;
  
  mdbOpenPolicy policy = { { 0, 0 }, 0, 0 };
  err = factory->CreateNewFileStore(mEnv, dbHeap, newFile, &policy, &mStore);
  
  if (err != 0) return NS_ERROR_FAILURE;
  
  rv = CreateTokens();
  NS_ENSURE_SUCCESS(rv, rv);

  // Create the one and only table in the history db
  err = mStore->NewTable(mEnv, kToken_HistoryRowScope, kToken_HistoryKind, PR_TRUE, nsnull, &mTable);
  if (err != 0) return NS_ERROR_FAILURE;
  if (!mTable) return NS_ERROR_FAILURE;

  // Create the meta row.
  mdbOid oid = { kToken_HistoryRowScope, 1 };
  err = mTable->GetMetaRow(mEnv, &oid, nsnull, getter_AddRefs(mMetaRow));
  if (err != 0)
    NS_WARNING("Could not get meta row\n");

  // Force a commit now to get it written out.
  nsCOMPtr<nsIMdbThumb> thumb;
  err = mStore->LargeCommit(mEnv, getter_AddRefs(thumb));
  if (err != 0) return NS_ERROR_FAILURE;

  mdb_count total;
  mdb_count current;
  mdb_bool done;
  mdb_bool broken;

  do {
    err = thumb->DoMore(mEnv, &total, &current, &done, &broken);
  } while ((err == 0) && !broken && !done);

  if ((err != 0) || !done) return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::OpenNewFile ( nsIMdbFactory factory,
const char *  filePath 
) [protected]
void nsIRDFRemoteDataSource::Refresh ( in boolean  aBlocking) [inherited]

Refresh the remote datasource, re-loading its contents from the URI.

Parameters:
aBlockingIf true, the call will block until the datasource has completely reloaded.

removeAllPages Remove all pages from global history

removeAllPages Remove all pages from global history

nsresult nsGlobalHistory::RemoveMatchingRows ( rowMatchCallback  aMatchFunc,
void aClosure,
PRBool  notify 
) [protected]

Definition at line 1256 of file nsGlobalHistory.cpp.

{
  NS_ENSURE_SUCCESS(OpenDB(), NS_ERROR_FAILURE);
  nsresult rv;
  if (!mTable) return NS_OK;

  mdb_err err;
  mdb_count count;
  err = mTable->GetCount(mEnv, &count);
  if (err != 0) return NS_ERROR_FAILURE;

  BeginUpdateBatch();

  // Begin the batch.
  int marker;
  err = mTable->StartBatchChangeHint(mEnv, &marker);
  NS_ASSERTION(err == 0, "unable to start batch");
  if (err != 0) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIRDFResource> resource;
  // XXX from here until end batch, no early returns!
  for (mdb_pos pos = count - 1; pos >= 0; --pos) {
    nsCOMPtr<nsIMdbRow> row;
    err = mTable->PosToRow(mEnv, pos, getter_AddRefs(row));
    NS_ASSERTION(err == 0, "unable to get row");
    if (err != 0)
      break;

    NS_ASSERTION(row != nsnull, "no row");
    if (! row)
      continue;

    // now we actually do the match. If this row doesn't match, loop again
    if (!(aMatchFunc)(row, aClosure))
      continue;

    if (notify) {
      // What's the URL? We need to know to properly notify our RDF
      // observers.
      mdbYarn yarn;
      err = row->AliasCellYarn(mEnv, kToken_URLColumn, &yarn);
      if (err != 0)
        continue;
      
      const char* startPtr = (const char*) yarn.mYarn_Buf;
      nsCAutoString uri(Substring(startPtr, startPtr+yarn.mYarn_Fill));
      rv = gRDFService->GetResource(uri, getter_AddRefs(resource));
      NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
      if (NS_FAILED(rv))
        continue;
    }
    // Officially cut the row *now*, before notifying any observers:
    // that way, any re-entrant calls won't find the row.
    err = mTable->CutRow(mEnv, row);
    NS_ASSERTION(err == 0, "couldn't cut row");
    if (err != 0)
      continue;
  
    // possibly avoid leakage
    err = row->CutAllColumns(mEnv);
    NS_ASSERTION(err == 0, "couldn't cut all columns");
    // we'll notify regardless of whether we could successfully
    // CutAllColumns or not.
    
    
  }
  
  // Finish the batch.
  err = mTable->EndBatchChangeHint(mEnv, &marker);
  NS_ASSERTION(err == 0, "error ending batch");

  EndUpdateBatch();

  return ( err == 0) ? NS_OK : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::RemoveMatchingRows ( rowMatchCallback  aMatchFunc,
void aClosure,
PRBool  notify 
) [protected]

Remove an observer from this data source.

Here is the caller graph for this function:

remove a page from history

remove a page from history

nsresult nsGlobalHistory::RemovePageInternal ( const char *  aSpec) [protected]
nsresult nsGlobalHistory::RemovePageInternal ( const char *  aSpec) [protected]

Definition at line 864 of file nsGlobalHistory.cpp.

{
  if (!mTable) return NS_ERROR_NOT_INITIALIZED;
  // find the old row, ignore it if we don't have it
  nsCOMPtr<nsIMdbRow> row;
  nsresult rv = FindRow(kToken_URLColumn, aSpec, getter_AddRefs(row));
  if (NS_FAILED(rv)) return NS_OK;

  // remove the row
  mdb_err err = mTable->CutRow(mEnv, row);
  NS_ENSURE_TRUE(err == 0, NS_ERROR_FAILURE);

  // if there are batches in progress, we don't want to notify
  // observers that we're deleting items. the caller promises
  // to handle whatever UI updating is necessary when we're finished.  
  if (!mBatchesInProgress) {
    // get the resource so we can do the notification
    nsCOMPtr<nsIRDFResource> oldRowResource;
    gRDFService->GetResource(nsDependentCString(aSpec), getter_AddRefs(oldRowResource));
    NotifyFindUnassertions(oldRowResource, row);
  }

  // not a fatal error if we can't cut all column
  err = row->CutAllColumns(mEnv);
  NS_ASSERTION(err == 0, "couldn't cut all columns");

  // Sigh. This is pretty bad - if the user selects a bunch of things then
  // hits delete we'll be re-writing history over and over. Still, we will
  // be whacking global history pretty hard after 1.0 so I don't feel too 
  // bad.
  return Commit(kCompressCommit);
}

Here is the call graph for this function:

void nsIBrowserHistory::removePagesFromHost ( in AUTF8String  aHost,
in boolean  aEntireDomain 
) [inherited]

removePagesFromHost Remove all pages from the given host.

If aEntireDomain is true, will assume aHost is a domain, and remove all pages from the entire domain.

void nsIBrowserHistory::removePagesFromHost ( in AUTF8String  aHost,
in boolean  aEntireDomain 
) [inherited]

removePagesFromHost Remove all pages from the given host.

If aEntireDomain is true, will assume aHost is a domain, and remove all pages from the entire domain.

Definition at line 3870 of file nsGlobalHistory.cpp.

{
  PRUint32 length = aQuery->terms.Count();
  PRUint32 i;

  for (i=0; i<length; i++) {
    
    searchTerm *term = (searchTerm*)aQuery->terms[i];

    if (!term->datasource.Equals("history"))
      continue;                 // we only match against history queries
    
    // use callback if it exists
    if (term->match) {
      // queue up some values just in case callback needs it
      // (how would we do this dynamically?)
      matchSearchTerm_t matchSearchTerm = { mEnv, mStore, term, PR_FALSE, 0, this };
      
      if (!term->match(aRow, (void *)&matchSearchTerm))
        return PR_FALSE;
    } else {
      mdb_err err;

      mdb_column property_column;
      nsCAutoString property_name(term->property);
      property_name.Append(char(0));
      
      err = mStore->QueryToken(mEnv, property_name.get(), &property_column);
      if (err != 0) {
        NS_WARNING("Unrecognized column!");
        continue;               // assume we match???
      }
      
      // match the term directly against the column?
      mdbYarn yarn;
      err = aRow->AliasCellYarn(mEnv, property_column, &yarn);
      if (err != 0 || !yarn.mYarn_Buf) return PR_FALSE;

      const char* startPtr;
      PRInt32 yarnLength = yarn.mYarn_Fill;
      nsCAutoString titleStr;
      if (property_column == kToken_NameColumn) {
        AppendUTF16toUTF8(Substring((const PRUnichar*)yarn.mYarn_Buf,
                                    (const PRUnichar*)yarn.mYarn_Buf + yarnLength),
                          titleStr);
        startPtr = titleStr.get();
        yarnLength = titleStr.Length();
      }
      else {
        // account for null strings
        if (yarn.mYarn_Buf)
          startPtr = (const char *)yarn.mYarn_Buf;
        else 
          startPtr = "";
      }
      
      const nsASingleFragmentCString& rowVal =
          Substring(startPtr, startPtr + yarnLength);

      // set up some iterators
      nsASingleFragmentCString::const_iterator start, end;
      rowVal.BeginReading(start);
      rowVal.EndReading(end);
  
      NS_ConvertUCS2toUTF8 utf8Value(term->text);
      
      if (term->method.Equals("is")) {
        if (!utf8Value.Equals(rowVal, nsCaseInsensitiveCStringComparator()))
          return PR_FALSE;
      }

      else if (term->method.Equals("isnot")) {
        if (utf8Value.Equals(rowVal, nsCaseInsensitiveCStringComparator()))
          return PR_FALSE;
      }

      else if (term->method.Equals("contains")) {
        if (!FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()))
          return PR_FALSE;
      }

      else if (term->method.Equals("doesntcontain")) {
        if (FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()))
          return PR_FALSE;
      }

      else if (term->method.Equals("startswith")) {
        // need to make sure that the found string is 
        // at the beginning of the string
        nsACString::const_iterator real_start = start;
        if (!(FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()) &&
              real_start == start))
          return PR_FALSE;
      }

      else if (term->method.Equals("endswith")) {
        // need to make sure that the found string ends
        // at the end of the string
        nsACString::const_iterator real_end = end;
        if (!(RFindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()) &&
              real_end == end))
          return PR_FALSE;
      }

      else {
        NS_WARNING("Unrecognized search method in SearchEnumerator::RowMatches");
        // don't handle other match types like isgreater/etc yet,
        // so assume the match failed and bail
        return PR_FALSE;
      }
      
    }
  }
  
  // we've gone through each term and didn't bail, so they must have
  // all matched!
  return PR_TRUE;
}

Here is the call graph for this function:

PRBool nsGlobalHistory::RowMatches ( nsIMdbRow aRow,
searchQuery aQuery,
PRBool  caseSensitive 
)

Definition at line 3985 of file nsGlobalHistory.cpp.

{
  PRUint32 length = aQuery->terms.Count();
  PRUint32 i;

  for (i=0; i<length; i++) {
    
    searchTerm *term = (searchTerm*)aQuery->terms[i];

    if (!term->datasource.Equals("history"))
      continue;                 // we only match against history queries
    
    // use callback if it exists
    if (term->match) {
      // queue up some values just in case callback needs it
      // (how would we do this dynamically?)
      matchSearchTerm_t matchSearchTerm = { mEnv, mStore, term , PR_FALSE};
      
      if (!term->match(aRow, (void *)&matchSearchTerm))
        return PR_FALSE;
    } else {
      mdb_err err;

      mdb_column property_column;
      nsCAutoString property_name(term->property);
      property_name.Append(char(0));
      
      err = mStore->QueryToken(mEnv, property_name.get(), &property_column);
      if (err != 0) {
        NS_WARNING("Unrecognized column!");
        continue;               // assume we match???
      }
      
      // match the term directly against the column?
      mdbYarn yarn;
      err = aRow->AliasCellYarn(mEnv, property_column, &yarn);
      if (err != 0 || !yarn.mYarn_Buf) return PR_FALSE;
      
      nsAutoString rowVal;

      PRInt32 yarnLength = yarn.mYarn_Fill;;
      if (property_column == kToken_NameColumn) {
        // The name column (page title) is stored as UTF-16.
        rowVal.Assign((const PRUnichar*)yarn.mYarn_Buf, yarnLength / 2);
      }
      else {
        // Other columns are stored as UTF-8 and can be null.
        if (yarn.mYarn_Buf)
          rowVal = NS_ConvertUTF8toUTF16((const char*)yarn.mYarn_Buf, yarnLength);
      }
      
      // set up some iterators
      nsString::const_iterator start, end;
      rowVal.BeginReading(start);
      rowVal.EndReading(end);

      const nsXPIDLString& searchText = term->text;
      
      if (term->method.Equals("is")) {
        if (caseSensitive) {
          if (!searchText.Equals(rowVal, nsDefaultStringComparator()))
            return PR_FALSE;
        }
        else {
          if (!searchText.Equals(rowVal, nsCaseInsensitiveStringComparator()))
            return PR_FALSE;
        }
      }

      else if (term->method.Equals("isnot")) {        
        if (caseSensitive) {
          if (searchText.Equals(rowVal, nsDefaultStringComparator()))
            return PR_FALSE;
        }
        else {
          if (searchText.Equals(rowVal, nsCaseInsensitiveStringComparator()))
            return PR_FALSE;
        }
      }

      else if (term->method.Equals("contains")) {
        if (caseSensitive) {
          if (!FindInReadable(searchText, start, end, nsDefaultStringComparator()))
            return PR_FALSE;
        }
        else {
          if (!FindInReadable(searchText, start, end, nsCaseInsensitiveStringComparator()))
            return PR_FALSE;
        }
      }

      else if (term->method.Equals("doesntcontain")) {
        if (caseSensitive) {
          if (FindInReadable(searchText, start, end, nsDefaultStringComparator()))
            return PR_FALSE;
        }
        else {
          if (FindInReadable(searchText, start, end, nsCaseInsensitiveStringComparator()))
            return PR_FALSE;
        }
      }

      else if (term->method.Equals("startswith")) {
        // need to make sure that the found string is 
        // at the beginning of the string
        nsAString::const_iterator real_start = start;
        if (caseSensitive) {
          if (!(FindInReadable(searchText, start, end, nsDefaultStringComparator()) && real_start == start))
            return PR_FALSE;
        }
        else {
          if (!(FindInReadable(searchText, start, end, nsCaseInsensitiveStringComparator()) &&
                real_start == start))
            return PR_FALSE;
        }
      }

      else if (term->method.Equals("endswith")) {
        // need to make sure that the found string ends
        // at the end of the string
        nsAString::const_iterator real_end = end;
        if (caseSensitive) {
          if (!(RFindInReadable(searchText, start, end, nsDefaultStringComparator()) && real_end == end))
            return PR_FALSE;
        }
        else {
          if (!(RFindInReadable(searchText, start, end, nsCaseInsensitiveStringComparator()) &&
                real_end == end))
          return PR_FALSE;
        }
      }

      else {
        NS_WARNING("Unrecognized search method in SearchEnumerator::RowMatches");
        // don't handle other match types like isgreater/etc yet,
        // so assume the match failed and bail
        return PR_FALSE;
      }
      
    }
  }
  
  // we've gone through each term and didn't bail, so they must have
  // all matched!
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::SaveByteOrder ( const char *  aByteOrder) [protected]

Definition at line 1378 of file nsGlobalHistory.cpp.

{
  if (PL_strcmp(aByteOrder, "BE") != 0 && PL_strcmp(aByteOrder, "LE") != 0) {
    NS_WARNING("Invalid byte order argument.");
    return NS_ERROR_INVALID_ARG;
  }
  NS_ENSURE_STATE(mMetaRow);

  mdb_err err = SetRowValue(mMetaRow, kToken_ByteOrder, aByteOrder);
  NS_ENSURE_TRUE(err == 0, NS_ERROR_FAILURE);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::SaveByteOrder ( const char *  aByteOrder) [protected]

Definition at line 1940 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  if (mSyncTimer)
    mSyncTimer->Cancel();

  if (!mSyncTimer) {
    mSyncTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
    if (NS_FAILED(rv)) return rv;
  }
  
  mDirty = PR_TRUE;
  mSyncTimer->InitWithFuncCallback(fireSyncTimer, this, HISTORY_SYNC_TIMEOUT,
                                   nsITimer::TYPE_ONE_SHOT);
  

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIGlobalHistory2::setPageTitle ( in nsIURI  aURI,
in AString  aTitle 
) [inherited]

Set the page title for the given uri.

URIs that are not already in global history will not be added.

Parameters:
aURIthe URI for which to set to the title
aTitlethe page title
nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRTime aValue 
) [protected]
nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRInt32  aValue 
) [protected]
nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const char *  aValue 
) [protected]
nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRUnichar aValue 
) [protected]
nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRTime aValue 
) [protected]

Definition at line 898 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  nsCAutoString val;
  val.AppendInt(aValue);

  mdbYarn yarn = { (void *)val.get(), val.Length(), val.Length(), 0, 0, nsnull };
  
  err = aRow->AddColumn(mEnv, aCol, &yarn);

  if ( err != 0 ) return NS_ERROR_FAILURE;
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRInt32  aValue 
) [protected]

Definition at line 962 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  
  nsCAutoString buf; buf.AppendInt(aValue);
  mdbYarn yarn = { (void *)buf.get(), buf.Length(), buf.Length(), 0, 0, nsnull };

  err = aRow->AddColumn(mEnv, aCol, &yarn);
  
  if (err != 0) return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const char *  aValue 
) [protected]

Definition at line 949 of file nsGlobalHistory.cpp.

{
  mdb_err err;
  PRInt32 len = PL_strlen(aValue);
  mdbYarn yarn = { (void*) aValue, len, len, 0, 0, nsnull };
  err = aRow->AddColumn(mEnv, aCol, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGlobalHistory::SetRowValue ( nsIMdbRow aRow,
mdb_column  aCol,
const PRUnichar aValue 
) [protected]

Definition at line 914 of file nsGlobalHistory.cpp.

{
  mdb_err err;

  PRInt32 len = (nsCRT::strlen(aValue) * sizeof(PRUnichar));
  PRUnichar *swapval = nsnull;

  // eventually turn this on when we're confident in mork's abilitiy
  // to handle yarn forms properly
#if 0
  NS_ConvertUCS2toUTF8 utf8Value(aValue);
  printf("Storing utf8 value %s\n", utf8Value.get());
  mdbYarn yarn = { (void *)utf8Value.get(), utf8Value.Length(), utf8Value.Length(), 0, 1, nsnull };
#else

  if (mReverseByteOrder) {
    // The file is other-endian.  Byte-swap the value.
    swapval = (PRUnichar *)malloc(len);
    if (!swapval)
      return NS_ERROR_OUT_OF_MEMORY;
    SwapBytes(aValue, swapval, len / sizeof(PRUnichar));
    aValue = swapval;
  }
  mdbYarn yarn = { (void *)aValue, len, len, 0, 0, nsnull };
  
#endif
  err = aRow->AddColumn(mEnv, aCol, &yarn);
  if (swapval)
    free(swapval);
  if (err != 0) return NS_ERROR_FAILURE;
  return NS_OK;
}

Here is the call graph for this function:

void nsIAutoCompleteSearch::startSearch ( in AString  searchString,
in AString  searchParam,
in nsIAutoCompleteResult  previousResult,
in nsIAutoCompleteObserver  listener 
) [inherited]
void nsGlobalHistory::SwapBytes ( const PRUnichar source,
PRUnichar dest,
PRInt32  aLen 
) [protected]

Definition at line 1020 of file nsGlobalHistory.cpp.

{
  PRUint16 c;
  const PRUnichar *inp;
  PRUnichar *outp;
  PRInt32 i;

  inp = source;
  outp = dest;
  for (i = 0; i < aLen; i++) {
    c = *inp++;
    *outp++ = (((c >> 8) & 0xff) | (c << 8));
  }
  return;
}

Here is the caller graph for this function:

void nsGlobalHistory::SwapBytes ( const PRUnichar source,
PRUnichar dest,
PRInt32  aLen 
) [protected]
void nsGlobalHistory::Sync ( ) [protected]

Definition at line 1920 of file nsGlobalHistory.cpp.

Here is the call graph for this function:

void nsGlobalHistory::Sync ( ) [protected]

Definition at line 3389 of file nsGlobalHistory.cpp.

{

  PRInt32 i;
  PRInt32 length = aTokens.Count();

  aResult.groupBy = 0;
  const char *datasource=nsnull, *property=nsnull,
    *method=nsnull, *text=nsnull;

  PRUint32 datasourceLen=0, propertyLen=0, methodLen=0, textLen=0;
  rowMatchCallback matchCallback=nsnull; // matching callback if needed
  
  for (i=0; i<length; i++) {
    tokenPair *token = (tokenPair *)aTokens[i];

    // per-term tokens
    const nsASingleFragmentCString& tokenName =
        Substring(token->tokenName, token->tokenName + token->tokenNameLength);
    if (tokenName.EqualsLiteral("datasource")) {
      datasource = token->tokenValue;
      datasourceLen = token->tokenValueLength;
    }
    else if (tokenName.EqualsLiteral("match")) {
      if (Substring(token->tokenValue, token->tokenValue+token->tokenValueLength).Equals("AgeInDays"))
        matchCallback = matchAgeInDaysCallback;
      
      property = token->tokenValue;
      propertyLen = token->tokenValueLength;
    }
    else if (tokenName.EqualsLiteral("method")) {
      method = token->tokenValue;
      methodLen = token->tokenValueLength;
    }    
    else if (tokenName.EqualsLiteral("text")) {
      text = token->tokenValue;
      textLen = token->tokenValueLength;
    }
    
    // really, we should be storing the group-by as a column number or
    // rdf resource
    else if (tokenName.EqualsLiteral("groupby")) {
      mdb_err err;
      err = mStore->QueryToken(mEnv,
                               nsCAutoString(token->tokenValue).get(),
                               &aResult.groupBy);
      if (err != 0)
        aResult.groupBy = 0;
    }
    
    // once we complete a term, we move on to the next one
    if (datasource && property && method && text) {
      searchTerm *currentTerm = new searchTerm(datasource, datasourceLen,
                                               property, propertyLen,
                                               method, methodLen,
                                               text, textLen);
      currentTerm->match = matchCallback;
      
      // append the old one, then create a new one
      aResult.terms.AppendElement((void *)currentTerm);

      // reset our state
      matchCallback=nsnull;
      currentTerm = nsnull;
      datasource = property = method = text = 0;
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFDataSource::Unassert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

Remove an assertion from the graph.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class AutoCompleteEnumerator [friend]

Definition at line 477 of file nsGlobalHistory.h.

SearchEnumerator [friend]

Definition at line 444 of file nsGlobalHistory.h.

URLEnumerator [friend]

Definition at line 443 of file nsGlobalHistory.h.


Member Data Documentation

readonly attribute unsigned long nsIBrowserHistory::count [inherited]

count The number of entries in global history

Definition at line 63 of file nsIBrowserHistory.idl.

count The number of entries in global history

Definition at line 65 of file nsIBrowserHistory.idl.

static nsIMdbFactory * nsGlobalHistory::gMdbFactory = nsnull [static, protected]

Definition at line 376 of file nsGlobalHistory.h.

static nsIPrefBranch * nsGlobalHistory::gPrefBranch = nsnull [static, protected]

Definition at line 377 of file nsGlobalHistory.h.

static nsIRDFService * nsGlobalHistory::gRDFService [static, protected]

Definition at line 359 of file nsGlobalHistory.h.

static PRInt32 nsGlobalHistory::gRefCnt [static, protected]

Definition at line 358 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_AgeInDays [static, protected]

Definition at line 364 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_child [static, protected]

Definition at line 369 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_Date [static, protected]

Definition at line 361 of file nsGlobalHistory.h.

Definition at line 374 of file nsGlobalHistory.h.

Definition at line 362 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_HistoryByDate [static, protected]

Definition at line 372 of file nsGlobalHistory.h.

Definition at line 373 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_HistoryRoot [static, protected]

Definition at line 371 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_Hostname [static, protected]

Definition at line 367 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_Name [static, protected]

Definition at line 365 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_NameSort [static, protected]

Definition at line 366 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_Page [static, protected]

Definition at line 360 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_Referrer [static, protected]

Definition at line 368 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_URL [static, protected]

Definition at line 370 of file nsGlobalHistory.h.

static nsIRDFResource * nsGlobalHistory::kNC_VisitCount [static, protected]

Definition at line 363 of file nsGlobalHistory.h.

Definition at line 299 of file nsGlobalHistory.h.

Definition at line 292 of file nsGlobalHistory.h.

Definition at line 296 of file nsGlobalHistory.h.

Definition at line 287 of file nsGlobalHistory.h.

Definition at line 286 of file nsGlobalHistory.h.

Definition at line 295 of file nsGlobalHistory.h.

Definition at line 301 of file nsGlobalHistory.h.

Definition at line 291 of file nsGlobalHistory.h.

Definition at line 294 of file nsGlobalHistory.h.

Definition at line 290 of file nsGlobalHistory.h.

Definition at line 297 of file nsGlobalHistory.h.

Definition at line 289 of file nsGlobalHistory.h.

Definition at line 293 of file nsGlobalHistory.h.

readonly attribute AUTF8String nsIBrowserHistory::lastPageVisited [inherited]

lastPageVisited The last page that was visited in a top-level window.

Definition at line 59 of file nsIBrowserHistory.idl.

This value is true when the datasource has fully loaded itself.

Definition at line 50 of file nsIRDFRemoteDataSource.idl.

Definition at line 212 of file nsGlobalHistory.h.

Definition at line 242 of file nsGlobalHistory.h.

Definition at line 354 of file nsGlobalHistory.h.

Definition at line 242 of file nsGlobalHistory.h.

Definition at line 255 of file nsGlobalHistory.h.

Definition at line 280 of file nsGlobalHistory.h.

Definition at line 182 of file nsGlobalHistory.h.

Definition at line 244 of file nsGlobalHistory.h.

Definition at line 170 of file nsGlobalHistory.h.

nsStringArray nsGlobalHistory::mIgnoreHostnames [protected]

Definition at line 214 of file nsGlobalHistory.h.

nsStringArray nsGlobalHistory::mIgnoreSchemes [protected]

Definition at line 213 of file nsGlobalHistory.h.

Definition at line 241 of file nsGlobalHistory.h.

Definition at line 284 of file nsGlobalHistory.h.

Definition at line 243 of file nsGlobalHistory.h.

Definition at line 267 of file nsGlobalHistory.h.

Definition at line 340 of file nsGlobalHistory.h.

Definition at line 281 of file nsGlobalHistory.h.

Definition at line 256 of file nsGlobalHistory.h.

Definition at line 282 of file nsGlobalHistory.h.

nsCStringHashSet nsGlobalHistory::mTypedHiddenURIs [protected]

Definition at line 304 of file nsGlobalHistory.h.

readonly attribute string nsIRDFDataSource::URI [inherited]

The "URI" of the data source.

This used by the RDF service's |GetDataSource()| method to cache datasources.

Definition at line 56 of file nsIRDFDataSource.idl.


The documentation for this class was generated from the following files: