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

Unified Diff: content/browser/gamepad/gamepad_service.cc

Issue 362123002: Gamepad: don't notify about connected pads twice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more build fix (kNumberOfGamepads) Created 6 years, 6 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
« no previous file with comments | « content/browser/gamepad/gamepad_service.h ('k') | content/browser/gamepad/gamepad_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)));
« no previous file with comments | « content/browser/gamepad/gamepad_service.h ('k') | content/browser/gamepad/gamepad_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698