Bug 1268822 - rename mozilla::gmp::Runnable/SyncRunnable in order not to confuse NS_LOG_ADDREF/NS_LOG_RELEASE. r=gerald.
MozReview-Commit-ID: 30CzoGyy0CK
--- a/dom/media/gmp/GMPPlatform.cpp
+++ b/dom/media/gmp/GMPPlatform.cpp
@@ -19,48 +19,48 @@ static GMPChild* sChild = nullptr;
static bool
IsOnChildMainThread()
{
return sMainLoop && sMainLoop == MessageLoop::current();
}
// We just need a refcounted wrapper for GMPTask objects.
-class Runnable final
+class GMPRunnable final
{
public:
- NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Runnable)
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPRunnable)
- explicit Runnable(GMPTask* aTask)
+ explicit GMPRunnable(GMPTask* aTask)
: mTask(aTask)
{
MOZ_ASSERT(mTask);
}
void Run()
{
mTask->Run();
mTask->Destroy();
mTask = nullptr;
}
private:
- ~Runnable()
+ ~GMPRunnable()
{
}
GMPTask* mTask;
};
-class SyncRunnable final
+class GMPSyncRunnable final
{
public:
- NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SyncRunnable)
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPSyncRunnable)
- SyncRunnable(GMPTask* aTask, MessageLoop* aMessageLoop)
+ GMPSyncRunnable(GMPTask* aTask, MessageLoop* aMessageLoop)
: mDone(false)
, mTask(aTask)
, mMessageLoop(aMessageLoop)
, mMonitor("GMPSyncRunnable")
{
MOZ_ASSERT(mTask);
MOZ_ASSERT(mMessageLoop);
}
@@ -68,17 +68,17 @@ public:
void Post()
{
// We assert here for two reasons.
// 1) Nobody should be blocking the main thread.
// 2) This prevents deadlocks when doing sync calls to main which if the
// main thread tries to do a sync call back to the calling thread.
MOZ_ASSERT(!IsOnChildMainThread());
- mMessageLoop->PostTask(NewRunnableMethod(this, &SyncRunnable::Run));
+ mMessageLoop->PostTask(NewRunnableMethod(this, &GMPSyncRunnable::Run));
MonitorAutoLock lock(mMonitor);
while (!mDone) {
lock.Wait();
}
}
void Run()
{
@@ -86,17 +86,17 @@ public:
mTask->Destroy();
mTask = nullptr;
MonitorAutoLock lock(mMonitor);
mDone = true;
lock.Notify();
}
private:
- ~SyncRunnable()
+ ~GMPSyncRunnable()
{
}
bool mDone;
GMPTask* mTask;
MessageLoop* mMessageLoop;
Monitor mMonitor;
};
@@ -115,30 +115,30 @@ CreateThread(GMPThread** aThread)
GMPErr
RunOnMainThread(GMPTask* aTask)
{
if (!aTask || !sMainLoop) {
return GMPGenericErr;
}
- RefPtr<Runnable> r = new Runnable(aTask);
- sMainLoop->PostTask(NewRunnableMethod(r.get(), &Runnable::Run));
+ RefPtr<GMPRunnable> r = new GMPRunnable(aTask);
+ sMainLoop->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run));
return GMPNoErr;
}
GMPErr
SyncRunOnMainThread(GMPTask* aTask)
{
if (!aTask || !sMainLoop || IsOnChildMainThread()) {
return GMPGenericErr;
}
- RefPtr<SyncRunnable> r = new SyncRunnable(aTask, sMainLoop);
+ RefPtr<GMPSyncRunnable> r = new GMPSyncRunnable(aTask, sMainLoop);
r->Post();
return GMPNoErr;
}
GMPErr
CreateMutex(GMPMutex** aMutex)
@@ -247,19 +247,19 @@ GMPThreadImpl::Post(GMPTask* aTask)
if (!mThread.IsRunning()) {
bool started = mThread.Start();
if (!started) {
NS_WARNING("Unable to start GMPThread!");
return;
}
}
- RefPtr<Runnable> r = new Runnable(aTask);
+ RefPtr<GMPRunnable> r = new GMPRunnable(aTask);
- mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &Runnable::Run));
+ mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run));
}
void
GMPThreadImpl::Join()
{
{
MutexAutoLock lock(mMutex);
if (mThread.IsRunning()) {