| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | |
| 6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "content/public/renderer/renderer_gamepad_provider.h" | |
| 12 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" | |
| 13 #include "device/gamepad/public/interfaces/gamepad.mojom.h" | |
| 14 #include "mojo/public/cpp/bindings/binding.h" | |
| 15 #include "mojo/public/cpp/system/buffer.h" | |
| 16 #include "third_party/WebKit/public/platform/WebGamepads.h" | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 typedef device::SharedMemorySeqLockBuffer<blink::WebGamepads> | |
| 21 GamepadHardwareBuffer; | |
| 22 | |
| 23 class GamepadSharedMemoryReader : public RendererGamepadProvider, | |
| 24 public device::mojom::GamepadObserver { | |
| 25 public: | |
| 26 explicit GamepadSharedMemoryReader(RenderThread* thread); | |
| 27 ~GamepadSharedMemoryReader() override; | |
| 28 | |
| 29 // RendererGamepadProvider implementation. | |
| 30 void SampleGamepads(blink::WebGamepads& gamepads) override; | |
| 31 void Start(blink::WebPlatformEventListener* listener) override; | |
| 32 | |
| 33 protected: | |
| 34 // PlatformEventObserver protected methods. | |
| 35 void SendStartMessage() override; | |
| 36 void SendStopMessage() override; | |
| 37 | |
| 38 private: | |
| 39 // device::mojom::GamepadObserver methods. | |
| 40 void GamepadConnected(int index, const blink::WebGamepad& gamepad) override; | |
| 41 void GamepadDisconnected(int index, | |
| 42 const blink::WebGamepad& gamepad) override; | |
| 43 | |
| 44 mojo::ScopedSharedBufferHandle renderer_shared_buffer_handle_; | |
| 45 mojo::ScopedSharedBufferMapping renderer_shared_buffer_mapping_; | |
| 46 GamepadHardwareBuffer* gamepad_hardware_buffer_; | |
| 47 | |
| 48 bool ever_interacted_with_; | |
| 49 | |
| 50 mojo::Binding<device::mojom::GamepadObserver> binding_; | |
| 51 device::mojom::GamepadMonitorPtr gamepad_monitor_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 | |
| 58 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | |
| OLD | NEW |