Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1226)

Unified Diff: content/browser/renderer_host/gamepad_browser_message_filter.cc

Issue 195873019: Gamepad API: add support for connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and a missing override Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698