Bug 1505931 - URL-Classifier should consider all the prefs, r=francois
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 01 Dec 2018 13:04:20 +0100
changeset 505560 fe5c160d056e25d10c63e2c9200e2a9e0a3db596
parent 505559 f94594ae2fc11fb937adcb27b098b5f19b773fd1
child 505561 c466f72acdec9998b647307d582e52bb46454ab6
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1505931
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505931 - URL-Classifier should consider all the prefs, r=francois
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1752,37 +1752,43 @@ nsUrlClassifierDBService::AsyncClassifyL
   }
 
   // Let's see if we have special entries set by prefs.
   if (!aExtraEntriesByPrefs.IsEmpty()) {
     nsAutoCString host;
     rv = uri->GetHost(host);
     NS_ENSURE_SUCCESS(rv, rv);
 
+    nsAutoCString tables;
     for (uint32_t i = 0; i < aExtraEntriesByPrefs.Length(); ++i) {
       nsTArray<nsCString> entries;
       Classifier::SplitTables(aExtraEntriesByPrefs[i], entries);
 
       if (entries.Contains(host)) {
-        nsCString table = aExtraTablesByPrefs[i];
-        nsCOMPtr<nsIURIClassifierCallback> callback(aCallback);
-        nsCOMPtr<nsIRunnable> cbRunnable = NS_NewRunnableFunction(
-            "nsUrlClassifierDBService::AsyncClassifyLocalWithTables",
-            [callback, table]() -> void {
-              callback->OnClassifyComplete(
-                  NS_OK,  // Not used.
-                  table,
-                  EmptyCString(),   // provider. (Not used)
-                  EmptyCString());  // prefix. (Not used)
-            });
-
-        NS_DispatchToMainThread(cbRunnable);
-        return NS_OK;
+        if (!tables.IsEmpty()) {
+          tables.AppendLiteral(",");
+        }
+        tables.Append(aExtraTablesByPrefs[i]);
       }
     }
+
+    if (!tables.IsEmpty()) {
+      nsCOMPtr<nsIURIClassifierCallback> callback(aCallback);
+      nsCOMPtr<nsIRunnable> cbRunnable = NS_NewRunnableFunction(
+        "nsUrlClassifierDBService::AsyncClassifyLocalWithTables",
+        [callback, tables]() -> void {
+          callback->OnClassifyComplete(NS_OK, // Not used.
+                                       tables,
+                                       EmptyCString(),  // provider. (Not used)
+                                       EmptyCString()); // prefix. (Not used)
+        });
+
+      NS_DispatchToMainThread(cbRunnable);
+      return NS_OK;
+    }
   }
 
   nsAutoCString key;
   // Canonicalize the url
   nsCOMPtr<nsIUrlClassifierUtils> utilsService =
       do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID);
   rv = utilsService->GetKeyForURI(uri, key);
   NS_ENSURE_SUCCESS(rv, rv);