Bug 318653 r=annie.sullivan Add functions for externally creating history/visit entries. (places is not compiled by default)

This commit is contained in:
brettw%gmail.com 2005-12-30 23:23:28 +00:00
Родитель ef4a583e95
Коммит 0e90005c2a
3 изменённых файлов: 113 добавлений и 9 удалений

Просмотреть файл

@ -681,6 +681,45 @@ interface nsINavHistoryService : nsISupports
*/
boolean canAddURI(in nsIURI aURI);
/**
* Call to set the full information for a given page. If the page does not
* exist, it will be added to the database. If it does, the existing values
* WILL BE OVERWRITTEN. This is an updated version of addPageWithDetails
* for backup/restore type operations.
*
* @param aURI Page to add/change.
* @param aTitle Title as specified by the page.
* @param aUserTitle Custom title provided by user. Set to NULL if none.
* @param aVisitCount Number of times this page has been visited. Setting this
* to 0 may make the page invisible in some views.
* @param aHidden Whether the page is hidden. If the page has only
* TRANSITION_EMBED visits, this will be true, otherwise
* false.
* @param aTyped True if this URL has ever been typed.
*/
void setPageDetails(in nsIURI aURI, in AString aTitle, in AString aUserTitle,
in PRUint32 aVisitCount, in boolean aHidden,
in boolean aTyped);
/**
* Call to manually add a visit for a specific page. This will probably not
* be commonly used other than for backup/restore type operations. If the URI
* does not have an entry in the history database already, one will be created
* with no visits, no title, hidden, not typed.
*
* @param aURI Visited page
* @param aTime Time page was visited (microseconds)
* @param aReferrer The ID of the visit that generated this one. Use 0
* for no referrer. This must be a valid visit already
* in the DB or 0.
* @param aTranstitionType Type of transition: one of TRANSITION_* above
* @param aSession The session ID that this page belongs to. Use 0 for
* no session.
* @returns The ID of the created visit
*/
PRInt64 addVisit(in nsIURI aURI, in PRTime aTime, in PRInt64 aReferrer,
in PRInt32 aTransitionType, in PRInt64 aSession);
/**
* This returns a new query object that you can pass to executeQuer[y/ies].
* It will be initialized to all empty (so using it will give you all history).

Просмотреть файл

@ -698,8 +698,8 @@ nsNavHistory::InternalAdd(nsIURI* aURI, nsIURI* aReferrer, PRInt64 aSessionID,
}
PRInt64 visitID, referringID;
rv = AddVisit(aReferrer, pageID, aVisitDate, aTransitionType,
&visitID, &referringID);
rv = InternalAddVisit(aReferrer, pageID, aVisitDate, aTransitionType,
&visitID, &referringID);
if (aPageID)
*aPageID = pageID;
@ -795,7 +795,7 @@ nsNavHistory::InternalAddNewPage(nsIURI* aURI, const PRUnichar* aTitle,
}
// nsNavHistory::AddVisit
// nsNavHistory::InternalAddVisit
//
// Just a wrapper for inserting a new visit in the DB.
//
@ -809,9 +809,9 @@ nsNavHistory::InternalAddNewPage(nsIURI* aURI, const PRUnichar* aTitle,
// The visit ID of the referrer that this function computes will be put
// into referringID.
nsresult nsNavHistory::AddVisit(nsIURI* aReferrer, PRInt64 aPageID,
PRTime aTime, PRInt32 aTransitionType,
PRInt64* visitID, PRInt64 *referringID)
nsresult nsNavHistory::InternalAddVisit(nsIURI* aReferrer, PRInt64 aPageID,
PRTime aTime, PRInt32 aTransitionType,
PRInt64* visitID, PRInt64 *referringID)
{
nsresult rv;
PRInt64 fromStep = 0;
@ -1184,6 +1184,71 @@ nsNavHistory::CanAddURI(nsIURI* aURI, PRBool* canAdd)
}
// nsNavHistory::SetPageDetails
NS_IMETHODIMP
nsNavHistory::SetPageDetails(nsIURI* aURI, const nsAString& aTitle,
const nsAString& aUserTitle, PRUint32 aVisitCount,
PRBool aHidden, PRBool aTyped)
{
// look up the page ID, creating a new one if necessary
PRInt64 pageID;
nsresult rv = GetUrlIdFor(aURI, &pageID, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<mozIStorageStatement> statement;
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
"UPDATE moz_history "
"SET title = ?2, "
"user_title = ?3, "
"visit_count = ?4, "
"hidden = ?5, "
"typed = ?6 "
"WHERE id = ?1"),
getter_AddRefs(statement));
NS_ENSURE_SUCCESS(rv, rv);
rv = statement->BindInt64Parameter(0, pageID);
NS_ENSURE_SUCCESS(rv, rv);
statement->BindStringParameter(1, aTitle);
NS_ENSURE_SUCCESS(rv, rv);
statement->BindStringParameter(2, aUserTitle);
NS_ENSURE_SUCCESS(rv, rv);
statement->BindInt32Parameter(3, aVisitCount);
NS_ENSURE_SUCCESS(rv, rv);
statement->BindInt32Parameter(4, aHidden ? 1 : 0);
NS_ENSURE_SUCCESS(rv, rv);
statement->BindInt32Parameter(5, aTyped ? 1 : 0);
NS_ENSURE_SUCCESS(rv, rv);
rv = statement->Execute();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// nsNavHistory::AddVisit
NS_IMETHODIMP
nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, PRInt64 aReferrer,
PRInt32 aTransitionType, PRInt64 aSession,
PRInt64* aVisitID)
{
// look up the page ID
PRInt64 pageID;
nsresult rv = GetUrlIdFor(aURI, &pageID, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
// FIXME(brettw) we ignore the referrer ID, this should be hooked up. (This
// is pending a redo of the way sessions and referrers are handled coming
// from the docshell that will necessitate a rework of all of the visit
// creation code.)
PRInt64 referringID; // don't care about this
return InternalAddVisit(nsnull, pageID, aTime, aTransitionType, aVisitID,
&referringID);
}
// nsNavHistory::GetNewQuery
NS_IMETHODIMP nsNavHistory::GetNewQuery(nsINavHistoryQuery **_retval)

Просмотреть файл

@ -265,9 +265,9 @@ protected:
nsresult InternalAddNewPage(nsIURI* aURI, const PRUnichar* aTitle,
PRBool aHidden, PRBool aTyped,
PRInt32 aVisitCount, PRInt64* aPageID);
nsresult AddVisit(nsIURI* aReferrer, PRInt64 aPageID, PRTime aTime,
PRInt32 aTransitionType, PRInt64* aVisitID,
PRInt64* aReferringID);
nsresult InternalAddVisit(nsIURI* aReferrer, PRInt64 aPageID, PRTime aTime,
PRInt32 aTransitionType, PRInt64* aVisitID,
PRInt64* aReferringID);
PRBool IsURIStringVisited(const nsACString& url);
nsresult VacuumDB(PRTime aTimeAgo, PRBool aCompress);
nsresult LoadPrefs();