Bug 1539819 - P2: Introduce PProxyConfigLookup.ipdl for get proxy config in TRRServiceChannel r=dragana
authorKershaw Chang <kershaw@mozilla.com>
Mon, 18 May 2020 20:18:05 +0000
changeset 530704 3c13d25cab1eff31c39c7fa3b121fe58d24f71ca
parent 530703 d23855057df71e5add44e08e507033f4f4c8446b
child 530705 d332f00b2ada23ed72448219d551d37449723144
push id116316
push userkjang@mozilla.com
push dateMon, 18 May 2020 20:28:45 +0000
treeherderautoland@7c84257e93be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1539819
milestone78.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 1539819 - P2: Introduce PProxyConfigLookup.ipdl for get proxy config in TRRServiceChannel r=dragana Differential Revision: https://phabricator.services.mozilla.com/D68398
netwerk/ipc/PProxyConfigLookup.ipdl
netwerk/ipc/PSocketProcess.ipdl
netwerk/ipc/ProxyConfigLookup.cpp
netwerk/ipc/ProxyConfigLookup.h
netwerk/ipc/ProxyConfigLookupChild.cpp
netwerk/ipc/ProxyConfigLookupChild.h
netwerk/ipc/ProxyConfigLookupParent.cpp
netwerk/ipc/ProxyConfigLookupParent.h
netwerk/ipc/SocketProcessParent.cpp
netwerk/ipc/SocketProcessParent.h
netwerk/ipc/moz.build
netwerk/protocol/http/TRRServiceChannel.cpp
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/PProxyConfigLookup.ipdl
@@ -0,0 +1,21 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+include protocol PSocketProcess;
+
+include NeckoChannelParams;
+
+namespace mozilla {
+namespace net {
+
+async refcounted protocol PProxyConfigLookup
+{
+  manager PSocketProcess;
+
+child:
+  async __delete__(ProxyInfoCloneArgs[] aProxyInfo, nsresult aResult);
+};
+
+} // namespace net
+} // namespace mozilla
--- a/netwerk/ipc/PSocketProcess.ipdl
+++ b/netwerk/ipc/PSocketProcess.ipdl
@@ -12,16 +12,17 @@ include protocol PHttpConnectionMgr;
 include protocol PFileDescriptorSet;
 include protocol PChildToParentStream;
 include protocol PParentToChildStream;
 include protocol PInputChannelThrottleQueue;
 include protocol PBackground;
 include protocol PAltService;
 include protocol PAltSvcTransaction;
 include protocol PTRRService;
+include protocol PProxyConfigLookup;
 
 include MemoryReportTypes;
 include NeckoChannelParams;
 include PrefsTypes;
 include PSMIPCTypes;
 
 using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
 using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
@@ -29,16 +30,17 @@ using mozilla::Telemetry::HistogramAccum
 using mozilla::Telemetry::KeyedHistogramAccumulation from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
 using base::ProcessId from "base/process.h";
 using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 using PRTime from "prtime.h";
