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

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

Issue 372053004: Fix PepperGamepadHostTest.WaitForReply (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 6 years, 5 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') | tools/valgrind/gtest_exclude/content_unittests.gtest.txt » ('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 42b1e10821607d112203d281e86698894d2a0f01..67930f6118d16de2468d3d3968b68fb5abbec077 100644
--- a/content/browser/gamepad/gamepad_service.cc
+++ b/content/browser/gamepad/gamepad_service.cc
@@ -22,23 +22,27 @@ GamepadService* g_gamepad_service = 0;
GamepadService::GamepadService()
: num_active_consumers_(0),
gesture_callback_pending_(false) {
- SetInstance();
+ SetInstance(this);
}
GamepadService::GamepadService(scoped_ptr<GamepadDataFetcher> fetcher)
: provider_(new GamepadProvider(fetcher.Pass())),
num_active_consumers_(0),
gesture_callback_pending_(false) {
- SetInstance();
+ SetInstance(this);
thread_checker_.DetachFromThread();
}
GamepadService::~GamepadService() {
+ SetInstance(NULL);
}
-void GamepadService::SetInstance() {
- CHECK(!g_gamepad_service);
- g_gamepad_service = this;
+void GamepadService::SetInstance(GamepadService* instance) {
+ // Unit tests can create multiple instances but only one should exist at any
+ // given time so g_gamepad_service should only go from NULL to non-NULL and
+ // vica versa.
+ CHECK(!!instance != !!g_gamepad_service);
+ g_gamepad_service = instance;
}
GamepadService* GamepadService::GetInstance() {
« no previous file with comments | « content/browser/gamepad/gamepad_service.h ('k') | tools/valgrind/gtest_exclude/content_unittests.gtest.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698