Bug 1323953 - Send 4-byte prefix for both v2/v4 tables. r=francois draft
authorHenry Chang <hchang@mozilla.com>
Tue, 07 Feb 2017 10:56:12 +0800
changeset 479701 94ca2da38a7aeae061a37cb9013b45dfefbcc843
parent 479700 955dd973d5b7ed2426e87e805a080902d7098e3d
child 544746 187fa6e031cb60cb333ebd526490b0b0fbbedb3a
push id44322
push userhchang@mozilla.com
push dateTue, 07 Feb 2017 02:58:23 +0000
reviewersfrancois
bugs1323953
milestone54.0a1
Bug 1323953 - Send 4-byte prefix for both v2/v4 tables. r=francois MozReview-Commit-ID: 1jlBdSQARNg
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -991,30 +991,21 @@ nsUrlClassifierLookupCallback::LookupCom
       // we may have found a prefix in an existing table before the listmanager
       // has registered the table. In the second case we should not call
       // complete.
       if ((!gethashUrl.IsEmpty() ||
            StringBeginsWith(result.mTableName, NS_LITERAL_CSTRING("test"))) &&
           mDBService->GetCompleter(result.mTableName,
                                    getter_AddRefs(completer))) {
 
-        // TODO: Figure out how long the partial hash should be sent
-        //       for completion. See Bug 1323953.
+        // Bug 1323953 - Send the first 4 bytes for completion no matter how
+        // long we matched the prefix.
         nsAutoCString partialHash;
-        if (StringEndsWith(result.mTableName, NS_LITERAL_CSTRING("-proto"))) {
-          // We send the complete partial hash for v4 at the moment.
-          partialHash = result.PartialHash();
-        } else {
-          // We always send the first 4 bytes of the partial hash for
-          // non-v4 tables. This matters when we have 32-byte prefix
-          // in "test-xxx-simple" test data.
-          partialHash.Assign(reinterpret_cast<char*>(&result.hash.fixedLengthPrefix),
-                             PREFIX_SIZE);
-        }
-
+        partialHash.Assign(reinterpret_cast<char*>(&result.hash.fixedLengthPrefix),
+                           PREFIX_SIZE);
         nsresult rv = completer->Complete(partialHash,
                                           gethashUrl,
                                           result.mTableName,
                                           this);
         if (NS_SUCCEEDED(rv)) {
           mPendingCompletions++;
         }
       } else {