+using refcounted class nsIURI from "mozilla/ipc/URIUtils.h";
 
 namespace mozilla {
 namespace net {
 
 sync protocol PSocketProcess
 {
   manages PDNSRequest;
   manages PWebrtcTCPSocket;
@@ -46,16 +48,17 @@ sync protocol PSocketProcess
   manages PHttpTransaction;
   manages PHttpConnectionMgr;
   manages PChildToParentStream;
   manages PParentToChildStream;
   manages PInputChannelThrottleQueue;
   manages PAltService;
   manages PAltSvcTransaction;
   manages PTRRService;
+  manages PProxyConfigLookup;
 
 parent:
   async InitCrashReporter(NativeThreadId threadId);
   async AddMemoryReport(MemoryReport aReport);
   async FinishMemoryReport(uint32_t aGeneration);
   // Messages for sending telemetry to parent process.
   async AccumulateChildHistograms(HistogramAccumulation[] accumulations);
   async AccumulateChildKeyedHistograms(KeyedHistogramAccumulation[] accumulations);
@@ -79,16 +82,17 @@ parent:
                         OriginAttributes aOriginAttributes,
                         int32_t aPort,
                         uint32_t aProviderFlags,
                         uint32_t aProviderTlsFlags,
                         ByteArray aServerCert,
                         ByteArray? aClientCert,
                         ByteArray[] aCollectedCANames)
     returns (bool aSucceeded, ByteArray aOutCert, ByteArray aOutKey, ByteArray[] aBuiltChain);
+  async PProxyConfigLookup(nsIURI aUri, uint32_t aFlags);
 
 child:
   async PreferenceUpdate(Pref pref);
   async RequestMemoryReport(uint32_t generation,
                             bool anonymize,
                             bool minimizeMemoryUsage,
                             FileDescriptor? DMDFile);
   async SetOffline(bool offline);
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookup.cpp
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ProxyConfigLookup.h"
+#include "ProxyConfigLookupChild.h"
+#include "mozilla/Unused.h"
+#include "nsContentUtils.h"
+#include "nsICancelable.h"
+#include "nsIProtocolProxyService.h"
+#include "nsIProtocolProxyService2.h"
+#include "nsNetUtil.h"
+#include "nsThreadUtils.h"
+
+namespace mozilla {
+namespace net {
+
+// static
+nsresult ProxyConfigLookup::Create(
+    std::function<void(nsIProxyInfo*, nsresult)>&& aCallback, nsIURI* aURI,
+    uint32_t aProxyResolveFlags) {
+  MOZ_ASSERT(NS_IsMainThread());
+
+  RefPtr<ProxyConfigLookup> lookUp =
+      new ProxyConfigLookup(std::move(aCallback), aURI, aProxyResolveFlags);
+  return lookUp->DoProxyResolve();
+}
+
+ProxyConfigLookup::ProxyConfigLookup(
+    std::function<void(nsIProxyInfo*, nsresult)>&& aCallback, nsIURI* aURI,
+    uint32_t aProxyResolveFlags)
+    : mCallback(std::move(aCallback)),
+      mURI(aURI),
+      mProxyResolveFlags(aProxyResolveFlags) {}
+
+ProxyConfigLookup::~ProxyConfigLookup() = default;
+
+nsresult ProxyConfigLookup::DoProxyResolve() {
+  if (!XRE_IsParentProcess()) {
+    RefPtr<ProxyConfigLookup> self = this;
+    bool result = ProxyConfigLookupChild::Create(
+        mURI, mProxyResolveFlags,
+        [self](nsIProxyInfo* aProxyinfo, nsresult aResult) {
+          self->OnProxyAvailable(nullptr, nullptr, aProxyinfo, aResult);
+        });
+    return result ? NS_OK : NS_ERROR_FAILURE;
+  }
+
+  nsresult rv;
+  nsCOMPtr<nsIChannel> channel;
+  rv = NS_NewChannel(getter_AddRefs(channel), mURI,
+                     nsContentUtils::GetSystemPrincipal(),
+                     nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+                     nsIContentPolicy::TYPE_OTHER);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  nsCOMPtr<nsIProtocolProxyService> pps =
+      do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  // using the nsIProtocolProxyService2 allows a minor performance
+  // optimization, but if an add-on has only provided the original interface
+  // then it is ok to use that version.
+  nsCOMPtr<nsICancelable> proxyRequest;
+  nsCOMPtr<nsIProtocolProxyService2> pps2 = do_QueryInterface(pps);
+  if (pps2) {
+    rv = pps2->AsyncResolve2(channel, mProxyResolveFlags, this, nullptr,
+                             getter_AddRefs(proxyRequest));
+  } else {
+    rv = pps->AsyncResolve(channel, mProxyResolveFlags, this, nullptr,
+                           getter_AddRefs(proxyRequest));
+  }
+
+  return rv;
+}
+
+NS_IMETHODIMP ProxyConfigLookup::OnProxyAvailable(nsICancelable* aRequest,
+                                                  nsIChannel* aChannel,
+                                                  nsIProxyInfo* aProxyinfo,
+                                                  nsresult aResult) {
+  mCallback(aProxyinfo, aResult);
+  return NS_OK;
+}
+
+NS_IMPL_ISUPPORTS(ProxyConfigLookup, nsIProtocolProxyCallback)
+
+}  // namespace net
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookup.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_net_ProxyConfigLookup_h
+#define mozilla_net_ProxyConfigLookup_h
+
+#include <functional>
+#include "nsIProtocolProxyCallback.h"
+
+class nsIURI;
+
+namespace mozilla {
+namespace net {
+
+class ProxyConfigLookup final : public nsIProtocolProxyCallback {
+ public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIPROTOCOLPROXYCALLBACK
+
+  static nsresult Create(
+      std::function<void(nsIProxyInfo*, nsresult)>&& aCallback, nsIURI* aURI,
+      uint32_t aProxyResolveFlags);
+
+ private:
+  explicit ProxyConfigLookup(
+      std::function<void(nsIProxyInfo*, nsresult)>&& aCallback, nsIURI* aURI,
+      uint32_t aProxyResolveFlags);
+  virtual ~ProxyConfigLookup();
+  nsresult DoProxyResolve();
+
+  std::function<void(nsIProxyInfo*, nsresult)> mCallback;
+  nsCOMPtr<nsIURI> mURI;
+  uint32_t mProxyResolveFlags;
+};
+
+}  // namespace net
+}  // namespace mozilla
+
+#endif  // mozilla_net_ProxyConfigLookup_h
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookupChild.cpp
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ProxyConfigLookupChild.h"
+
+#include "mozilla/net/SocketProcessChild.h"
+#include "nsProxyInfo.h"
+
+namespace mozilla {
+namespace net {
+
+// static
+bool ProxyConfigLookupChild::Create(
+    nsIURI* aURI, uint32_t aProxyResolveFlags,
+    std::function<void(nsIProxyInfo*, nsresult)>&& aCallback) {
+  SocketProcessChild* socketChild = SocketProcessChild::GetSingleton();
+  if (!socketChild) {
+    return false;
+  }
+
+  RefPtr<ProxyConfigLookupChild> child =
+      new ProxyConfigLookupChild(std::move(aCallback));
+  return socketChild->SendPProxyConfigLookupConstructor(child, aURI,
+                                                        aProxyResolveFlags);
+}
+
+ProxyConfigLookupChild::ProxyConfigLookupChild(
+    std::function<void(nsIProxyInfo*, nsresult)>&& aCallback)
+    : mCallback(std::move(aCallback)) {}
+
+mozilla::ipc::IPCResult ProxyConfigLookupChild::Recv__delete__(
+    nsTArray<ProxyInfoCloneArgs>&& aProxyInfo, const nsresult& aResult) {
+  nsCOMPtr<nsIProxyInfo> proxyInfo =
+      nsProxyInfo::DeserializeProxyInfo(aProxyInfo);
+  mCallback(proxyInfo, aResult);
+  return IPC_OK();
+}
+
+}  // namespace net
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookupChild.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_net_ProxyConfigLookupChild_h
+#define mozilla_net_ProxyConfigLookupChild_h
+
+#include "mozilla/net/PProxyConfigLookupChild.h"
+#include <functional>
+
+class nsIProxyInfo;
+
+namespace mozilla {
+namespace net {
+
+class ProxyConfigLookupChild final : public PProxyConfigLookupChild {
+ public:
+  NS_INLINE_DECL_REFCOUNTING(ProxyConfigLookupChild, override)
+
+  static bool Create(nsIURI* aURI, uint32_t aProxyResolveFlags,
+                     std::function<void(nsIProxyInfo*, nsresult)>&& aCallback);
+
+  mozilla::ipc::IPCResult Recv__delete__(
+      nsTArray<ProxyInfoCloneArgs>&& aProxyInfo, const nsresult& aResult);
+
+ private:
+  explicit ProxyConfigLookupChild(
+      std::function<void(nsIProxyInfo*, nsresult)>&& aCallback);
+  virtual ~ProxyConfigLookupChild() = default;
+
+  std::function<void(nsIProxyInfo*, nsresult)> mCallback;
+};
+
+}  // namespace net
+}  // namespace mozilla
+
+#endif  // mozilla_net_ProxyConfigLookupChild_h
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookupParent.cpp
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ProxyConfigLookupParent.h"
+#include "ProxyConfigLookup.h"
+#include "mozilla/Unused.h"
+#include "nsProxyInfo.h"
+
+namespace mozilla {
+namespace net {
+
+ProxyConfigLookupParent::ProxyConfigLookupParent(nsIURI* aURI,
+                                                 uint32_t aProxyResolveFlags)
+    : mURI(aURI), mProxyResolveFlags(aProxyResolveFlags) {}
+
+ProxyConfigLookupParent::~ProxyConfigLookupParent() = default;
+
+void ProxyConfigLookupParent::DoProxyLookup() {
+  RefPtr<ProxyConfigLookupParent> self = this;
+  nsresult rv = ProxyConfigLookup::Create(
+      [self](nsIProxyInfo* aProxyInfo, nsresult aStatus) {
+        if (self->CanSend()) {
+          nsTArray<ProxyInfoCloneArgs> proxyInfoArray;
+          if (aProxyInfo && NS_SUCCEEDED(aStatus)) {
+            nsProxyInfo::SerializeProxyInfo(
+                static_cast<nsProxyInfo*>(aProxyInfo), proxyInfoArray);
+          }
+          Unused << Send__delete__(self, proxyInfoArray, aStatus);
+        }
+      },
+      mURI, mProxyResolveFlags);
+
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    nsTArray<ProxyInfoCloneArgs> emptyArray;
+    Unused << Send__delete__(self, emptyArray, rv);
+  }
+}
+
+}  // namespace net
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/ProxyConfigLookupParent.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_net_ProxyConfigLookupParent_h
+#define mozilla_net_ProxyConfigLookupParent_h
+
+#include "mozilla/net/PProxyConfigLookupParent.h"
+
+class nsIURI;
+
+namespace mozilla {
+namespace net {
+
+class ProxyConfigLookupParent final : public PProxyConfigLookupParent {
+ public:
+  NS_INLINE_DECL_REFCOUNTING(ProxyConfigLookupParent, override)
+
+  explicit ProxyConfigLookupParent(nsIURI* aURI, uint32_t aProxyResolveFlags);
+
+  void DoProxyLookup();
+
+ private:
+  virtual ~ProxyConfigLookupParent();
+
+  nsCOMPtr<nsIURI> mURI;
+  uint32_t mProxyResolveFlags;
+};
+
+}  // namespace net
+}  // namespace mozilla
+
+#endif  // mozilla_net_ProxyConfigLookupParent_h
--- a/netwerk/ipc/SocketProcessParent.cpp
+++ b/netwerk/ipc/SocketProcessParent.cpp
@@ -10,16 +10,17 @@
 #include "HttpTransactionParent.h"
 #include "SocketProcessHost.h"
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/ipc/FileDescriptorSetParent.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/PChildToParentStreamParent.h"
 #include "mozilla/ipc/PParentToChildStreamParent.h"
 #include "mozilla/net/DNSRequestParent.h"
+#include "mozilla/net/ProxyConfigLookupParent.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TelemetryIPC.h"
 #include "nsIHttpActivityObserver.h"
 #include "nsNSSIOLayer.h"
 #include "PSMIPCCommon.h"
 #include "secerr.h"
 #ifdef MOZ_WEBRTC
 #  include "mozilla/dom/ContentProcessManager.h"
@@ -323,16 +324,31 @@ mozilla::ipc::IPCResult SocketProcessPar
       aBuiltChain->AppendElement(std::move(array));
     }
   }
 
   *aSucceeded = true;
   return IPC_OK();
 }
 
+already_AddRefed<PProxyConfigLookupParent>
+SocketProcessParent::AllocPProxyConfigLookupParent(
+    nsIURI* aURI, const uint32_t& aProxyResolveFlags) {
+  RefPtr<ProxyConfigLookupParent> actor =
+      new ProxyConfigLookupParent(aURI, aProxyResolveFlags);
+  return actor.forget();
+}
+
+mozilla::ipc::IPCResult SocketProcessParent::RecvPProxyConfigLookupConstructor(
+    PProxyConfigLookupParent* aActor, nsIURI* aURI,
+    const uint32_t& aProxyResolveFlags) {
+  static_cast<ProxyConfigLookupParent*>(aActor)->DoProxyLookup();
+  return IPC_OK();
+}
+
 // To ensure that IPDL is finished before SocketParent gets deleted.
 class DeferredDeleteSocketProcessParent : public Runnable {
  public:
   explicit DeferredDeleteSocketProcessParent(
       UniquePtr<SocketProcessParent>&& aParent)
       : Runnable("net::DeferredDeleteSocketProcessParent"),
         mParent(std::move(aParent)) {}
 
--- a/netwerk/ipc/SocketProcessParent.h
+++ b/netwerk/ipc/SocketProcessParent.h
@@ -98,16 +98,22 @@ class SocketProcessParent final
   mozilla::ipc::IPCResult RecvGetTLSClientCert(
       const nsCString& aHostName, const OriginAttributes& aOriginAttributes,
       const int32_t& aPort, const uint32_t& aProviderFlags,
       const uint32_t& aProviderTlsFlags, const ByteArray& aServerCert,
       Maybe<ByteArray>&& aClientCert, nsTArray<ByteArray>&& aCollectedCANames,
       bool* aSucceeded, ByteArray* aOutCert, ByteArray* aOutKey,
       nsTArray<ByteArray>* aBuiltChain);
 
+  already_AddRefed<PProxyConfigLookupParent> AllocPProxyConfigLookupParent(
+      nsIURI* aURI, const uint32_t& aProxyResolveFlags);
+  mozilla::ipc::IPCResult RecvPProxyConfigLookupConstructor(
+      PProxyConfigLookupParent* aActor, nsIURI* aURI,
+      const uint32_t& aProxyResolveFlags) override;
+
  private:
   SocketProcessHost* mHost;
   UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;
 
   static void Destroy(UniquePtr<SocketProcessParent>&& aParent);
 };
 
 }  // namespace net
