Bug 1350436 - Rename ValidatingDispatcher to SchedulerGroup (r=froydnj)

MozReview-Commit-ID: 1gWB9ZLPQfY
This commit is contained in:
Bill McCloskey 2017-03-09 12:32:32 -08:00
Родитель 21e75fbf2a
Коммит 2bb4eb39bf
10 изменённых файлов: 72 добавлений и 73 удалений

Просмотреть файл

@ -7,7 +7,7 @@
#include "mozilla/dom/DispatcherTrait.h"
#include "mozilla/AbstractThread.h"
#include "mozilla/Dispatcher.h"
#include "mozilla/SchedulerGroup.h"
#include "nsINamed.h"
using namespace mozilla;
@ -18,7 +18,7 @@ DispatcherTrait::Dispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
{
return ValidatingDispatcher::UnlabeledDispatch(aName, aCategory, Move(aRunnable));
return SchedulerGroup::UnlabeledDispatch(aName, aCategory, Move(aRunnable));
}
nsIEventTarget*

Просмотреть файл

@ -13,7 +13,6 @@
#include "nsString.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/Dispatcher.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/CustomElementRegistry.h"

Просмотреть файл

@ -103,10 +103,10 @@ TabGroup::GetFromWindowActor(mozIDOMWindowProxy* aWindow)
// We have an event target. We assume the IPC code created it via
// TabGroup::CreateEventTarget.
RefPtr<ValidatingDispatcher> dispatcher =
ValidatingDispatcher::FromEventTarget(target);
MOZ_RELEASE_ASSERT(dispatcher);
auto tabGroup = dispatcher->AsTabGroup();
RefPtr<SchedulerGroup> group =
SchedulerGroup::FromEventTarget(target);
MOZ_RELEASE_ASSERT(group);
auto tabGroup = group->AsTabGroup();
MOZ_RELEASE_ASSERT(tabGroup);
// We delay creating the event targets until now since the TabGroup
@ -241,7 +241,7 @@ TabGroup::EventTargetFor(TaskCategory aCategory) const
if (aCategory == TaskCategory::Worker || aCategory == TaskCategory::Timer) {
MOZ_RELEASE_ASSERT(mThrottledQueuesInitialized || mIsChrome);
}
return ValidatingDispatcher::EventTargetFor(aCategory);
return SchedulerGroup::EventTargetFor(aCategory);
}
AbstractThread*
@ -255,7 +255,7 @@ TabGroup::AbstractMainThreadForImpl(TaskCategory aCategory)
return AbstractThread::MainThread();
}
return ValidatingDispatcher::AbstractMainThreadForImpl(aCategory);
return SchedulerGroup::AbstractMainThreadForImpl(aCategory);
}
} // namespace dom

Просмотреть файл

