OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/gamepad_shared_memory_reader.h" | 5 #include "content/renderer/gamepad_shared_memory_reader.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "content/common/gamepad_hardware_buffer.h" |
9 #include "content/common/gamepad_user_gesture.h" | 10 #include "content/common/gamepad_user_gesture.h" |
10 #include "content/public/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
11 #include "content/common/gamepad_hardware_buffer.h" | 12 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
12 #include "ipc/ipc_sync_message_filter.h" | 13 #include "ipc/ipc_sync_message_filter.h" |
13 #include "third_party/WebKit/public/platform/WebGamepadListener.h" | 14 #include "third_party/WebKit/public/platform/WebGamepadListener.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 GamepadSharedMemoryReader::GamepadSharedMemoryReader() | 18 GamepadSharedMemoryReader::GamepadSharedMemoryReader( |
| 19 RendererWebKitPlatformSupportImpl* webkit_platform_support) |
18 : gamepad_hardware_buffer_(NULL), | 20 : gamepad_hardware_buffer_(NULL), |
19 gamepad_listener_(NULL), | 21 gamepad_listener_(NULL), |
20 is_polling_(false), | 22 is_polling_(false), |
21 ever_interacted_with_(false) { | 23 ever_interacted_with_(false) { |
| 24 webkit_platform_support->set_gamepad_provider(this); |
22 } | 25 } |
23 | 26 |
24 void GamepadSharedMemoryReader::StartPollingIfNecessary() { | 27 void GamepadSharedMemoryReader::StartPollingIfNecessary() { |
25 if (is_polling_) | 28 if (is_polling_) |
26 return; | 29 return; |
27 | 30 |
28 CHECK(RenderThread::Get()->Send(new GamepadHostMsg_StartPolling( | 31 CHECK(RenderThread::Get()->Send(new GamepadHostMsg_StartPolling( |
29 &renderer_shared_memory_handle_))); | 32 &renderer_shared_memory_handle_))); |
30 | 33 |
31 // If we don't get a valid handle from the browser, don't try to Map (we're | 34 // If we don't get a valid handle from the browser, don't try to Map (we're |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 151 } |
149 | 152 |
150 void GamepadSharedMemoryReader::OnGamepadDisconnected( | 153 void GamepadSharedMemoryReader::OnGamepadDisconnected( |
151 int index, | 154 int index, |
152 const blink::WebGamepad& gamepad) { | 155 const blink::WebGamepad& gamepad) { |
153 if (gamepad_listener_) | 156 if (gamepad_listener_) |
154 gamepad_listener_->didDisconnectGamepad(index, gamepad); | 157 gamepad_listener_->didDisconnectGamepad(index, gamepad); |
155 } | 158 } |
156 | 159 |
157 } // namespace content | 160 } // namespace content |
OLD | NEW |