| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "chrome/browser/policy/cloud_policy_subsystem.h" |    5 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <string> |    8 #include <string> | 
|    9  |    9  | 
|   10 #include "base/command_line.h" |   10 #include "base/command_line.h" | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   96     DCHECK(cloud_policy_cache_.get()); |   96     DCHECK(cloud_policy_cache_.get()); | 
|   97     DCHECK(device_token_fetcher_.get()); |   97     DCHECK(device_token_fetcher_.get()); | 
|   98  |   98  | 
|   99     refresh_pref_name_ = refresh_pref_name; |   99     refresh_pref_name_ = refresh_pref_name; | 
|  100     CreateCloudPolicyController(); |  100     CreateCloudPolicyController(); | 
|  101     device_management_service_->ScheduleInitialization(delay_milliseconds); |  101     device_management_service_->ScheduleInitialization(delay_milliseconds); | 
|  102  |  102  | 
|  103     PrefService* local_state = g_browser_process->local_state(); |  103     PrefService* local_state = g_browser_process->local_state(); | 
|  104     DCHECK(pref_change_registrar_.IsEmpty()); |  104     DCHECK(pref_change_registrar_.IsEmpty()); | 
|  105     pref_change_registrar_.Init(local_state); |  105     pref_change_registrar_.Init(local_state); | 
|  106     pref_change_registrar_.Add(refresh_pref_name_, this); |  106     pref_change_registrar_.Add( | 
 |  107         refresh_pref_name_, | 
 |  108         base::Bind(&CloudPolicySubsystem::OnRefreshPrefChanged, | 
 |  109                    base::Unretained(this))); | 
|  107     UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); |  110     UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); | 
|  108   } |  111   } | 
|  109 } |  112 } | 
|  110  |  113  | 
|  111 void CloudPolicySubsystem::Shutdown() { |  114 void CloudPolicySubsystem::Shutdown() { | 
|  112   if (device_management_service_.get()) |  115   if (device_management_service_.get()) | 
|  113     device_management_service_->Shutdown(); |  116     device_management_service_->Shutdown(); | 
|  114   cloud_policy_controller_.reset(); |  117   cloud_policy_controller_.reset(); | 
|  115   cloud_policy_cache_.reset(); |  118   cloud_policy_cache_.reset(); | 
|  116   pref_change_registrar_.RemoveAll(); |  119   pref_change_registrar_.RemoveAll(); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  151  |  154  | 
|  152 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { |  155 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { | 
|  153   if (cloud_policy_controller_.get()) { |  156   if (cloud_policy_controller_.get()) { | 
|  154     // Clamp to sane values. |  157     // Clamp to sane values. | 
|  155     refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); |  158     refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); | 
|  156     refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); |  159     refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); | 
|  157     cloud_policy_controller_->SetRefreshRate(refresh_rate); |  160     cloud_policy_controller_->SetRefreshRate(refresh_rate); | 
|  158   } |  161   } | 
|  159 } |  162 } | 
|  160  |  163  | 
|  161 void CloudPolicySubsystem::OnPreferenceChanged(PrefServiceBase* service, |  164 void CloudPolicySubsystem::OnRefreshPrefChanged() { | 
|  162                                                const std::string& pref_name) { |  | 
|  163   DCHECK_EQ(pref_name, refresh_pref_name_); |  | 
|  164   PrefService* local_state = g_browser_process->local_state(); |  165   PrefService* local_state = g_browser_process->local_state(); | 
|  165   DCHECK_EQ(service, local_state); |  | 
|  166   UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); |  166   UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); | 
|  167 } |  167 } | 
|  168  |  168  | 
|  169 void CloudPolicySubsystem::ScheduleServiceInitialization( |  169 void CloudPolicySubsystem::ScheduleServiceInitialization( | 
|  170     int64 delay_milliseconds) { |  170     int64 delay_milliseconds) { | 
|  171   if (device_management_service_.get()) |  171   if (device_management_service_.get()) | 
|  172     device_management_service_->ScheduleInitialization(delay_milliseconds); |  172     device_management_service_->ScheduleInitialization(delay_milliseconds); | 
|  173 } |  173 } | 
|  174  |  174  | 
|  175  |  175  | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  194 CloudPolicyCacheBase* CloudPolicySubsystem::GetCloudPolicyCacheBase() const { |  194 CloudPolicyCacheBase* CloudPolicySubsystem::GetCloudPolicyCacheBase() const { | 
|  195   return cloud_policy_cache_.get(); |  195   return cloud_policy_cache_.get(); | 
|  196 } |  196 } | 
|  197  |  197  | 
|  198 CloudPolicySubsystem::CloudPolicySubsystem() |  198 CloudPolicySubsystem::CloudPolicySubsystem() | 
|  199     : refresh_pref_name_(NULL), |  199     : refresh_pref_name_(NULL), | 
|  200       data_store_(NULL) { |  200       data_store_(NULL) { | 
|  201 } |  201 } | 
|  202  |  202  | 
|  203 }  // namespace policy |  203 }  // namespace policy | 
| OLD | NEW |