@ -13,7 +13,7 @@
#include "nsString.h"
#include "mozilla/Atomics.h"
#include "mozilla/Dispatcher.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/RefPtr.h"
class mozIDOMWindowProxy;
@ -43,7 +43,7 @@ namespace dom {
class DocGroup;
class TabGroup final : public ValidatingDispatcher
class TabGroup final : public SchedulerGroup
{
private:
class HashEntry : public nsCStringHashKey

Просмотреть файл

@ -4,7 +4,7 @@
* 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/. */
#include "mozilla/Dispatcher.h"
#include "mozilla/SchedulerGroup.h"
#include "jsfriendapi.h"
#include "mozilla/AbstractThread.h"
@ -16,11 +16,11 @@
using namespace mozilla;
class ValidatingDispatcher::Runnable final : public mozilla::Runnable
class SchedulerGroup::Runnable final : public mozilla::Runnable
{
public:
Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
ValidatingDispatcher* aDispatcher);
SchedulerGroup* aDispatcher);
NS_IMETHODIMP
GetName(nsACString& aName) override
@ -41,10 +41,10 @@ public:
private:
nsCOMPtr<nsIRunnable> mRunnable;
RefPtr<ValidatingDispatcher> mDispatcher;
RefPtr<SchedulerGroup> mDispatcher;
};
/* DispatcherEventTarget */
/* SchedulerEventTarget */
namespace {
@ -52,15 +52,15 @@ namespace {
{ 0xbf4e36c8, 0x7d04, 0x4ef4, \
{ 0xbb, 0xd8, 0x11, 0x09, 0x0a, 0xdb, 0x4d, 0xf7 } }
class DispatcherEventTarget final : public nsIEventTarget
class SchedulerEventTarget final : public nsIEventTarget
{
RefPtr<ValidatingDispatcher> mDispatcher;
RefPtr<SchedulerGroup> mDispatcher;
TaskCategory mCategory;
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DISPATCHEREVENTTARGET_IID)
DispatcherEventTarget(ValidatingDispatcher* aDispatcher, TaskCategory aCategory)
SchedulerEventTarget(SchedulerGroup* aDispatcher, TaskCategory aCategory)
: mDispatcher(aDispatcher)
, mCategory(aCategory)
{}
@ -68,26 +68,26 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIEVENTTARGET
ValidatingDispatcher* Dispatcher() const { return mDispatcher; }
SchedulerGroup* Dispatcher() const { return mDispatcher; }
private:
~DispatcherEventTarget() {}
~SchedulerEventTarget() {}
};
NS_DEFINE_STATIC_IID_ACCESSOR(DispatcherEventTarget, NS_DISPATCHEREVENTTARGET_IID)
NS_DEFINE_STATIC_IID_ACCESSOR(SchedulerEventTarget, NS_DISPATCHEREVENTTARGET_IID)
} // namespace
NS_IMPL_ISUPPORTS(DispatcherEventTarget, DispatcherEventTarget, nsIEventTarget)
NS_IMPL_ISUPPORTS(SchedulerEventTarget, SchedulerEventTarget, nsIEventTarget)
NS_IMETHODIMP
DispatcherEventTarget::DispatchFromScript(nsIRunnable* aRunnable, uint32_t aFlags)
SchedulerEventTarget::DispatchFromScript(nsIRunnable* aRunnable, uint32_t aFlags)
{
return Dispatch(do_AddRef(aRunnable), aFlags);
}
NS_IMETHODIMP
DispatcherEventTarget::Dispatch(already_AddRefed<nsIRunnable> aRunnable, uint32_t aFlags)
SchedulerEventTarget::Dispatch(already_AddRefed<nsIRunnable> aRunnable, uint32_t aFlags)
{
if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL)) {
return NS_ERROR_UNEXPECTED;
@ -96,22 +96,22 @@ DispatcherEventTarget::Dispatch(already_AddRefed<nsIRunnable> aRunnable, uint32_
}
NS_IMETHODIMP
DispatcherEventTarget::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t)
SchedulerEventTarget::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
DispatcherEventTarget::IsOnCurrentThread(bool* aIsOnCurrentThread)
SchedulerEventTarget::IsOnCurrentThread(bool* aIsOnCurrentThread)
{
*aIsOnCurrentThread = NS_IsMainThread();
return NS_OK;
}
/* static */ nsresult
ValidatingDispatcher::UnlabeledDispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
SchedulerGroup::UnlabeledDispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
{
nsCOMPtr<nsIRunnable> runnable(aRunnable);
if (aName) {
@ -126,23 +126,23 @@ ValidatingDispatcher::UnlabeledDispatch(const char* aName,
}
}
ValidatingDispatcher* ValidatingDispatcher::sRunningDispatcher;
SchedulerGroup* SchedulerGroup::sRunningDispatcher;
ValidatingDispatcher::ValidatingDispatcher()
SchedulerGroup::SchedulerGroup()
: mAccessValid(false)
{
}
nsresult
ValidatingDispatcher::Dispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
SchedulerGroup::Dispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
{
return LabeledDispatch(aName, aCategory, Move(aRunnable));
}
nsIEventTarget*
ValidatingDispatcher::EventTargetFor(TaskCategory aCategory) const
SchedulerGroup::EventTargetFor(TaskCategory aCategory) const
{
MOZ_ASSERT(aCategory != TaskCategory::Count);
MOZ_ASSERT(mEventTargets[size_t(aCategory)]);
@ -150,14 +150,14 @@ ValidatingDispatcher::EventTargetFor(TaskCategory aCategory) const
}
AbstractThread*
ValidatingDispatcher::AbstractMainThreadFor(TaskCategory aCategory)
SchedulerGroup::AbstractMainThreadFor(TaskCategory aCategory)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
return AbstractMainThreadForImpl(aCategory);
}
AbstractThread*
ValidatingDispatcher::AbstractMainThreadForImpl(TaskCategory aCategory)
SchedulerGroup::AbstractMainThreadForImpl(TaskCategory aCategory)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aCategory != TaskCategory::Count);
@ -173,7 +173,7 @@ ValidatingDispatcher::AbstractMainThreadForImpl(TaskCategory aCategory)
}
void
ValidatingDispatcher::CreateEventTargets(bool aNeedValidation)
SchedulerGroup::CreateEventTargets(bool aNeedValidation)
{
for (size_t i = 0; i < size_t(TaskCategory::Count); i++) {
TaskCategory category = static_cast<TaskCategory>(i);
@ -189,9 +189,9 @@ ValidatingDispatcher::CreateEventTargets(bool aNeedValidation)
}
void
ValidatingDispatcher::Shutdown(bool aXPCOMShutdown)
SchedulerGroup::Shutdown(bool aXPCOMShutdown)
{
// There is a RefPtr cycle TabGroup -> DispatcherEventTarget -> TabGroup. To
// There is a RefPtr cycle TabGroup -> SchedulerEventTarget -> TabGroup. To
// avoid leaks, we need to break the chain somewhere. We shouldn't be using
// the ThrottledEventQueue for this TabGroup when no windows belong to it,
// so it's safe to null out the queue here.
@ -202,17 +202,17 @@ ValidatingDispatcher::Shutdown(bool aXPCOMShutdown)
}
already_AddRefed<nsIEventTarget>
ValidatingDispatcher::CreateEventTargetFor(TaskCategory aCategory)
SchedulerGroup::CreateEventTargetFor(TaskCategory aCategory)
{
RefPtr<DispatcherEventTarget> target =
new DispatcherEventTarget(this, aCategory);
RefPtr<SchedulerEventTarget> target =
new SchedulerEventTarget(this, aCategory);
return target.forget();
}
/* static */ ValidatingDispatcher*
ValidatingDispatcher::FromEventTarget(nsIEventTarget* aEventTarget)
/* static */ SchedulerGroup*
SchedulerGroup::FromEventTarget(nsIEventTarget* aEventTarget)
{
RefPtr<DispatcherEventTarget> target = do_QueryObject(aEventTarget);
RefPtr<SchedulerEventTarget> target = do_QueryObject(aEventTarget);
if (!target) {
return nullptr;
}
@ -220,9 +220,9 @@ ValidatingDispatcher::FromEventTarget(nsIEventTarget* aEventTarget)
}
nsresult
ValidatingDispatcher::LabeledDispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
SchedulerGroup::LabeledDispatch(const char* aName,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable)
{
nsCOMPtr<nsIRunnable> runnable(aRunnable);
if (XRE_IsContentProcess()) {
@ -232,7 +232,7 @@ ValidatingDispatcher::LabeledDispatch(const char* aName,
}
void
ValidatingDispatcher::SetValidatingAccess(ValidationType aType)
SchedulerGroup::SetValidatingAccess(ValidationType aType)
{
sRunningDispatcher = aType == StartValidation ? this : nullptr;
mAccessValid = aType == StartValidation;
@ -242,15 +242,15 @@ ValidatingDispatcher::SetValidatingAccess(ValidationType aType)
js::EnableAccessValidation(jsapi.cx(), !!sRunningDispatcher);
}
ValidatingDispatcher::Runnable::Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
ValidatingDispatcher* aDispatcher)
SchedulerGroup::Runnable::Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
SchedulerGroup* aDispatcher)
: mRunnable(Move(aRunnable)),
mDispatcher(aDispatcher)
{
}
NS_IMETHODIMP
ValidatingDispatcher::Runnable::Run()
SchedulerGroup::Runnable::Run()
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
@ -266,21 +266,21 @@ ValidatingDispatcher::Runnable::Run()
return result;
}
ValidatingDispatcher::AutoProcessEvent::AutoProcessEvent()
: mPrevRunningDispatcher(ValidatingDispatcher::sRunningDispatcher)
SchedulerGroup::AutoProcessEvent::AutoProcessEvent()
: mPrevRunningDispatcher(SchedulerGroup::sRunningDispatcher)
{
ValidatingDispatcher* prev = sRunningDispatcher;
SchedulerGroup* prev = sRunningDispatcher;
if (prev) {
MOZ_ASSERT(prev->mAccessValid);
prev->SetValidatingAccess(EndValidation);
}
}
ValidatingDispatcher::AutoProcessEvent::~AutoProcessEvent()
SchedulerGroup::AutoProcessEvent::~AutoProcessEvent()
{
MOZ_ASSERT(!sRunningDispatcher);
ValidatingDispatcher* prev = mPrevRunningDispatcher;
SchedulerGroup* prev = mPrevRunningDispatcher;
if (prev) {
prev->SetValidatingAccess(StartValidation);
}

Просмотреть файл

@ -4,8 +4,8 @@
* 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 mozilla_Dispatcher_h
#define mozilla_Dispatcher_h
#ifndef mozilla_SchedulerGroup_h
#define mozilla_SchedulerGroup_h
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/TaskCategory.h"
@ -31,10 +31,10 @@ class TabGroup;
// only functionality offered by a Dispatcher is the ability to dispatch
// runnables to the group. TabGroup, DocGroup, and SystemGroup are the concrete
// implementations of Dispatcher.
class ValidatingDispatcher
class SchedulerGroup
{
public:
ValidatingDispatcher();
SchedulerGroup();
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
@ -44,7 +44,7 @@ public:
~AutoProcessEvent();
private:
ValidatingDispatcher* mPrevRunningDispatcher;
SchedulerGroup* mPrevRunningDispatcher;
};
// Ensure that it's valid to access the TabGroup at this time.
@ -87,7 +87,7 @@ protected:
// Given an event target returned by |dispatcher->CreateEventTargetFor|, this
// function returns |dispatcher|.
static ValidatingDispatcher* FromEventTarget(nsIEventTarget* aEventTarget);
static SchedulerGroup* FromEventTarget(nsIEventTarget* aEventTarget);
nsresult LabeledDispatch(const char* aName,
TaskCategory aCategory,
@ -105,7 +105,7 @@ protected:
};
void SetValidatingAccess(ValidationType aType);
static ValidatingDispatcher* sRunningDispatcher;
static SchedulerGroup* sRunningDispatcher;
bool mAccessValid;
nsCOMPtr<nsIEventTarget> mEventTargets[size_t(TaskCategory::Count)];
@ -114,4 +114,4 @@ protected:
} // namespace mozilla
#endif // mozilla_dom_Dispatcher_h
#endif // mozilla_SchedulerGroup_h

