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 683bff58c2598233ab5b79345fc0783b4227def2..136a4ff3a7fdb2d14995deff2a8614fa0bf5e84c 100644 |
--- a/content/browser/renderer_host/gamepad_browser_message_filter.cc |
+++ b/content/browser/renderer_host/gamepad_browser_message_filter.cc |
@@ -4,9 +4,15 @@ |
#include "content/browser/renderer_host/gamepad_browser_message_filter.h" |
+#include "content/browser/gamepad/gamepad_service.h" |
#include "content/common/gamepad_messages.h" |
-GamepadBrowserMessageFilter::GamepadBrowserMessageFilter() { |
+namespace content { |
+ |
+GamepadBrowserMessageFilter::GamepadBrowserMessageFilter( |
+ content::RenderProcessHost* render_process_host) |
+ : gamepad_service_(NULL), |
+ render_process_host_(render_process_host) { |
} |
GamepadBrowserMessageFilter::~GamepadBrowserMessageFilter() { |
@@ -28,14 +34,15 @@ bool GamepadBrowserMessageFilter::OnMessageReceived( |
void GamepadBrowserMessageFilter::OnGamepadStartPolling( |
base::SharedMemoryHandle* renderer_handle) { |
- if (!provider_) { |
- provider_ = new content::GamepadProvider(NULL); |
- provider_->Start(); |
- } |
- *renderer_handle = provider_->GetRendererSharedMemoryHandle(peer_handle()); |
+ if (!gamepad_service_) |
+ gamepad_service_ = GamepadService::GetInstance(); |
+ gamepad_service_->Start(NULL, render_process_host_); |
+ *renderer_handle = gamepad_service_->GetSharedMemoryHandle(peer_handle()); |
} |
void GamepadBrowserMessageFilter::OnGamepadStopPolling() { |
- // TODO(scottmg) Remove this message entirely? |
- // Stop is currently handled by the refcount on provider_. |
+ // TODO(scottmg): Probably get rid of this message. We can't trust it will |
+ // arrive anyway if the renderer crashes, etc. |
} |
+ |
+} // namespace content |