Bug 1442486 - Mark LookupCacheV4 as primed after creating it. r=gcp

RegenActiveTables() relies on mPrimed being set correctly and so
the V4 lookup cache should behave the same way as the V2 one.

The V2 lookup cache on the other hand was unnecessarily setting
mPrimed to true twice.

MozReview-Commit-ID: LwNdI9DTqZ7

--HG--
extra : rebase_source : ff7d7a051f28867be5c35c1079407bb2bfd3a490
This commit is contained in:
Francois Marier 2018-03-01 18:09:58 -08:00
parent 77637dd978
commit 7d4feeefa4
4 changed files with 24 additions and 3 deletions

View File

@ -932,10 +932,12 @@ Classifier::RegenActiveTables()
LookupCache *lookupCache = GetLookupCache(table);
if (!lookupCache) {
LOG(("Inactive table (no cache): %s", table.get()));
continue;
}
if (!lookupCache->IsPrimed()) {
LOG(("Inactive table (cache not primed): %s", table.get()));
continue;
}

View File

@ -630,7 +630,6 @@ LookupCacheV2::Build(AddPrefixArray& aAddPrefixes,
nsresult rv = ConstructPrefixSet(aAddPrefixes);
NS_ENSURE_SUCCESS(rv, rv);
mPrimed = true;
return NS_OK;
}

View File

@ -129,12 +129,21 @@ LookupCacheV4::Build(PrefixStringMap& aPrefixMap)
{
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_VLPS_CONSTRUCT_TIME> timer;
return mVLPrefixSet->SetPrefixes(aPrefixMap);
nsresult rv = mVLPrefixSet->SetPrefixes(aPrefixMap);
NS_ENSURE_SUCCESS(rv, rv);
mPrimed = true;
return rv;
}
nsresult
LookupCacheV4::GetPrefixes(PrefixStringMap& aPrefixMap)
{
if (!mPrimed) {
// This can happen if its a new table, so no error.
LOG(("GetPrefixes from empty LookupCache"));
return NS_OK;
}
return mVLPrefixSet->GetPrefixes(aPrefixMap);
}

View File

@ -865,6 +865,16 @@ nsUrlClassifierDBServiceWorker::CacheCompletions(CacheResultArray *results)
nsTArray<nsCString> tables;
nsresult rv = mClassifier->ActiveTables(tables);
NS_ENSURE_SUCCESS(rv, rv);
if (LOG_ENABLED()) {
nsCString s;
for (size_t i=0; i < tables.Length(); i++) {
if (!s.IsEmpty()) {
s += ",";
}
s += tables[i];
}
LOG(("Active tables: %s", s.get()));
}
nsTArray<TableUpdate*> updates;
@ -895,7 +905,8 @@ nsUrlClassifierDBServiceWorker::CacheCompletions(CacheResultArray *results)
updates.AppendElement(tu);
pParse->ForgetTableUpdates();
} else {
LOG(("Completion received, but table is not active, so not caching."));
LOG(("Completion received, but table %s is not active, so not caching.",
result->table.get()));
}
}