| 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" | 11 #include "content/public/renderer/render_process_observer.h" |
| 12 #include "content/public/renderer/renderer_gamepad_provider.h" |
| 12 #include "third_party/WebKit/public/platform/WebGamepads.h" | 13 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 13 | 14 |
| 14 namespace blink { class WebGamepadListener; } | |
| 15 | |
| 16 namespace content { | 15 namespace content { |
| 17 | 16 |
| 18 struct GamepadHardwareBuffer; | 17 struct GamepadHardwareBuffer; |
| 18 class RendererWebKitPlatformSupportImpl; |
| 19 | 19 |
| 20 class GamepadSharedMemoryReader : public RenderProcessObserver { | 20 // Renderer side of gamepad implementation. |
| 21 // Notifies the browser about demand of gamepad data. Reads gamepad state from |
| 22 // shared memory. Recieves gamepad events. |
| 23 class GamepadSharedMemoryReader |
| 24 : public RenderProcessObserver |
| 25 , public RendererGamepadProvider { |
| 21 public: | 26 public: |
| 22 GamepadSharedMemoryReader(); | 27 GamepadSharedMemoryReader( |
| 28 RendererWebKitPlatformSupportImpl* webkit_platform_support); |
| 23 virtual ~GamepadSharedMemoryReader(); | 29 virtual ~GamepadSharedMemoryReader(); |
| 24 | 30 |
| 25 void SampleGamepads(blink::WebGamepads& gamepads); | 31 // RendererGamepadProvider implementation. |
| 26 void SetGamepadListener(blink::WebGamepadListener* listener); | 32 virtual void SampleGamepads(blink::WebGamepads& gamepads) OVERRIDE; |
| 33 virtual void SetGamepadListener( |
| 34 blink::WebGamepadListener* listener) OVERRIDE; |
| 27 | 35 |
| 28 // RenderProcessObserver implementation. | 36 // RenderProcessObserver implementation. |
| 29 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 37 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 30 | 38 |
| 31 private: | 39 private: |
| 32 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); | 40 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); |
| 33 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); | 41 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); |
| 34 | 42 |
| 35 void StartPollingIfNecessary(); | 43 void StartPollingIfNecessary(); |
| 36 void StopPollingIfNecessary(); | 44 void StopPollingIfNecessary(); |
| 37 | 45 |
| 38 base::SharedMemoryHandle renderer_shared_memory_handle_; | 46 base::SharedMemoryHandle renderer_shared_memory_handle_; |
| 39 scoped_ptr<base::SharedMemory> renderer_shared_memory_; | 47 scoped_ptr<base::SharedMemory> renderer_shared_memory_; |
| 40 GamepadHardwareBuffer* gamepad_hardware_buffer_; | 48 GamepadHardwareBuffer* gamepad_hardware_buffer_; |
| 41 blink::WebGamepadListener* gamepad_listener_; | 49 blink::WebGamepadListener* gamepad_listener_; |
| 42 | 50 |
| 43 bool is_polling_; | 51 bool is_polling_; |
| 44 bool ever_interacted_with_; | 52 bool ever_interacted_with_; |
| 45 }; | 53 }; |
| 46 | 54 |
| 47 } // namespace content | 55 } // namespace content |
| 48 | 56 |
| 49 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 57 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
| OLD | NEW |