Bug 1350798 - Ignore v4 completion too early will cause telemetry::URLCLASSIFIER_MATCH_RESULT gets wrong results. r=francois

Enable safebrowsing v4 completion but ignore the result by checking preference in
nsUrlClassifierLookupCallback::Completion may cause telemetry measure incorrect match
result since v4 completions will always be ignored.

So in this patch we move the preference check after telemetry is measured and then we
ignore the result.

MozReview-Commit-ID: J29JitvW3Lc

--HG--
extra : rebase_source : 0cf8797de476980ce25d83099e6526321308327c
This commit is contained in:
dimi 2017-03-28 09:09:57 +08:00
parent 9fa41c62a2
commit 229fe1f890

View File

@ -894,7 +894,10 @@ nsUrlClassifierDBServiceWorker::CacheCompletions(CacheResultArray *results)
TableUpdateV2* tuV2 = TableUpdate::Cast<TableUpdateV2>( TableUpdateV2* tuV2 = TableUpdate::Cast<TableUpdateV2>(
pParse->GetTableUpdate(resultsPtr->ElementAt(i).table)); pParse->GetTableUpdate(resultsPtr->ElementAt(i).table));
NS_ENSURE_TRUE(tuV2, NS_ERROR_FAILURE); // Ignore V4 for now.
if (!tuV2) {
continue;
}
LOG(("CacheCompletion Addchunk %d hash %X", resultsPtr->ElementAt(i).entry.addChunk, LOG(("CacheCompletion Addchunk %d hash %X", resultsPtr->ElementAt(i).entry.addChunk,
resultsPtr->ElementAt(i).entry.ToUint32())); resultsPtr->ElementAt(i).entry.ToUint32()));
@ -1136,14 +1139,6 @@ nsUrlClassifierLookupCallback::Completion(const nsACString& completeHash,
LOG(("nsUrlClassifierLookupCallback::Completion [%p, %s, %d]", LOG(("nsUrlClassifierLookupCallback::Completion [%p, %s, %d]",
this, PromiseFlatCString(tableName).get(), chunkId)); this, PromiseFlatCString(tableName).get(), chunkId));
if (StringEndsWith(tableName, NS_LITERAL_CSTRING("-proto")) &&
!Preferences::GetBool(TAKE_V4_COMPLETION_RESULT_PREF,
TAKE_V4_COMPLETION_RESULT_DEFAULT)) {
// Bug 1331534 - We temporarily ignore hash completion result
// for v4 tables.
return NS_OK;
}
mozilla::safebrowsing::Completion hash; mozilla::safebrowsing::Completion hash;
hash.Assign(completeHash); hash.Assign(completeHash);
@ -1252,6 +1247,14 @@ nsUrlClassifierLookupCallback::HandleResults()
continue; continue;
} }
if (StringEndsWith(result.mTableName, NS_LITERAL_CSTRING("-proto")) &&
!Preferences::GetBool(TAKE_V4_COMPLETION_RESULT_PREF,
TAKE_V4_COMPLETION_RESULT_DEFAULT)) {
// Bug 1331534 - We temporarily ignore hash completion result
// for v4 tables.
continue;
}
LOG(("Confirmed result %s from table %s", LOG(("Confirmed result %s from table %s",
result.PartialHashHex().get(), result.mTableName.get())); result.PartialHashHex().get(), result.mTableName.get()));