From 89fb42ab069321087be8cc49f25b8ff5a3a956a6 Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Thu, 29 Nov 2018 21:47:17 +0100 Subject: [PATCH] Bug 1286798 - Part 2: Add IsOnDOMFileThread() and AssertIsOnDOMFileThread() generic helper methods; r=asuth --- dom/file/ipc/IPCBlobInputStreamThread.cpp | 17 +++++++++++++++++ dom/file/ipc/IPCBlobInputStreamThread.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/dom/file/ipc/IPCBlobInputStreamThread.cpp b/dom/file/ipc/IPCBlobInputStreamThread.cpp index 15671b7cb769..a4cfa52a442b 100644 --- a/dom/file/ipc/IPCBlobInputStreamThread.cpp +++ b/dom/file/ipc/IPCBlobInputStreamThread.cpp @@ -247,5 +247,22 @@ IPCBlobInputStreamThread::DelayedDispatch(already_AddRefed, uint32_ 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 diff --git a/dom/file/ipc/IPCBlobInputStreamThread.h b/dom/file/ipc/IPCBlobInputStreamThread.h index 45900a6182a6..02bda56e1de7 100644 --- a/dom/file/ipc/IPCBlobInputStreamThread.h +++ b/dom/file/ipc/IPCBlobInputStreamThread.h @@ -54,6 +54,12 @@ private: nsTArray> mPendingActors; }; +bool +IsOnDOMFileThread(); + +void +AssertIsOnDOMFileThread(); + } // dom namespace } // mozilla namespace