From 42d74904893b0d08f5ee62f96df6912972a062e6 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 8 Jun 2020 06:57:23 +0000 Subject: [PATCH] Bug 1640091 - Make sure we TRRServiceChannel::mProxyRequest is initialized and used r=kershaw,necko-reviewers Differential Revision: https://phabricator.services.mozilla.com/D78525 --- netwerk/ipc/ProxyConfigLookup.cpp | 10 +++++++--- netwerk/ipc/ProxyConfigLookup.h | 5 +++-- netwerk/protocol/http/TRRServiceChannel.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/netwerk/ipc/ProxyConfigLookup.cpp b/netwerk/ipc/ProxyConfigLookup.cpp index 5f96db5b7b7b..2dc2f8704ace 100644 --- a/netwerk/ipc/ProxyConfigLookup.cpp +++ b/netwerk/ipc/ProxyConfigLookup.cpp @@ -20,12 +20,12 @@ namespace net { // static nsresult ProxyConfigLookup::Create( std::function&& aCallback, nsIURI* aURI, - uint32_t aProxyResolveFlags) { + uint32_t aProxyResolveFlags, nsICancelable** aLookupCancellable) { MOZ_ASSERT(NS_IsMainThread()); RefPtr lookUp = new ProxyConfigLookup(std::move(aCallback), aURI, aProxyResolveFlags); - return lookUp->DoProxyResolve(); + return lookUp->DoProxyResolve(aLookupCancellable); } ProxyConfigLookup::ProxyConfigLookup( @@ -37,7 +37,7 @@ ProxyConfigLookup::ProxyConfigLookup( ProxyConfigLookup::~ProxyConfigLookup() = default; -nsresult ProxyConfigLookup::DoProxyResolve() { +nsresult ProxyConfigLookup::DoProxyResolve(nsICancelable** aLookupCancellable) { if (!XRE_IsParentProcess()) { RefPtr self = this; bool result = ProxyConfigLookupChild::Create( @@ -77,6 +77,10 @@ nsresult ProxyConfigLookup::DoProxyResolve() { getter_AddRefs(proxyRequest)); } + if (aLookupCancellable) { + proxyRequest.forget(aLookupCancellable); + } + return rv; } diff --git a/netwerk/ipc/ProxyConfigLookup.h b/netwerk/ipc/ProxyConfigLookup.h index 5b53a67df296..da935c9028a1 100644 --- a/netwerk/ipc/ProxyConfigLookup.h +++ b/netwerk/ipc/ProxyConfigLookup.h @@ -22,14 +22,15 @@ class ProxyConfigLookup final : public nsIProtocolProxyCallback { static nsresult Create( std::function&& aCallback, nsIURI* aURI, - uint32_t aProxyResolveFlags); + uint32_t aProxyResolveFlags, + nsICancelable** aLookupCancellable = nullptr); private: explicit ProxyConfigLookup( std::function&& aCallback, nsIURI* aURI, uint32_t aProxyResolveFlags); virtual ~ProxyConfigLookup(); - nsresult DoProxyResolve(); + nsresult DoProxyResolve(nsICancelable** aLookupCancellable); std::function mCallback; nsCOMPtr mURI; diff --git a/netwerk/protocol/http/TRRServiceChannel.cpp b/netwerk/protocol/http/TRRServiceChannel.cpp index 7acc66a8afef..6d5106c4170d 100644 --- a/netwerk/protocol/http/TRRServiceChannel.cpp +++ b/netwerk/protocol/http/TRRServiceChannel.cpp @@ -252,7 +252,7 @@ nsresult TRRServiceChannel::ResolveProxy() { [self](nsIProxyInfo* aProxyInfo, nsresult aStatus) { self->OnProxyAvailable(nullptr, nullptr, aProxyInfo, aStatus); }, - mURI, mProxyResolveFlags); + mURI, mProxyResolveFlags, getter_AddRefs(mProxyRequest)); if (NS_FAILED(rv)) { if (!mCurrentEventTarget->IsOnCurrentThread()) {