mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 606966 - Need an async history visit API exposed to JS
Part 19 - Fetch the visit information about the right visit, and make sure we have the place id and guid when we need to notify a callback function. r=mak a=blocking
This commit is contained in:
parent
2eb8af4dde
commit
38e7cbc5ce
@ -531,6 +531,15 @@ private:
|
||||
else {
|
||||
rv = mHistory->InsertPlace(aPlace);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We need the place id and guid of the page we just inserted when we
|
||||
// have a callback. No point in doing the disk I/O if we do not need it.
|
||||
if (mCallback) {
|
||||
bool exists = mHistory->FetchPageInfo(aPlace);
|
||||
if (!exists) {
|
||||
NS_NOTREACHED("should have an entry in moz_places");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv = AddVisit(aPlace, aReferrer);
|
||||
@ -560,14 +569,34 @@ private:
|
||||
{
|
||||
NS_PRECONDITION(!_place.spec.IsEmpty(), "must have a non-empty spec!");
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> stmt =
|
||||
mHistory->syncStatements.GetCachedStatement(
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
// If we have a visitTime, we want information on that specific visit.
|
||||
if (_place.visitTime) {
|
||||
stmt = mHistory->syncStatements.GetCachedStatement(
|
||||
"SELECT id, session, visit_date "
|
||||
"FROM moz_historyvisits "
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"AND visit_date = :visit_date "
|
||||
);
|
||||
NS_ENSURE_TRUE(stmt, false);
|
||||
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("visit_date"),
|
||||
_place.visitTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
scoper.Abandon();
|
||||
}
|
||||
// Otherwise, we want information about the most recent visit.
|
||||
else {
|
||||
stmt = mHistory->syncStatements.GetCachedStatement(
|
||||
"SELECT id, session, visit_date "
|
||||
"FROM moz_historyvisits "
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"ORDER BY visit_date DESC "
|
||||
);
|
||||
NS_ENSURE_TRUE(stmt, false);
|
||||
NS_ENSURE_TRUE(stmt, false);
|
||||
}
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
|
||||
nsresult rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"),
|
||||
@ -688,11 +717,8 @@ private:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now that it should be in the database, we need to obtain the id of the
|
||||
// place we just added.
|
||||
bool visited = FetchVisitInfo(_place);
|
||||
if (visited) {
|
||||
NS_NOTREACHED("Not visited after adding a visit!");
|
||||
}
|
||||
// visit we just added.
|
||||
(void)FetchVisitInfo(_place);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user