gecko-dev/dom/base/DispatcherTrait.h
Andreas Farre 25ca8d7890 Bug 1620594 - Part 7: Remove TabGroup and SystemGroup. r=nika,bas
TabGroup never really made any difference in which thread something go
dispatched to. This was the intended use, but development of TabGroups
with abstract main threads never made it that far. The good thing is
that thish makes it safe to also remove to the SystemGroup and instead
switch all SystemGroup dispatches to dispatches to main thread.

Timers for setTimeout and workers were the sole users of wrapped and
throttled event targets, that those throttled queues have been moved
to the BrowsingContextGroup and are now accessed explicitly.

The SchedulerEventTarget has been removed, since there are no longer a
separate event target for every TaskCategory. Instead a
LabellingEventTarget has been added to DocGroup to handle the case
where an event is dispatched do DocGroup or when an AbstractThread is
created using a DocGroup. This means that we'll actually label more
events correctly with the DocGroup that they belong to.

DocGroups have also been moved to BrowsingContextGroup.

Depends on D67636

Differential Revision: https://phabricator.services.mozilla.com/D65936

--HG--
extra : moz-landing-system : lando
2020-04-07 15:17:47 +00:00

44 lines
1.6 KiB
C++

/* -*- 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 mozilla_dom_DispatcherTrait_h
#define mozilla_dom_DispatcherTrait_h
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/TaskCategory.h"
class nsIRunnable;
class nsISerialEventTarget;
namespace mozilla {
class AbstractThread;
namespace dom {
// This trait should be attached to classes like nsIGlobalObject and
// Document that have a DocGroup attached to them. The methods here
// should delegate to the DocGroup. We can't use the
// Dispatcher class directly because it inherits from nsISupports.
class DispatcherTrait {
public:
// This method may or may not be safe off of the main thread. For Document it
// is safe. For nsIGlobalWindow it is not safe.
virtual nsresult Dispatch(TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable);
// This method may or may not be safe off of the main thread. For Document it
// is safe. For nsIGlobalWindow it is not safe. The nsISerialEventTarget can
// always be used off the main thread.
virtual nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const;
// Must be called on the main thread. The AbstractThread can always be used
// off the main thread.
virtual AbstractThread* AbstractMainThreadFor(TaskCategory aCategory);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DispatcherTrait_h