Index: content/browser/renderer_host/gamepad_browser_message_filter.cc |
diff --git a/content/browser/renderer_host/gamepad_browser_message_filter.cc b/content/browser/renderer_host/gamepad_browser_message_filter.cc |
index e6e05f66e6856340712585cf7b6254652089acbe..f616a74b831c5cc106ac4f61f609c3b1788e0bb1 100644 |
--- a/content/browser/renderer_host/gamepad_browser_message_filter.cc |
+++ b/content/browser/renderer_host/gamepad_browser_message_filter.cc |
@@ -17,7 +17,7 @@ GamepadBrowserMessageFilter::GamepadBrowserMessageFilter() |
GamepadBrowserMessageFilter::~GamepadBrowserMessageFilter() { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
if (is_started_) |
- GamepadService::GetInstance()->RemoveConsumer(); |
+ GamepadService::GetInstance()->RemoveConsumer(this); |
} |
bool GamepadBrowserMessageFilter::OnMessageReceived( |
@@ -34,28 +34,31 @@ bool GamepadBrowserMessageFilter::OnMessageReceived( |
return handled; |
} |
+void GamepadBrowserMessageFilter::OnGamepadConnected( |
+ unsigned index, |
+ const blink::WebGamepad& gamepad) { |
+ Send(new GamepadMsg_GamepadConnected(index, gamepad)); |
+} |
+ |
+void GamepadBrowserMessageFilter::OnGamepadDisconnected( |
+ unsigned index, |
+ const blink::WebGamepad& gamepad) { |
+ Send(new GamepadMsg_GamepadDisconnected(index, gamepad)); |
+} |
+ |
void GamepadBrowserMessageFilter::OnGamepadStartPolling( |
base::SharedMemoryHandle* renderer_handle) { |
GamepadService* service = GamepadService::GetInstance(); |
- if (!is_started_) { |
- is_started_ = true; |
- service->AddConsumer(); |
- *renderer_handle = service->GetSharedMemoryHandleForProcess(PeerHandle()); |
- } else { |
- // Currently we only expect the renderer to tell us once to start. |
- NOTREACHED(); |
- } |
+ CHECK(!is_started_); |
+ is_started_ = true; |
+ service->ConsumerBecameActive(this); |
+ *renderer_handle = service->GetSharedMemoryHandleForProcess(PeerHandle()); |
} |
void GamepadBrowserMessageFilter::OnGamepadStopPolling() { |
- // TODO(scottmg): Probably get rid of this message. We can't trust it will |
- // arrive anyway if the renderer crashes, etc. |
- if (is_started_) { |
- is_started_ = false; |
- GamepadService::GetInstance()->RemoveConsumer(); |
- } else { |
- NOTREACHED(); |
- } |
+ CHECK(is_started_); |
+ is_started_ = false; |
+ GamepadService::GetInstance()->ConsumerBecameInactive(this); |
} |
} // namespace content |