Bug 1599379 - Create a DBService instance in GetWorker API when it doesn't exist. r=baku
☠☠ backed out by 3a7b90a6ba2c ☠ ☠
authorDimi Lee <dlee@mozilla.com>
Mon, 02 Dec 2019 08:51:12 +0000
changeset 504828 ecc4010a247c0f439bf01b33644d822956f16028
parent 504827 658c457c7572fbfd07b7cfd6af4fce8908804f1b
child 504829 d7b5314e7c8d76a187e66846136d8871b7c0620c
push id101982
push userdlee@mozilla.com
push dateMon, 02 Dec 2019 11:01:28 +0000
treeherderautoland@ecc4010a247c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1599379
milestone72.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 1599379 - Create a DBService instance in GetWorker API when it doesn't exist. r=baku There are two places using DBService during a page load at startup: 1. nsChannelClassifier::Start, used by Phishing Protection 2. AsyncChannelClassifier::CheckChannel, used by Tracking Protection Tracking protection checks happen before establishing a network connection, so it happens prior to phishing protection checkes. When we load a page at startup, ::CheckChannel API is called, but DBService is not yet created. This patch fixes this issue by creating a DBService instance when ::GetWorker API is called without a DBService instance. Differential Revision: https://phabricator.services.mozilla.com/D55248
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -2397,21 +2397,24 @@ nsIThread* nsUrlClassifierDBService::Bac
 
 // static
 bool nsUrlClassifierDBService::ShutdownHasStarted() {
   return gShuttingDownThread;
 }
 
 // static
 nsUrlClassifierDBServiceWorker* nsUrlClassifierDBService::GetWorker() {
-  if (!sUrlClassifierDBService) {
+  nsresult rv;
+  RefPtr<nsUrlClassifierDBService> service =
+      nsUrlClassifierDBService::GetInstance(&rv);
+  if (!inst) {
     return nullptr;
   }
 
-  return sUrlClassifierDBService->mWorker;
+  return service->mWorker;
 }
 
 NS_IMETHODIMP
 nsUrlClassifierDBService::AsyncClassifyLocalWithFeatures(
     nsIURI* aURI, const nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures,
     nsIUrlClassifierFeature::listType aListType,
     nsIUrlClassifierFeatureCallback* aCallback) {
   MOZ_ASSERT(NS_IsMainThread());