OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
11 #include "content/common/gamepad_messages.h" | 12 #include "content/common/gamepad_messages.h" |
12 #include "content/public/renderer/renderer_gamepad_provider.h" | 13 #include "content/public/renderer/renderer_gamepad_provider.h" |
13 #include "third_party/WebKit/public/platform/WebGamepads.h" | 14 #include "third_party/WebKit/public/platform/WebGamepads.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 struct GamepadHardwareBuffer; | 18 struct GamepadHardwareBuffer; |
18 | 19 |
19 class GamepadSharedMemoryReader : public RendererGamepadProvider { | 20 class GamepadSharedMemoryReader : public RendererGamepadProvider { |
20 public: | 21 public: |
21 explicit GamepadSharedMemoryReader(RenderThread* thread); | 22 explicit GamepadSharedMemoryReader(RenderThread* thread); |
22 ~GamepadSharedMemoryReader() override; | 23 ~GamepadSharedMemoryReader() override; |
23 | 24 |
24 // RendererGamepadProvider implementation. | 25 // RendererGamepadProvider implementation. |
25 void SampleGamepads(blink::WebGamepads& gamepads) override; | 26 void SampleGamepads(blink::WebGamepads& gamepads) override; |
26 bool OnControlMessageReceived(const IPC::Message& message) override; | 27 bool OnControlMessageReceived(const IPC::Message& message) override; |
27 void Start(blink::WebPlatformEventListener* listener) override; | 28 void Start(blink::WebPlatformEventListener* listener) override; |
28 | 29 |
29 protected: | 30 protected: |
30 // PlatformEventObserver protected methods. | 31 // PlatformEventObserver protected methods. |
31 void SendStartMessage() override; | 32 void SendStartMessage() override; |
32 void SendStopMessage() override; | 33 void SendStopMessage() override; |
33 | 34 |
34 private: | 35 private: |
35 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); | 36 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); |
36 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); | 37 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); |
37 | 38 |
38 base::SharedMemoryHandle renderer_shared_memory_handle_; | 39 base::SharedMemoryHandle renderer_shared_memory_handle_; |
39 scoped_ptr<base::SharedMemory> renderer_shared_memory_; | 40 std::unique_ptr<base::SharedMemory> renderer_shared_memory_; |
40 GamepadHardwareBuffer* gamepad_hardware_buffer_; | 41 GamepadHardwareBuffer* gamepad_hardware_buffer_; |
41 | 42 |
42 bool ever_interacted_with_; | 43 bool ever_interacted_with_; |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); | 45 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); |
45 }; | 46 }; |
46 | 47 |
47 } // namespace content | 48 } // namespace content |
48 | 49 |
49 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 50 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
OLD | NEW |