зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj
--HG-- extra : source : ae110eaaa626064dd81188d4f587a2df1f439bd2
This commit is contained in:
Родитель
661f0a0891
Коммит
5a61756f88
|
@ -36,6 +36,7 @@
|
|||
#include "nsXPCOMPrivate.h"
|
||||
#include "mozilla/ChaosMode.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsThreadSyncDispatch.h"
|
||||
#include "LeakRefPtr.h"
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
|
@ -1172,20 +1173,6 @@ nsThread::SetScriptObserver(mozilla::CycleCollectedJSRuntime* aScriptObserver)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThreadSyncDispatch::Run()
|
||||
{
|
||||
if (mSyncTask) {
|
||||
mResult = mSyncTask->Run();
|
||||
mSyncTask = nullptr;
|
||||
// unblock the origin thread
|
||||
mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsThread::nsNestedEventTarget, nsIEventTarget)
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -207,36 +207,6 @@ protected:
|
|||
MainThreadFlag mIsMainThread;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class nsThreadSyncDispatch : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
|
||||
: mOrigin(aOrigin)
|
||||
, mSyncTask(aTask)
|
||||
, mResult(NS_ERROR_NOT_INITIALIZED)
|
||||
{
|
||||
}
|
||||
|
||||
bool IsPending()
|
||||
{
|
||||
return mSyncTask != nullptr;
|
||||
}
|
||||
|
||||
nsresult Result()
|
||||
{
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
nsCOMPtr<nsIThread> mOrigin;
|
||||
nsCOMPtr<nsIRunnable> mSyncTask;
|
||||
nsresult mResult;
|
||||
};
|
||||
|
||||
#if defined(XP_UNIX) && !defined(ANDROID) && !defined(DEBUG) && HAVE_UALARM \
|
||||
&& defined(_GNU_SOURCE)
|
||||
# define MOZ_CANARY
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsAutoPtr.h"
|
||||
#include "prinrval.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsThreadSyncDispatch.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef nsThreadSyncDispatch_h_
|
||||
#define nsThreadSyncDispatch_h_
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsThreadSyncDispatch : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
|
||||
: mOrigin(aOrigin)
|
||||
, mSyncTask(aTask)
|
||||
, mResult(NS_ERROR_NOT_INITIALIZED)
|
||||
{
|
||||
}
|
||||
|
||||
bool IsPending()
|
||||
{
|
||||
return mSyncTask != nullptr;
|
||||
}
|
||||
|
||||
nsresult Result()
|
||||
{
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private:
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (mSyncTask) {
|
||||
mResult = mSyncTask->Run();
|
||||
mSyncTask = nullptr;
|
||||
// unblock the origin thread
|
||||
mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThread> mOrigin;
|
||||
nsCOMPtr<nsIRunnable> mSyncTask;
|
||||
nsresult mResult;
|
||||
};
|
||||
|
||||
#endif // nsThreadSyncDispatch_h_
|
Загрузка…
Ссылка в новой задаче