Bug 1321377 - When called from the content process, ClassifyLocalWithTables should return failure instead of causing an IPC error
MozReview-Commit-ID: B1RemxGRSKB
--- 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.