Index: content/browser/gamepad/gamepad_service.cc |
diff --git a/content/browser/gamepad/gamepad_service.cc b/content/browser/gamepad/gamepad_service.cc |
index a2a83b316fab6b9c28103873f954d91bfcdbb7ee..42b1e10821607d112203d281e86698894d2a0f01 100644 |
--- a/content/browser/gamepad/gamepad_service.cc |
+++ b/content/browser/gamepad/gamepad_service.cc |
@@ -15,24 +15,36 @@ |
namespace content { |
+namespace { |
+GamepadService* g_gamepad_service = 0; |
+} |
+ |
GamepadService::GamepadService() |
: num_active_consumers_(0), |
gesture_callback_pending_(false) { |
+ SetInstance(); |
} |
GamepadService::GamepadService(scoped_ptr<GamepadDataFetcher> fetcher) |
: provider_(new GamepadProvider(fetcher.Pass())), |
num_active_consumers_(0), |
gesture_callback_pending_(false) { |
+ SetInstance(); |
thread_checker_.DetachFromThread(); |
} |
GamepadService::~GamepadService() { |
} |
+void GamepadService::SetInstance() { |
+ CHECK(!g_gamepad_service); |
+ g_gamepad_service = this; |
+} |
+ |
GamepadService* GamepadService::GetInstance() { |
- return Singleton<GamepadService, |
- LeakySingletonTraits<GamepadService> >::get(); |
+ if (!g_gamepad_service) |
+ g_gamepad_service = new GamepadService; |
+ return g_gamepad_service; |
} |
void GamepadService::ConsumerBecameActive(GamepadConsumer* consumer) { |
@@ -46,6 +58,7 @@ void GamepadService::ConsumerBecameActive(GamepadConsumer* consumer) { |
insert_result.first->is_active = true; |
if (!insert_result.first->did_observe_user_gesture && |
!gesture_callback_pending_) { |
+ gesture_callback_pending_ = true; |
provider_->RegisterForUserGesture( |
base::Bind(&GamepadService::OnUserGesture, |
base::Unretained(this))); |