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/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "content/public/common/service_names.mojom.h" |
9 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
10 #include "content/renderer/renderer_blink_platform_impl.h" | 11 #include "content/renderer/renderer_blink_platform_impl.h" |
11 #include "ipc/ipc_sync_message_filter.h" | 12 #include "ipc/ipc_sync_message_filter.h" |
12 #include "services/service_manager/public/cpp/interface_provider.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
13 #include "third_party/WebKit/public/platform/WebGamepadListener.h" | 14 #include "third_party/WebKit/public/platform/WebGamepadListener.h" |
14 #include "third_party/WebKit/public/platform/WebPlatformEventListener.h" | 15 #include "third_party/WebKit/public/platform/WebPlatformEventListener.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 GamepadSharedMemoryReader::GamepadSharedMemoryReader(RenderThread* thread) | 19 GamepadSharedMemoryReader::GamepadSharedMemoryReader(RenderThread* thread) |
19 : RendererGamepadProvider(thread), | 20 : RendererGamepadProvider(thread), |
20 gamepad_hardware_buffer_(NULL), | 21 gamepad_hardware_buffer_(NULL), |
21 ever_interacted_with_(false), | 22 ever_interacted_with_(false), |
22 binding_(this) { | 23 binding_(this) { |
23 if (thread) { | 24 if (thread) { |
24 thread->GetRemoteInterfaces()->GetInterface( | 25 thread->GetConnector()->BindInterface(mojom::kBrowserServiceName, |
25 mojo::MakeRequest(&gamepad_monitor_)); | 26 mojo::MakeRequest(&gamepad_monitor_)); |
26 gamepad_monitor_->SetObserver(binding_.CreateInterfacePtrAndBind()); | 27 gamepad_monitor_->SetObserver(binding_.CreateInterfacePtrAndBind()); |
27 } | 28 } |
28 } | 29 } |
29 | 30 |
30 void GamepadSharedMemoryReader::SendStartMessage() { | 31 void GamepadSharedMemoryReader::SendStartMessage() { |
31 if (gamepad_monitor_) { | 32 if (gamepad_monitor_) { |
32 gamepad_monitor_->GamepadStartPolling(&renderer_shared_buffer_handle_); | 33 gamepad_monitor_->GamepadStartPolling(&renderer_shared_buffer_handle_); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 127 } |
127 | 128 |
128 void GamepadSharedMemoryReader::GamepadDisconnected( | 129 void GamepadSharedMemoryReader::GamepadDisconnected( |
129 int index, | 130 int index, |
130 const blink::WebGamepad& gamepad) { | 131 const blink::WebGamepad& gamepad) { |
131 if (listener()) | 132 if (listener()) |
132 listener()->didDisconnectGamepad(index, gamepad); | 133 listener()->didDisconnectGamepad(index, gamepad); |
133 } | 134 } |
134 | 135 |
135 } // namespace content | 136 } // namespace content |
OLD | NEW |