--- a/netwerk/ipc/moz.build
+++ b/netwerk/ipc/moz.build
@@ -14,16 +14,19 @@ EXPORTS.mozilla.net += [
     'InputChannelThrottleQueueChild.h',
     'InputChannelThrottleQueueParent.h',
     'NeckoChild.h',
     'NeckoCommon.h',
     'NeckoMessageUtils.h',
     'NeckoParent.h',
     'NeckoTargetHolder.h',
     'ParentProcessDocumentChannel.h',
+    'ProxyConfigLookup.h',
+    'ProxyConfigLookupChild.h',
+    'ProxyConfigLookupParent.h',
     'SocketProcessBridgeChild.h',
     'SocketProcessBridgeParent.h',
     'SocketProcessChild.h',
     'SocketProcessHost.h',
     'SocketProcessImpl.h',
     'SocketProcessParent.h',
 ]
 
@@ -34,32 +37,36 @@ UNIFIED_SOURCES += [
     'DocumentChannelParent.cpp',
     'DocumentLoadListener.cpp',
     'InputChannelThrottleQueueChild.cpp',
     'InputChannelThrottleQueueParent.cpp',
     'NeckoChild.cpp',
     'NeckoParent.cpp',
     'NeckoTargetHolder.cpp',
     'ParentProcessDocumentChannel.cpp',
+    'ProxyConfigLookup.cpp',
+    'ProxyConfigLookupChild.cpp',
+    'ProxyConfigLookupParent.cpp',
     'SocketProcessBridgeChild.cpp',
     'SocketProcessBridgeParent.cpp',
     'SocketProcessChild.cpp',
     'SocketProcessHost.cpp',
     'SocketProcessImpl.cpp',
     'SocketProcessParent.cpp',
 ]
 
 IPDL_SOURCES = [
     'NeckoChannelParams.ipdlh',
     'PChannelDiverter.ipdl',
     'PDataChannel.ipdl',
     'PDocumentChannel.ipdl',
     'PFileChannel.ipdl',
     'PInputChannelThrottleQueue.ipdl',
     'PNecko.ipdl',
+    'PProxyConfigLookup.ipdl',
     'PSimpleChannel.ipdl',
     'PSocketProcess.ipdl',
     'PSocketProcessBridge.ipdl'
 ]
 
 # needed so --disable-webrtc builds work (yes, a bit messy)
 if not CONFIG['MOZ_WEBRTC']:
   IPDL_SOURCES += [
--- a/netwerk/protocol/http/TRRServiceChannel.cpp
+++ b/netwerk/protocol/http/TRRServiceChannel.cpp
@@ -13,16 +13,17 @@
 #include "nsEscape.h"
 #include "nsHttpTransaction.h"
 #include "nsICancelable.h"
 #include "nsIHttpPushListener.h"
 #include "nsIProtocolProxyService2.h"
 #include "nsIOService.h"
 #include "nsISeekableStream.h"
 #include "nsURLHelper.h"
+#include "ProxyConfigLookup.h"
 #include "TRRLoadInfo.h"
 #include "ReferrerInfo.h"
 #include "TRR.h"
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ADDREF(TRRServiceChannel)
@@ -202,39 +203,23 @@ nsresult TRRServiceChannel::ResolveProxy
     return NS_DispatchToMainThread(
         NewRunnableMethod("TRRServiceChannel::ResolveProxy", this,
                           &TRRServiceChannel::ResolveProxy),
         NS_DISPATCH_NORMAL);
   }
 
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsresult rv;
-  nsCOMPtr<nsIChannel> channel;
-  rv = NS_NewChannel(getter_AddRefs(channel), mURI,
-                     nsContentUtils::GetSystemPrincipal(),
-                     nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                     nsIContentPolicy::TYPE_OTHER);
-  if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsIProtocolProxyService> pps =
-        do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
-    if (NS_SUCCEEDED(rv)) {
-      // using the nsIProtocolProxyService2 allows a minor performance
-      // optimization, but if an add-on has only provided the original interface
-      // then it is ok to use that version.
-      nsCOMPtr<nsIProtocolProxyService2> pps2 = do_QueryInterface(pps);
-      if (pps2) {
-        rv = pps2->AsyncResolve2(channel, mProxyResolveFlags, this, nullptr,
-                                 getter_AddRefs(mProxyRequest));
-      } else {
-        rv = pps->AsyncResolve(channel, mProxyResolveFlags, this, nullptr,
-                               getter_AddRefs(mProxyRequest));
-      }
-    }
-  }
+  // TODO: bug 1625171. Consider moving proxy resolution to socket process.
+  RefPtr<TRRServiceChannel> self = this;
+  nsresult rv = ProxyConfigLookup::Create(
+      [self](nsIProxyInfo* aProxyInfo, nsresult aStatus) {
+        self->OnProxyAvailable(nullptr, nullptr, aProxyInfo, aStatus);
+      },
+      mURI, mProxyResolveFlags);
 
   if (NS_FAILED(rv)) {
     if (!mCurrentEventTarget->IsOnCurrentThread()) {
       mCurrentEventTarget->Dispatch(
           NewRunnableMethod<nsresult>("TRRServiceChannel::AsyncAbort", this,
                                       &TRRServiceChannel::AsyncAbort, rv),
           NS_DISPATCH_NORMAL);
     }