Bug 1333257 - Only cache V2 misses when doing Safe Browsing lookups. r=francois

MozReview-Commit-ID: 6kvM6z5OnPw
This commit is contained in:
Dimi Lee
2017-01-26 11:36:52 +08:00
parent cc1d4b826e
commit 45dd73df16
3 changed files with 14 additions and 4 deletions

View File

@@ -281,8 +281,12 @@ nsUrlClassifierDBServiceWorker::DoLookup(const nsACString& spec,
nsAutoPtr<LookupResultArray> completes(new LookupResultArray());
for (uint32_t i = 0; i < results->Length(); i++) {
if (!mMissCache.Contains(results->ElementAt(i).hash.fixedLengthPrefix)) {
completes->AppendElement(results->ElementAt(i));
const LookupResult& lookupResult = results->ElementAt(i);
// mMissCache should only be used in V2.
if (!lookupResult.mProtocolV2 ||
!mMissCache.Contains(lookupResult.hash.fixedLengthPrefix)) {
completes->AppendElement(lookupResult);
}
}
@@ -1141,6 +1145,7 @@ nsUrlClassifierLookupCallback::HandleResults()
}
}
// TODO: Bug 1333328, Refactor cache miss mechanism for v2.
// Some parts of this gethash request generated no hits at all.
// Prefixes must have been removed from the database since our last update.
// Save the prefixes we checked to prevent repeated requests
@@ -1149,7 +1154,7 @@ nsUrlClassifierLookupCallback::HandleResults()
if (cacheMisses) {
for (uint32_t i = 0; i < mResults->Length(); i++) {
LookupResult &result = mResults->ElementAt(i);
if (!result.Confirmed() && !result.mNoise) {
if (result.mProtocolV2 && !result.Confirmed() && !result.mNoise) {
cacheMisses->AppendElement(result.hash.fixedLengthPrefix);
}
}