mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 459786 - lazily get mDBVisitTo[Visit|URL]Result
r=dietrich
This commit is contained in:
parent
09427291bc
commit
2452632409
@ -1195,56 +1195,6 @@ nsNavHistory::InitStatements()
|
||||
getter_AddRefs(mDBAddNewPage));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// mDBVisitToURLResult, should match kGetInfoIndex_* (see GetQueryResults)
|
||||
// We are not checking for duplicated ids into the unified table
|
||||
// for perf reasons, LIMIT 1 will discard duplicates faster since we
|
||||
// have unique visit ids.
|
||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
SQL_STR_FRAGMENT_MAX_VISIT_DATE( "h.id" )
|
||||
", f.url, null, null "
|
||||
"FROM moz_places_temp h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"UNION ALL "
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
SQL_STR_FRAGMENT_MAX_VISIT_DATE( "h.id" )
|
||||
", f.url, null, null "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"LIMIT 1"),
|
||||
getter_AddRefs(mDBVisitToURLResult));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// mDBVisitToVisitResult, should match kGetInfoIndex_* (see GetQueryResults)
|
||||
// We are not checking for duplicated ids into the unified table
|
||||
// for perf reasons, LIMIT 1 will discard duplicates faster since we
|
||||
// have unique visit ids.
|
||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
"v.visit_date, f.url, v.session, null "
|
||||
"FROM moz_places_temp h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"UNION ALL "
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
"v.visit_date, f.url, v.session, null "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"LIMIT 1"),
|
||||
getter_AddRefs(mDBVisitToVisitResult));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// mDBBookmarkToUrlResult, should match kGetInfoIndex_*
|
||||
// We are not checking for duplicated ids into the unified table
|
||||
// for perf reasons, LIMIT 1 will discard duplicates faster since we
|
||||
@ -6479,12 +6429,12 @@ nsNavHistory::VisitIdToResultNode(PRInt64 visitId,
|
||||
case nsNavHistoryQueryOptions::RESULTS_AS_VISIT:
|
||||
case nsNavHistoryQueryOptions::RESULTS_AS_FULL_VISIT:
|
||||
// visit query - want exact visit time
|
||||
statement = mDBVisitToVisitResult;
|
||||
statement = GetDBVisitToVisitResult();
|
||||
break;
|
||||
|
||||
case nsNavHistoryQueryOptions::RESULTS_AS_URI:
|
||||
// URL results - want last visit time
|
||||
statement = mDBVisitToURLResult;
|
||||
statement = GetDBVisitToURLResult();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -6492,6 +6442,7 @@ nsNavHistory::VisitIdToResultNode(PRInt64 visitId,
|
||||
// by registering their own observers when they are expanded.
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ENSURE_TRUE(statement, NS_ERROR_UNEXPECTED);
|
||||
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
nsresult rv = statement->BindInt64Parameter(0, visitId);
|
||||
@ -7383,6 +7334,74 @@ nsNavHistory::GetBundle()
|
||||
return mBundle;
|
||||
}
|
||||
|
||||
mozIStorageStatement *
|
||||
nsNavHistory::GetDBVisitToVisitResult()
|
||||
{
|
||||
if (mDBVisitToVisitResult)
|
||||
return mDBVisitToVisitResult;
|
||||
|
||||
// mDBVisitToVisitResult, should match kGetInfoIndex_* (see GetQueryResults)
|
||||
// We are not checking for duplicated ids into the unified table
|
||||
// for perf reasons, LIMIT 1 will discard duplicates faster since we
|
||||
// have unique visit ids.
|
||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
"v.visit_date, f.url, v.session, null "
|
||||
"FROM moz_places_temp h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"UNION ALL "
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
"v.visit_date, f.url, v.session, null "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"LIMIT 1"),
|
||||
getter_AddRefs(mDBVisitToVisitResult));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
return mDBVisitToVisitResult;
|
||||
}
|
||||
|
||||
mozIStorageStatement *
|
||||
nsNavHistory::GetDBVisitToURLResult()
|
||||
{
|
||||
if (mDBVisitToURLResult)
|
||||
return mDBVisitToURLResult;
|
||||
|
||||
// mDBVisitToURLResult, should match kGetInfoIndex_* (see GetQueryResults)
|
||||
// We are not checking for duplicated ids into the unified table
|
||||
// for perf reasons, LIMIT 1 will discard duplicates faster since we
|
||||
// have unique visit ids.
|
||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
SQL_STR_FRAGMENT_MAX_VISIT_DATE( "h.id" )
|
||||
", f.url, null, null "
|
||||
"FROM moz_places_temp h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"UNION ALL "
|
||||
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
|
||||
SQL_STR_FRAGMENT_MAX_VISIT_DATE( "h.id" )
|
||||
", f.url, null, null "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
"LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE v.id = ?1 OR v_t.id = ?1 "
|
||||
"LIMIT 1"),
|
||||
getter_AddRefs(mDBVisitToURLResult));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
return mDBVisitToURLResult;
|
||||
}
|
||||
|
||||
// nsICharsetResolver **********************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -431,7 +431,10 @@ protected:
|
||||
nsCOMPtr<mozIStorageStatement> mDBSetPlaceTitle; // used by SetPageTitleInternal
|
||||
|
||||
// these are used by VisitIdToResultNode for making new result nodes from IDs
|
||||
// Consumers need to use the getters since these statements are lazily created
|
||||
mozIStorageStatement *GetDBVisitToURLResult();
|
||||
nsCOMPtr<mozIStorageStatement> mDBVisitToURLResult; // kGetInfoIndex_* results
|
||||
mozIStorageStatement *GetDBVisitToVisitResult();
|
||||
nsCOMPtr<mozIStorageStatement> mDBVisitToVisitResult; // kGetInfoIndex_* results
|
||||
nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user