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

Unified Diff: chrome/browser/chromeos/login/existing_user_controller_browsertest.cc

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trailing space Created 7 years, 3 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: chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
diff --git a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
index e327615d46e5ad4e9ac070812ce229380e36908e..33aae889ea89baa1809a94c2711ec4f5048fd9eb 100644
--- a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/location.h"
+#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/authenticator.h"
@@ -452,40 +453,34 @@ class ExistingUserControllerPublicSessionTest
.Times(0);
}
- scoped_ptr<base::RunLoop> CreateSettingsObserverRunLoop(
- content::MockNotificationObserver& observer, const char* setting) {
- base::RunLoop* loop = new base::RunLoop;
- EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED,
- _, HasDetails(setting)))
- .Times(1)
- .WillOnce(InvokeWithoutArgs(loop, &base::RunLoop::Quit));
- CrosSettings::Get()->AddSettingsObserver(setting, &observer);
- return make_scoped_ptr(loop);
- }
-
void SetAutoLoginPolicy(const std::string& username, int delay) {
// Wait until ExistingUserController has finished auto-login
// configuration by observing the same settings that trigger
// ConfigurePublicSessionAutoLogin.
- content::MockNotificationObserver observer;
em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
// If both settings have changed we need to wait for both to
// propagate, so check the new values against the old ones.
- scoped_ptr<base::RunLoop> runner1;
+ scoped_refptr<content::MessageLoopRunner> runner1;
+ scoped_ptr<CrosSettings::ObserverSubscription> subscription1;
if (!proto.has_device_local_accounts() ||
!proto.device_local_accounts().has_auto_login_id() ||
proto.device_local_accounts().auto_login_id() != username) {
- runner1 = CreateSettingsObserverRunLoop(
- observer, kAccountsPrefDeviceLocalAccountAutoLoginId);
+ runner1 = new content::MessageLoopRunner;
+ subscription1 = chromeos::CrosSettings::Get()->AddSettingsObserver(
+ chromeos::kAccountsPrefDeviceLocalAccountAutoLoginId,
+ runner1->QuitClosure());
}
- scoped_ptr<base::RunLoop> runner2;
+ scoped_refptr<content::MessageLoopRunner> runner2;
+ scoped_ptr<CrosSettings::ObserverSubscription> subscription2;
if (!proto.has_device_local_accounts() ||
!proto.device_local_accounts().has_auto_login_delay() ||
proto.device_local_accounts().auto_login_delay() != delay) {
- runner2 = CreateSettingsObserverRunLoop(
- observer, kAccountsPrefDeviceLocalAccountAutoLoginDelay);
+ runner1 = new content::MessageLoopRunner;
+ subscription1 = chromeos::CrosSettings::Get()->AddSettingsObserver(
+ chromeos::kAccountsPrefDeviceLocalAccountAutoLoginDelay,
+ runner1->QuitClosure());
}
// Update the policy.
@@ -494,18 +489,10 @@ class ExistingUserControllerPublicSessionTest
RefreshDevicePolicy();
// Wait for ExistingUserController to read the updated settings.
- if (runner1)
+ if (runner1.get())
runner1->Run();
- if (runner2)
+ if (runner2.get())
runner2->Run();
-
- // Clean up.
- CrosSettings::Get()->RemoveSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginId,
- &observer);
- CrosSettings::Get()->RemoveSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginDelay,
- &observer);
}
void ConfigureAutoLogin() {

Powered by Google App Engine
This is Rietveld 408576698