Bug 1328821 - hash completion request for v4 should not depend on table freshness. r=francois,henry
MozReview-Commit-ID: EIjDrnj1I4S
This commit is contained in:
@@ -468,35 +468,33 @@ Classifier::Check(const nsACString& aSpec,
|
||||
|
||||
for (uint32_t i = 0; i < cacheArray.Length(); i++) {
|
||||
LookupCache *cache = cacheArray[i];
|
||||
bool has, complete;
|
||||
bool has, fromCache;
|
||||
uint32_t matchLength;
|
||||
|
||||
rv = cache->Has(lookupHash, &has, &complete, &matchLength);
|
||||
rv = cache->Has(lookupHash, &has, &matchLength, &fromCache);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (has) {
|
||||
LookupResult *result = aResults.AppendElement();
|
||||
if (!result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
int64_t age;
|
||||
bool found = mTableFreshness.Get(cache->TableName(), &age);
|
||||
if (!found) {
|
||||
age = 24 * 60 * 60; // just a large number
|
||||
} else {
|
||||
int64_t now = (PR_Now() / PR_USEC_PER_SEC);
|
||||
age = now - age;
|
||||
// For V2, there is no TTL for caching, so we use table freshness to
|
||||
// decide if matching a completion should trigger a gethash request or not.
|
||||
// For V4, this is done by Positive Caching & Negative Caching mechanism.
|
||||
bool confirmed = false;
|
||||
if (fromCache) {
|
||||
cache->IsHashEntryConfirmed(lookupHash, mTableFreshness,
|
||||
aFreshnessGuarantee, &confirmed);
|
||||
}
|
||||
|
||||
LOG(("Found a result in %s: %s (Age: %Lds)",
|
||||
LOG(("Found a result in %s: %s",
|
||||
cache->TableName().get(),
|
||||
complete ? "complete." : "Not complete.",
|
||||
age));
|
||||
confirmed ? "confirmed." : "Not confirmed."));
|
||||
|
||||
result->hash.complete = lookupHash;
|
||||
result->mComplete = complete;
|
||||
result->mFresh = (age < aFreshnessGuarantee);
|
||||
result->mConfirmed = confirmed;
|
||||
result->mTableName.Assign(cache->TableName());
|
||||
result->mPartialHashLength = matchLength;
|
||||
result->mPartialHashLength = confirmed ? COMPLETE_SIZE : matchLength;
|
||||
|
||||
if (LookupCache::Cast<LookupCacheV4>(cache)) {
|
||||
matchingStatistics |= PrefixMatch::eMatchV4Prefix;
|
||||
|
||||
Reference in New Issue
Block a user