Просмотреть файл

@ -12,7 +12,7 @@
using namespace mozilla;
class SystemGroupImpl final : public ValidatingDispatcher
class SystemGroupImpl final : public SchedulerGroup
{
public:
SystemGroupImpl();

Просмотреть файл

@ -8,7 +8,7 @@
#define mozilla_SystemGroup_h
#include "mozilla/TaskCategory.h"
#include "mozilla/Dispatcher.h"
#include "mozilla/SchedulerGroup.h"
// The SystemGroup should be used for dispatching runnables that don't need to
// touch web content. Runnables dispatched to the SystemGroup are run in order

Просмотреть файл

@ -39,7 +39,6 @@ EXPORTS.mozilla += [
'BlockingResourceBase.h',
'CondVar.h',
'DeadlockDetector.h',
'Dispatcher.h',
'HangAnnotations.h',
'HangMonitor.h',
'LazyIdleThread.h',
@ -48,6 +47,7 @@ EXPORTS.mozilla += [
'MozPromise.h',
'Mutex.h',
'ReentrantMonitor.h',
'SchedulerGroup.h',
'SharedThreadPool.h',
'StateMirroring.h',
'StateWatching.h',
@ -63,7 +63,6 @@ UNIFIED_SOURCES += [
'AbstractThread.cpp',
'BackgroundHangMonitor.cpp',
'BlockingResourceBase.cpp',
'Dispatcher.cpp',
'HangAnnotations.cpp',
'HangMonitor.cpp',
'LazyIdleThread.cpp',
@ -78,6 +77,7 @@ UNIFIED_SOURCES += [
'nsThreadPool.cpp',
'nsThreadUtils.cpp',
'nsTimerImpl.cpp',
'SchedulerGroup.cpp',
'SharedThreadPool.cpp',
'SystemGroup.cpp',
'TaskQueue.cpp',

Просмотреть файл

@ -22,13 +22,13 @@
#include "nsQueryObject.h"
#include "pratom.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Dispatcher.h"
#include "mozilla/Logging.h"
#include "nsIObserverService.h"
#include "mozilla/HangMonitor.h"
#include "mozilla/IOInterposer.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/Services.h"
#include "nsXPCOMPrivate.h"
#include "mozilla/ChaosMode.h"
@ -1202,7 +1202,7 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult)
// and repeat the nested event loop since its state change hasn't happened yet.
bool reallyWait = aMayWait && (mNestedEventLoopDepth > 0 || !ShuttingDown());
Maybe<ValidatingDispatcher::AutoProcessEvent> ape;
Maybe<SchedulerGroup::AutoProcessEvent> ape;
if (mIsMainThread == MAIN_THREAD) {
DoMainThreadSpecificProcessing(reallyWait);
ape.emplace();