From 2bb98fc53fd2f60a8b2b91ba75b7050e758aae35 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Wed, 7 Jun 2017 16:21:18 -0700 Subject: [PATCH] Bug 1371129 - Convert NS_GetCurrentThread in IPCStreamSource.cpp (r=bevis) MozReview-Commit-ID: JVmmzoaK4Pm --- ipc/glue/IPCStreamSource.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp index 60aa8da0b81c..32028fe056b4 100644 --- a/ipc/glue/IPCStreamSource.cpp +++ b/ipc/glue/IPCStreamSource.cpp @@ -8,8 +8,9 @@ #include "nsIAsyncInputStream.h" #include "nsICancelableRunnable.h" #include "nsIRunnable.h" -#include "nsIThread.h" +#include "nsISerialEventTarget.h" #include "nsStreamUtils.h" +#include "nsThreadUtils.h" using mozilla::dom::workers::Canceling; using mozilla::dom::workers::GetCurrentThreadWorkerPrivate; @@ -26,7 +27,7 @@ class IPCStreamSource::Callback final : public nsIInputStreamCallback public: explicit Callback(IPCStreamSource* aSource) : mSource(aSource) - , mOwningThread(NS_GetCurrentThread()) + , mOwningEventTarget(GetCurrentThreadSerialEventTarget()) { MOZ_ASSERT(mSource); } @@ -35,14 +36,14 @@ public: OnInputStreamReady(nsIAsyncInputStream* aStream) override { // any thread - if (mOwningThread == NS_GetCurrentThread()) { + if (mOwningEventTarget->IsOnCurrentThread()) { return Run(); } // If this fails, then it means the owning thread is a Worker that has // been shutdown. Its ok to lose the event in this case because the // IPCStreamChild listens for this event through the WorkerHolder. - nsresult rv = mOwningThread->Dispatch(this, nsIThread::DISPATCH_NORMAL); + nsresult rv = mOwningEventTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL); if (NS_FAILED(rv)) { NS_WARNING("Failed to dispatch stream readable event to owning thread"); } @@ -53,7 +54,7 @@ public: NS_IMETHOD Run() override { - MOZ_ASSERT(mOwningThread == NS_GetCurrentThread()); + MOZ_ASSERT(mOwningEventTarget->IsOnCurrentThread()); if (mSource) { mSource->OnStreamReady(this); } @@ -72,7 +73,7 @@ public: void ClearSource() { - MOZ_ASSERT(mOwningThread == NS_GetCurrentThread()); + MOZ_ASSERT(mOwningEventTarget->IsOnCurrentThread()); MOZ_ASSERT(mSource); mSource = nullptr; } @@ -91,7 +92,7 @@ private: // ActorDestroyed() is called). IPCStreamSource* mSource; - nsCOMPtr mOwningThread; + nsCOMPtr mOwningEventTarget; NS_DECL_THREADSAFE_ISUPPORTS };