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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "content/common/gamepad_messages.h" | 10 #include "content/common/gamepad_messages.h" |
11 #include "content/public/renderer/render_process_observer.h" | |
12 #include "content/public/renderer/renderer_gamepad_provider.h" | 11 #include "content/public/renderer/renderer_gamepad_provider.h" |
13 #include "third_party/WebKit/public/platform/WebGamepads.h" | 12 #include "third_party/WebKit/public/platform/WebGamepads.h" |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 struct GamepadHardwareBuffer; | 16 struct GamepadHardwareBuffer; |
18 class RendererWebKitPlatformSupportImpl; | |
19 | 17 |
20 class GamepadSharedMemoryReader | 18 class GamepadSharedMemoryReader : public RendererGamepadProvider { |
21 : public RenderProcessObserver, | |
22 public RendererGamepadProvider { | |
23 public: | 19 public: |
24 GamepadSharedMemoryReader( | 20 explicit GamepadSharedMemoryReader(RenderThread* thread); |
25 RendererWebKitPlatformSupportImpl* webkit_platform_support); | |
26 virtual ~GamepadSharedMemoryReader(); | 21 virtual ~GamepadSharedMemoryReader(); |
27 | 22 |
28 // RendererGamepadProvider implementation. | 23 // RendererGamepadProvider implementation. |
29 virtual void SampleGamepads( | 24 virtual void SampleGamepads( |
30 blink::WebGamepads& gamepads) OVERRIDE; | 25 blink::WebGamepads& gamepads) OVERRIDE; |
31 virtual void SetGamepadListener( | 26 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
32 blink::WebGamepadListener* listener) OVERRIDE; | 27 virtual void Start(blink::WebPlatformEventListener* listener) OVERRIDE; |
33 | 28 |
34 // RenderProcessObserver implementation. | 29 protected: |
35 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 30 // PlatformEventObserver protected methods. |
| 31 virtual void SendStartMessage() OVERRIDE; |
| 32 virtual void SendStopMessage() OVERRIDE; |
36 | 33 |
37 private: | 34 private: |
38 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); | 35 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); |
39 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); | 36 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); |
40 | 37 |
41 void StartPollingIfNecessary(); | |
42 void StopPollingIfNecessary(); | |
43 | |
44 base::SharedMemoryHandle renderer_shared_memory_handle_; | 38 base::SharedMemoryHandle renderer_shared_memory_handle_; |
45 scoped_ptr<base::SharedMemory> renderer_shared_memory_; | 39 scoped_ptr<base::SharedMemory> renderer_shared_memory_; |
46 GamepadHardwareBuffer* gamepad_hardware_buffer_; | 40 GamepadHardwareBuffer* gamepad_hardware_buffer_; |
47 blink::WebGamepadListener* gamepad_listener_; | |
48 | 41 |
49 bool is_polling_; | |
50 bool ever_interacted_with_; | 42 bool ever_interacted_with_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); |
51 }; | 45 }; |
52 | 46 |
53 } // namespace content | 47 } // namespace content |
54 | 48 |
55 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 49 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
OLD | NEW |