Bug 1599379 - Create a DBService instance in GetWorker API when it doesn't exist. r=baku
authorDimi Lee <dlee@mozilla.com>
Mon, 02 Dec 2019 14:37:25 +0000
changeset 504843 42913f0f886d1cf5e9b23440fd0f0d4556bbce1c
parent 504842 7074213657a3908c2805fa75d8dcebb76bc64ea1
child 504844 d8871ccf76bd3c4c9960954aaa70695883aed31b
push id36870
push usernerli@mozilla.com
push dateMon, 02 Dec 2019 18:41:58 +0000
treeherdermozilla-central@bc2e8add2746 [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 (!service) {
     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());