Bug 1540289 - Don't init socket process bridge if the pref is disabled r=dragana,bwc
authorKershaw Chang <kershaw@mozilla.com>
Tue, 23 Apr 2019 13:06:05 +0000
changeset 470481 c126bc2983801e7e8b77e57e5c6c2d5998ce7d59
parent 470480 b2a8685b55e1904694913e75c89151056a6d3508
child 470482 56f46d0eafe230c410e139ad51b2c596e18d14d5
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana, bwc
bugs1540289
milestone68.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 1540289 - Don't init socket process bridge if the pref is disabled r=dragana,bwc Differential Revision: https://phabricator.services.mozilla.com/D25571
media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp
netwerk/ipc/SocketProcessBridgeChild.cpp
--- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp
@@ -155,17 +155,18 @@ class MediaTransportHandlerSTS : public 
   bool mProxyOnly = false;
 };
 
 /* static */
 already_AddRefed<MediaTransportHandler> MediaTransportHandler::Create(
     nsISerialEventTarget* aCallbackThread) {
   RefPtr<MediaTransportHandler> result;
   if (XRE_IsContentProcess() &&
-      Preferences::GetBool("media.peerconnection.mtransport_process")) {
+      Preferences::GetBool("media.peerconnection.mtransport_process") &&
+      Preferences::GetBool("network.process.enabled")) {
     result = new MediaTransportHandlerIPC(aCallbackThread);
   } else {
     result = new MediaTransportHandlerSTS(aCallbackThread);
   }
   return result.forget();
 }
 
 MediaTransportHandlerSTS::MediaTransportHandlerSTS(
--- a/netwerk/ipc/SocketProcessBridgeChild.cpp
+++ b/netwerk/ipc/SocketProcessBridgeChild.cpp
@@ -5,16 +5,17 @@
 
 #include "SocketProcessBridgeChild.h"
 #include "SocketProcessLogging.h"
 
 #include "mozilla/net/NeckoChild.h"
 #include "nsIObserverService.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/PMediaTransportChild.h"
+#include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace net {
 
 StaticRefPtr<SocketProcessBridgeChild>
     SocketProcessBridgeChild::sSocketProcessBridgeChild;
 
 NS_IMPL_ISUPPORTS(SocketProcessBridgeChild, nsIObserver)
@@ -42,21 +43,37 @@ SocketProcessBridgeChild::GetSingleton()
   if (!sSocketProcessBridgeChild) {
     return nullptr;
   }
 
   RefPtr<SocketProcessBridgeChild> child = sSocketProcessBridgeChild.get();
   return child.forget();
 }
 
+static bool SocketProcessEnabled() {
+  static bool sInited = false;
+  static bool sSocketProcessEnabled = false;
+  if (!sInited) {
+    sSocketProcessEnabled = Preferences::GetBool("network.process.enabled");
+    sInited = true;
+  }
+
+  return sSocketProcessEnabled;
+}
+
 // static
 RefPtr<SocketProcessBridgeChild::GetPromise>
 SocketProcessBridgeChild::GetSocketProcessBridge() {
   MOZ_ASSERT(NS_IsMainThread());
 
+  if (!SocketProcessEnabled()) {
+    return GetPromise::CreateAndReject(nsCString("Socket process disabled!"),
+                                       __func__);
+  }
+
   if (!gNeckoChild) {
     return GetPromise::CreateAndReject(nsCString("No NeckoChild!"), __func__);
   }
 
   if (sSocketProcessBridgeChild) {
     return GetPromise::CreateAndResolve(sSocketProcessBridgeChild, __func__);
   }