Bug 1286798 - Part 2: Add IsOnDOMFileThread() and AssertIsOnDOMFileThread() generic helper methods; r=asuth
authorJan Varga <jan.varga@gmail.com>
Thu, 29 Nov 2018 21:47:17 +0100
changeset 505220 bb1fc7fd2fd240e074d0348721c7cdea1a07bb5e
parent 505219 c58b7f9f87735d9f86489ebf4a0cc1a80cb00048
child 505221 2a6e7e64cec1e3b8184a432c6f4c2351a87f9f43
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1286798
milestone65.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 1286798 - Part 2: Add IsOnDOMFileThread() and AssertIsOnDOMFileThread() generic helper methods; r=asuth
dom/file/ipc/IPCBlobInputStreamThread.cpp
dom/file/ipc/IPCBlobInputStreamThread.h
--- a/dom/file/ipc/IPCBlobInputStreamThread.cpp
+++ b/dom/file/ipc/IPCBlobInputStreamThread.cpp
@@ -242,10 +242,27 @@ IPCBlobInputStreamThread::DispatchFromSc
 }
 
 NS_IMETHODIMP
 IPCBlobInputStreamThread::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+bool
+IsOnDOMFileThread()
+{
+  mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex);
+
+  MOZ_ASSERT(!gShutdownHasStarted);
+  MOZ_ASSERT(gIPCBlobThread);
+
+  return gIPCBlobThread->IsOnCurrentThreadInfallible();
+}
+
+void
+AssertIsOnDOMFileThread()
+{
+  MOZ_ASSERT(IsOnDOMFileThread());
+}
+
 } // dom namespace
 } // mozilla namespace
--- a/dom/file/ipc/IPCBlobInputStreamThread.h
+++ b/dom/file/ipc/IPCBlobInputStreamThread.h
@@ -49,12 +49,18 @@ private:
 
   nsCOMPtr<nsIThread> mThread;
 
   // This is populated if MigrateActor() is called before the initialization of
   // the thread.
   nsTArray<RefPtr<IPCBlobInputStreamChild>> mPendingActors;
 };
 
+bool
+IsOnDOMFileThread();
+
+void
+AssertIsOnDOMFileThread();
+
 } // dom namespace
 } // mozilla namespace
 
 #endif // mozilla_dom_IPCBlobInputStreamThread_h