Bug 1041855 - Skip gethash completions on startup for hits in existing tables that haven't been registered yet. r=gcp, a=sledru
authorMonica Chew <mmc@mozilla.com>
Thu, 24 Jul 2014 10:58:41 -0700
changeset 217333 898849f4927785445181cafafaf6286e35caa959
parent 217332 0c070c30cde4dffc7a4a806074ede73c8247eccd
child 217334 2a4ae7cd64a170889c1f8b5bc0a419555e712d85
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp, sledru
bugs1041855
milestone33.0a2
Bug 1041855 - Skip gethash completions on startup for hits in existing tables that haven't been registered yet. r=gcp, a=sledru
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -832,24 +832,24 @@ nsUrlClassifierLookupCallback::LookupCom
       nsCOMPtr<nsIUrlClassifierHashCompleter> completer;
       nsCString gethashUrl;
       nsresult rv;
       nsCOMPtr<nsIUrlListManager> listManager = do_GetService(
         "@mozilla.org/url-classifier/listmanager;1", &rv);
       NS_ENSURE_SUCCESS(rv, rv);
       rv = listManager->GetGethashUrl(result.mTableName, gethashUrl);
       NS_ENSURE_SUCCESS(rv, rv);
-      if (mDBService->GetCompleter(result.mTableName,
+      // gethashUrls may be empty in 2 cases: test tables, and on startup where
+      // 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))) {
-        // Only allow empty gethashUrls for test tables if a completer exists.
-        if (gethashUrl.IsEmpty()) {
-          MOZ_ASSERT(
-            StringBeginsWith(result.mTableName, NS_LITERAL_CSTRING("test-")),
-            "Only test tables may have empty gethash urls");
-        }
         nsAutoCString partialHash;
         partialHash.Assign(reinterpret_cast<char*>(&result.hash.prefix),
                            PREFIX_SIZE);
 
         nsresult rv = completer->Complete(partialHash, gethashUrl, this);
         if (NS_SUCCEEDED(rv)) {
           mPendingCompletions++;
         }