Chromium Code Reviews| Index: chrome/browser/policy/cloud_policy_subsystem.cc |
| diff --git a/chrome/browser/policy/cloud_policy_subsystem.cc b/chrome/browser/policy/cloud_policy_subsystem.cc |
| index 5ed979a967586a8f55deff175d9f729c90f50605..be960bd5485c33e97f62d11694a5e3fdfc5a8baa 100644 |
| --- a/chrome/browser/policy/cloud_policy_subsystem.cc |
| +++ b/chrome/browser/policy/cloud_policy_subsystem.cc |
| @@ -8,6 +8,7 @@ |
| #include <string> |
| #include "base/command_line.h" |
| +#include "chrome/browser/browser_process.h" |
| #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| #include "chrome/browser/policy/cloud_policy_controller.h" |
| #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
| @@ -50,8 +51,7 @@ CloudPolicySubsystem::ObserverRegistrar::~ObserverRegistrar() { |
| CloudPolicySubsystem::CloudPolicySubsystem( |
| CloudPolicyIdentityStrategy* identity_strategy, |
| - CloudPolicyCacheBase* policy_cache) |
| - : prefs_(NULL) { |
| + CloudPolicyCacheBase* policy_cache) { |
| net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| notifier_.reset(new PolicyNotifier()); |
| CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| @@ -77,7 +77,6 @@ CloudPolicySubsystem::CloudPolicySubsystem( |
| } |
| CloudPolicySubsystem::~CloudPolicySubsystem() { |
| - DCHECK(!prefs_); |
| cloud_policy_controller_.reset(); |
| device_token_fetcher_.reset(); |
| cloud_policy_cache_.reset(); |
| @@ -92,16 +91,19 @@ void CloudPolicySubsystem::OnIPAddressChanged() { |
| } |
| } |
| -void CloudPolicySubsystem::Initialize( |
| - PrefService* prefs, |
| +void CloudPolicySubsystem::Initialize(const char* policy_refresh_name, |
|
Mattias Nissler (ping if slow)
2011/05/13 09:45:03
Indentation
sfeuz
2011/05/17 14:27:42
Done.
|
| net::URLRequestContextGetter* request_context) { |
| - DCHECK(!prefs_); |
| - prefs_ = prefs; |
| - |
| if (device_management_service_.get()) |
| device_management_service_->Initialize(request_context); |
| - policy_refresh_rate_.Init(prefs::kPolicyRefreshRate, prefs_, this); |
| + DCHECK(std::string(policy_refresh_name) == |
| + std::string(prefs::kUserPolicyRefreshRate) || |
| + std::string(policy_refresh_name) == |
| + std::string(prefs::kDevicePolicyRefreshRate)); |
|
Mattias Nissler (ping if slow)
2011/05/13 09:45:03
Why this DCHECK? The subsystem doesn't care what p
sfeuz
2011/05/17 14:27:42
Done.
|
| + policy_refresh_rate_.Init(policy_refresh_name, |
| + g_browser_process->local_state(), |
| + this); |
| + |
| UpdatePolicyRefreshRate(); |
| } |
| @@ -111,7 +113,6 @@ void CloudPolicySubsystem::Shutdown() { |
| cloud_policy_controller_.reset(); |
| cloud_policy_cache_.reset(); |
| policy_refresh_rate_.Destroy(); |
| - prefs_ = NULL; |
| } |
| CloudPolicySubsystem::PolicySubsystemState CloudPolicySubsystem::state() { |
| @@ -144,7 +145,10 @@ ConfigurationPolicyProvider* |
| // static |
| void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) { |
| - pref_service->RegisterIntegerPref(prefs::kPolicyRefreshRate, |
| + pref_service->RegisterIntegerPref(prefs::kDevicePolicyRefreshRate, |
| + kDefaultPolicyRefreshRateMs, |
| + PrefService::UNSYNCABLE_PREF); |
| + pref_service->RegisterIntegerPref(prefs::kUserPolicyRefreshRate, |
| kDefaultPolicyRefreshRateMs, |
| PrefService::UNSYNCABLE_PREF); |
| } |
| @@ -164,8 +168,9 @@ void CloudPolicySubsystem::Observe(NotificationType type, |
| const NotificationDetails& details) { |
| if (type == NotificationType::PREF_CHANGED && |
| policy_refresh_rate_.GetPrefName() == |
| - *(Details<std::string>(details).ptr()) && |
| - prefs_ == Source<PrefService>(source).ptr()) { |
| + *(Details<std::string>(details).ptr())) { |
| + DCHECK(Source<PrefService>(source).ptr() == |
|
Mattias Nissler (ping if slow)
2011/05/13 09:45:03
Why not use DCHECK_EQ?
sfeuz
2011/05/17 14:27:42
Done.
|
| + g_browser_process->local_state()); |
| UpdatePolicyRefreshRate(); |
| } else { |
| NOTREACHED(); |