Bug 1321377 - When called from the content process, ClassifyLocalWithTables should return failure instead of causing an IPC error draft
authorKirk Steuber <ksteuber@mozilla.com>
Wed, 30 Nov 2016 10:57:48 -0800
changeset 446035 9cd411a1ca674a1e1f6a64911c60e4a9900722ac
parent 446034 b6bee3064f50ffd261990dd6182bcc8851deb569
child 538685 18953eaab947f293ae59618f6bc6d0cbc575b541
push id37678
push userksteuber@mozilla.com
push dateWed, 30 Nov 2016 19:59:49 +0000
bugs1321377
milestone53.0a1
Bug 1321377 - When called from the content process, ClassifyLocalWithTables should return failure instead of causing an IPC error MozReview-Commit-ID: B1RemxGRSKB
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4806,26 +4806,23 @@ ContentParent::DeallocPURLClassifierPare
 
   RefPtr<URLClassifierParent> actor =
     dont_AddRef(static_cast<URLClassifierParent*>(aActor));
   return true;
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvClassifyLocal(const URIParams& aURI, const nsCString& aTables,
-                                 nsTArray<nsCString>* aResults)
+                                 nsresult *aRv, nsTArray<nsCString>* aResults)
 {
   MOZ_ASSERT(aResults);
   nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
   if (!uri) {
     return IPC_FAIL_NO_REASON(this);
   }
   nsCOMPtr<nsIURIClassifier> uriClassifier =
     do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID);
   if (!uriClassifier) {
     return IPC_FAIL_NO_REASON(this);
   }
-  nsresult rv = uriClassifier->ClassifyLocalWithTables(uri, aTables, *aResults);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return IPC_FAIL(this, "ClassifyLocalWithTables error");
-  }
+  *aRv = uriClassifier->ClassifyLocalWithTables(uri, aTables, *aResults);
   return IPC_OK();
 }
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -555,16 +555,17 @@ public:
                                 const bool& aUseTrackingProtection,
                                 bool* aSuccess) override;
   virtual bool
   DeallocPURLClassifierParent(PURLClassifierParent* aActor) override;
 
   virtual mozilla::ipc::IPCResult
   RecvClassifyLocal(const URIParams& aURI,
                     const nsCString& aTables,
+                    nsresult* aRv,
                     nsTArray<nsCString>* aResults) override;
 
   // Use the PHangMonitor channel to ask the child to repaint a tab.
   void ForceTabPaint(TabParent* aTabParent, uint64_t aLayerObserverEpoch);
 
 protected:
   void OnChannelConnected(int32_t pid) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -799,17 +799,17 @@ parent:
 
     async PPresentation();
 
     async PFlyWebPublishedServer(nsString name, FlyWebPublishOptions params);
 
     sync PURLClassifier(Principal principal, bool useTrackingProtection)
         returns (bool success);
     sync ClassifyLocal(URIParams uri, nsCString tables)
-        returns (nsCString[] results);
+        returns (nsresult rv, nsCString[] results);
 
     // Services remoting
 
     async StartVisitedQuery(URIParams uri);
     async VisitURI(URIParams uri, OptionalURIParams referrer, uint32_t flags);
     async SetURITitle(URIParams uri, nsString title);
 
     async LoadURIExternal(URIParams uri, PBrowser windowContext);
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1512,40 +1512,42 @@ nsUrlClassifierDBService::ClassifyLocalW
                                                   const nsACString& aTables,
                                                   nsTArray<nsCString>& aTableResults)
 {
   MOZ_ASSERT(NS_IsMainThread(), "ClassifyLocalWithTables must be on main thread");
   if (gShuttingDownThread) {
     return NS_ERROR_ABORT;
   }
 
+  nsresult rv;
   if (XRE_IsContentProcess()) {
     using namespace mozilla::dom;
     using namespace mozilla::ipc;
     URIParams uri;
     SerializeURI(aURI, uri);
     nsAutoCString tables(aTables);
     bool result = ContentChild::GetSingleton()->SendClassifyLocal(uri, tables,
+                                                                  &rv,
                                                                   &aTableResults);
     if (result) {
-      return NS_OK;
+      return rv;
     }
     return NS_ERROR_FAILURE;
   }
 
   PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
 
   nsCOMPtr<nsIURI> uri = NS_GetInnermostURI(aURI);
   NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
 
   nsAutoCString key;
   // Canonicalize the url
   nsCOMPtr<nsIUrlClassifierUtils> utilsService =
     do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID);
-  nsresult rv = utilsService->GetKeyForURI(uri, key);
+  rv = utilsService->GetKeyForURI(uri, key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoPtr<LookupResultArray> results(new LookupResultArray());
   if (!results) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // In unittests, we may not have been initalized, so don't crash.