Bug 1231213 - Support IPCStreamSource on the Worker Launcher thread. r=asuth
☠☠ backed out by 3cf55b7f12f2 ☠ ☠
authorPerry Jiang <perry@mozilla.com>
Wed, 14 Aug 2019 16:19:34 +0000
changeset 488061 2d5628a0e52dc9aff4a67fa05da6d238793f9af6
parent 488060 3449c2eba4c6b196fc3f0be090a5aa48058b8173
child 488062 581653ef33ddb0bf5b054ba455d5108dbb2cfa1a
push id113900
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:53:50 +0000
treeherdermozilla-inbound@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1231213
milestone70.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 1231213 - Support IPCStreamSource on the Worker Launcher thread. r=asuth Differential Revision: https://phabricator.services.mozilla.com/D26160
ipc/glue/IPCStreamSource.cpp
--- a/ipc/glue/IPCStreamSource.cpp
+++ b/ipc/glue/IPCStreamSource.cpp
@@ -1,16 +1,17 @@
 /* -*- 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 "IPCStreamSource.h"
 #include "BackgroundParent.h"  // for AssertIsOnBackgroundThread
+#include "mozilla/dom/RemoteWorkerService.h"
 #include "mozilla/webrender/WebRenderTypes.h"
 #include "nsIAsyncInputStream.h"
 #include "nsICancelableRunnable.h"
 #include "nsIRunnable.h"
 #include "nsISerialEventTarget.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 
@@ -108,33 +109,36 @@ bool IPCStreamSource::Initialize() {
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mStream->IsNonBlocking(&nonBlocking)));
   // IPCStreamChild reads in the current thread, so it is only supported on
   // non-blocking, async channels
   if (!nonBlocking) {
     return false;
   }
 
   // A source can be used on any thread, but we only support IPCStream on
-  // main thread, Workers and PBackground thread right now.  This is due
-  // to the requirement  that the thread be guaranteed to live long enough to
-  // receive messages. We can enforce this guarantee with a StrongWorkerRef on
-  // worker threads, but not other threads. Main-thread and PBackground thread
-  // do not need anything special in order to be kept alive.
+  // main thread, Workers, Worker Launcher, and PBackground thread right now.
+  // This is due to the requirement  that the thread be guaranteed to live long
+  // enough to receive messages. We can enforce this guarantee with a
+  // StrongWorkerRef on worker threads, but not other threads. Main-thread,
+  // PBackground, and Worker Launcher threads do not need anything special in
+  // order to be kept alive.
   if (!NS_IsMainThread()) {
     if (const auto workerPrivate = dom::GetCurrentThreadWorkerPrivate()) {
       RefPtr<dom::StrongWorkerRef> workerRef =
           dom::StrongWorkerRef::CreateForcibly(workerPrivate,
                                                "IPCStreamSource");
       if (NS_WARN_IF(!workerRef)) {
         return false;
       }
 
       mWorkerRef = std::move(workerRef);
     } else {
-      AssertIsOnBackgroundThread();
+      MOZ_DIAGNOSTIC_ASSERT(
+          IsOnBackgroundThread() ||
+          dom::RemoteWorkerService::Thread()->IsOnCurrentThread());
     }
   }
 
   return true;
 }
 
 void IPCStreamSource::ActorConstructed() {
   MOZ_ASSERT(mState == ePending);