Bug 1322204 - Fail gracefully when the URL classifier service isn't available because we're in safe mode; r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 08 Dec 2016 10:19:08 -1000
changeset 325465 7849f81b44de6f6b1a83545bdd514f0a73f21c5e
parent 325464 c3d4bcee4905b8d322319d9585e76a148a7b707f
child 325466 8ec6d1a356d132809281b8bd227abbfcc3318904
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1322204
milestone53.0a1
Bug 1322204 - Fail gracefully when the URL classifier service isn't available because we're in safe mode; r=smaug
dom/ipc/URLClassifierParent.cpp
--- a/dom/ipc/URLClassifierParent.cpp
+++ b/dom/ipc/URLClassifierParent.cpp
@@ -13,23 +13,25 @@ using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(URLClassifierParent, nsIURIClassifierCallback)
 
 mozilla::ipc::IPCResult
 URLClassifierParent::StartClassify(nsIPrincipal* aPrincipal,
                                    bool aUseTrackingProtection,
                                    bool* aSuccess)
 {
+  nsresult rv = NS_OK;
+  // Note that in safe mode, the URL classifier service isn't available, so we
+  // should handle the service not being present gracefully.
   nsCOMPtr<nsIURIClassifier> uriClassifier =
-    do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID);
-  if (!uriClassifier) {
-    return IPC_FAIL_NO_REASON(this);
+    do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
+    rv = uriClassifier->Classify(aPrincipal, aUseTrackingProtection,
+                                 this, aSuccess);
   }
-  nsresult rv = uriClassifier->Classify(aPrincipal, aUseTrackingProtection,
-                                        this, aSuccess);
   if (NS_FAILED(rv) || !*aSuccess) {
     // We treat the case where we fail to classify and the case where the
     // classifier returns successfully but doesn't perform a lookup as the
     // classification not yielding any results, so we just kill the child actor
     // without ever calling out callback in both cases.
     // This means that code using this in the child process will only get a hit
     // on its callback if some classification actually happens.
     Unused << Send__delete__(this, void_t());