Bug 820283 - Only accept cached Completes if we still have the corresponding Prefix. r=dcamp, a=akeybl
☠☠ backed out by 878ffb3da483 ☠ ☠
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Thu, 20 Dec 2012 16:56:25 -0800
changeset 117777 f4467b37dfef0ab3dcb31622943e2774affdfb00
parent 117776 a3e6bd7f973610b06ef3ccaf39ccbd4cd2cc3992
child 117778 878ffb3da483162cdbce59faeb12acaf0b1c306c
push id75
push userdbaron@mozilla.com
push dateSat, 22 Dec 2012 00:41:31 +0000
reviewersdcamp, akeybl
bugs820283
milestone18.0
Bug 820283 - Only accept cached Completes if we still have the corresponding Prefix. r=dcamp, a=akeybl
toolkit/components/url-classifier/LookupCache.cpp
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ b/toolkit/components/url-classifier/LookupCache.cpp
@@ -194,24 +194,16 @@ nsresult
 LookupCache::Has(const Completion& aCompletion,
                  const Completion& aHostkey,
                  const uint32_t aHashKey,
                  bool* aHas, bool* aComplete,
                  Prefix* aOrigPrefix)
 {
   *aHas = *aComplete = false;
 
-  // check completion store first
-  if (mCompletions.BinaryIndexOf(aCompletion) != nsTArray<Completion>::NoIndex) {
-    LOG(("Complete in %s", mTableName.get()));
-    *aComplete = true;
-    *aHas = true;
-    return NS_OK;
-  }
-
   uint32_t prefix = aCompletion.ToUint32();
   uint32_t hostkey = aHostkey.ToUint32();
   uint32_t codedkey;
   nsresult rv = KeyedHash(prefix, hostkey, aHashKey, &codedkey, !mPerClientRandomize);
   NS_ENSURE_SUCCESS(rv, rv);
 
   Prefix codedPrefix;
   codedPrefix.FromUint32(codedkey);
@@ -220,16 +212,21 @@ LookupCache::Has(const Completion& aComp
   bool found;
   rv = mPrefixSet->Contains(codedkey, &found);
   NS_ENSURE_SUCCESS(rv, rv);
 
   LOG(("Probe in %s: %X, found %d", mTableName.get(), prefix, found));
 
   if (found) {
     *aHas = true;
+    // check completion store
+    if (mCompletions.BinaryIndexOf(aCompletion) != nsTArray<Completion>::NoIndex) {
+      LOG(("Complete in %s", mTableName.get()));
+      *aComplete = true;
+    }
   }
 
   return NS_OK;
 }
 
 nsresult
 LookupCache::WriteFile()
 {