Bug 1041855: Skip gethash completions on startup for hits in existing tables that haven't been registered yet (r=gcp)

This commit is contained in:
Monica Chew 2014-07-24 10:58:41 -07:00
parent 88c58d592b
commit eac23f060e

View File

@ -837,14 +837,14 @@ nsUrlClassifierLookupCallback::LookupComplete(nsTArray<LookupResult>* results)
NS_ENSURE_SUCCESS(rv, rv);
rv = listManager->GetGethashUrl(result.mTableName, gethashUrl);
NS_ENSURE_SUCCESS(rv, rv);
if (mDBService->GetCompleter(result.mTableName,
// gethashUrls may be empty in 2 cases: test tables, and on startup where
// we may have found a prefix in an existing table before the listmanager
// has registered the table. In the second case we should not call
// complete.
if ((!gethashUrl.IsEmpty() ||
StringBeginsWith(result.mTableName, NS_LITERAL_CSTRING("test-"))) &&
mDBService->GetCompleter(result.mTableName,
getter_AddRefs(completer))) {
// Only allow empty gethashUrls for test tables if a completer exists.
if (gethashUrl.IsEmpty()) {
MOZ_ASSERT(
StringBeginsWith(result.mTableName, NS_LITERAL_CSTRING("test-")),
"Only test tables may have empty gethash urls");
}
nsAutoCString partialHash;
partialHash.Assign(reinterpret_cast<char*>(&result.hash.prefix),
PREFIX_SIZE);