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( ...@@ -40,9 +40,10 @@ void GamepadDispatcher::ResetVibrationActuator(
std::move(callback)); std::move(callback));
} }
GamepadDispatcher::GamepadDispatcher( GamepadDispatcher::GamepadDispatcher(ExecutionContext* context)
scoped_refptr<base::SingleThreadTaskRunner> task_runner) : // See https://bit.ly/2S0zRAS for task types.
: task_runner_(std::move(task_runner)) {} task_runner_(context ? context->GetTaskRunner(TaskType::kMiscPlatformAPI)
: nullptr) {}
GamepadDispatcher::~GamepadDispatcher() = default; GamepadDispatcher::~GamepadDispatcher() = default;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "device/gamepad/public/mojom/gamepad.mojom-blink.h" #include "device/gamepad/public/mojom/gamepad.mojom-blink.h"
#include "mojo/public/cpp/bindings/remote.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/core/frame/platform_event_dispatcher.h"
#include "third_party/blink/renderer/modules/gamepad/gamepad_listener.h" #include "third_party/blink/renderer/modules/gamepad/gamepad_listener.h"
...@@ -28,8 +29,7 @@ class GamepadDispatcher final : public GarbageCollected<GamepadDispatcher>, ...@@ -28,8 +29,7 @@ class GamepadDispatcher final : public GarbageCollected<GamepadDispatcher>,
USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher); USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher);
public: public:
explicit GamepadDispatcher( explicit GamepadDispatcher(ExecutionContext* context);
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~GamepadDispatcher() override; ~GamepadDispatcher() override;
void SampleGamepads(device::Gamepads&); void SampleGamepads(device::Gamepads&);
......
...@@ -70,9 +70,7 @@ GamepadHapticActuator::GamepadHapticActuator( ...@@ -70,9 +70,7 @@ GamepadHapticActuator::GamepadHapticActuator(
device::GamepadHapticActuatorType type) device::GamepadHapticActuatorType type)
: ExecutionContextClient(context), : ExecutionContextClient(context),
pad_index_(pad_index), pad_index_(pad_index),
// See https://bit.ly/2S0zRAS for task types gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>(context)) {
gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>(
context->GetTaskRunner(TaskType::kMiscPlatformAPI))) {
SetType(type); SetType(type);
} }
......
...@@ -195,11 +195,8 @@ NavigatorGamepad::NavigatorGamepad(Navigator& navigator) ...@@ -195,11 +195,8 @@ NavigatorGamepad::NavigatorGamepad(Navigator& navigator)
ExecutionContextClient(navigator.DomWindow()), ExecutionContextClient(navigator.DomWindow()),
PlatformEventController( PlatformEventController(
navigator.GetFrame() ? navigator.GetFrame()->GetDocument() : nullptr), navigator.GetFrame() ? navigator.GetFrame()->GetDocument() : nullptr),
// See https://bit.ly/2S0zRAS for task types gamepad_dispatcher_(
gamepad_dispatcher_(MakeGarbageCollected<GamepadDispatcher>( MakeGarbageCollected<GamepadDispatcher>(navigator.DomWindow())) {
navigator.GetFrame() ? navigator.GetFrame()->GetTaskRunner(
blink::TaskType::kMiscPlatformAPI)
: nullptr)) {
if (navigator.DomWindow()) if (navigator.DomWindow())
navigator.DomWindow()->RegisterEventListenerObserver(this); 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