Commit c9d18ffc authored by Johann's avatar Johann Committed by Commit Bot

gamepad dispatcher: pass in execution context

Pass EC in instead of the task runner. Puts the task type in the
dispatcher class instead of the calling class. Dropped std::move:
  error: moving a temporary object prevents copy elision

Also paves the way for some new objects which will need the
execution context.

Change-Id: Id0608ccf129443532091e7bdfe0afccb146172ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152134Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Johann Koenig <johannkoenig@google.com>
Cr-Commit-Position: refs/heads/master@{#762725}
parent 0aa7262e
......@@ -40,9 +40,10 @@ void GamepadDispatcher::ResetVibrationActuator(
std::move(callback));
}
GamepadDispatcher::GamepadDispatcher(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(std::move(task_runner)) {}
GamepadDispatcher::GamepadDispatcher(ExecutionContext* context)
: // See https://bit.ly/2S0zRAS for task types.
task_runner_(context ? context->GetTaskRunner(TaskType::kMiscPlatformAPI)
: nullptr) {}
GamepadDispatcher::~GamepadDispatcher() = default;
......
......@@ -10,6 +10,7 @@
#include "base/memory/scoped_refptr.h"
#include "device/gamepad/public/mojom/gamepad.mojom-blink.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/platform_event_dispatcher.h"
#include "third_party/blink/renderer/modules/gamepad/gamepad_listener.h"
......@@ -28,8 +29,7 @@ class GamepadDispatcher final : public GarbageCollected<GamepadDispatcher>,
USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher);
public:
explicit GamepadDispatcher(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
explicit GamepadDispatcher(ExecutionContext* context);
~GamepadDispatcher() override;
void SampleGamepads(device::Gamepads&);
......
......@@ -70,9 +70,7 @@ GamepadHapticActuator::GamepadHapticActuator(
device::GamepadHapticActuatorType type)
: ExecutionContextClient(context),
pad_index_(pad_index),
// See https://bit.ly/2S0zRAS for task types
gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>(
context->GetTaskRunner(TaskType::kMiscPlatformAPI))) {
gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>(context)) {
SetType(type);
}
......
......@@ -195,11 +195,8 @@ NavigatorGamepad::NavigatorGamepad(Navigator& navigator)
ExecutionContextClient(navigator.DomWindow()),
PlatformEventController(
navigator.GetFrame() ? navigator.GetFrame()->GetDocument() : nullptr),
// See https://bit.ly/2S0zRAS for task types
gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>(
navigator.GetFrame() ? navigator.GetFrame()->GetTaskRunner(
blink::TaskType::kMiscPlatformAPI)
: nullptr)) {
gamepad_dispatcher_(
MakeGarbageCollected<GamepadDispatcher>(navigator.DomWindow())) {
if (navigator.DomWindow())
navigator.DomWindow()->RegisterEventListenerObserver(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment