| 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/cloud_policy_core.h" | 5 #include "chrome/browser/policy/cloud/cloud_policy_core.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 12 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
| 12 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" | 13 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" |
| 13 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 14 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
| 14 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 15 #include "chrome/browser/policy/cloud/cloud_policy_store.h" |
| 16 #include "chrome/common/chrome_switches.h" |
| 15 | 17 |
| 16 namespace policy { | 18 namespace policy { |
| 17 | 19 |
| 18 CloudPolicyCore::CloudPolicyCore(const PolicyNamespaceKey& key, | 20 CloudPolicyCore::CloudPolicyCore(const PolicyNamespaceKey& key, |
| 19 CloudPolicyStore* store) | 21 CloudPolicyStore* store) |
| 20 : policy_ns_key_(key), | 22 : policy_ns_key_(key), |
| 21 store_(store) {} | 23 store_(store) {} |
| 22 | 24 |
| 23 CloudPolicyCore::~CloudPolicyCore() {} | 25 CloudPolicyCore::~CloudPolicyCore() {} |
| 24 | 26 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 void CloudPolicyCore::RefreshSoon() { | 41 void CloudPolicyCore::RefreshSoon() { |
| 40 if (refresh_scheduler_) | 42 if (refresh_scheduler_) |
| 41 refresh_scheduler_->RefreshSoon(); | 43 refresh_scheduler_->RefreshSoon(); |
| 42 } | 44 } |
| 43 | 45 |
| 44 void CloudPolicyCore::StartRefreshScheduler() { | 46 void CloudPolicyCore::StartRefreshScheduler() { |
| 45 if (!refresh_scheduler_) { | 47 if (!refresh_scheduler_) { |
| 46 refresh_scheduler_.reset( | 48 refresh_scheduler_.reset( |
| 47 new CloudPolicyRefreshScheduler( | 49 new CloudPolicyRefreshScheduler( |
| 48 client_.get(), store_, | 50 client_.get(), store_, |
| 49 base::MessageLoop::current()->message_loop_proxy())); | 51 base::MessageLoop::current()->message_loop_proxy(), |
| 52 CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 switches::kEnableCloudPolicyPush))); |
| 50 UpdateRefreshDelayFromPref(); | 54 UpdateRefreshDelayFromPref(); |
| 51 } | 55 } |
| 52 } | 56 } |
| 53 | 57 |
| 54 void CloudPolicyCore::TrackRefreshDelayPref( | 58 void CloudPolicyCore::TrackRefreshDelayPref( |
| 55 PrefService* pref_service, | 59 PrefService* pref_service, |
| 56 const std::string& refresh_pref_name) { | 60 const std::string& refresh_pref_name) { |
| 57 refresh_delay_.reset(new IntegerPrefMember()); | 61 refresh_delay_.reset(new IntegerPrefMember()); |
| 58 refresh_delay_->Init( | 62 refresh_delay_->Init( |
| 59 refresh_pref_name.c_str(), pref_service, | 63 refresh_pref_name.c_str(), pref_service, |
| 60 base::Bind(&CloudPolicyCore::UpdateRefreshDelayFromPref, | 64 base::Bind(&CloudPolicyCore::UpdateRefreshDelayFromPref, |
| 61 base::Unretained(this))); | 65 base::Unretained(this))); |
| 62 UpdateRefreshDelayFromPref(); | 66 UpdateRefreshDelayFromPref(); |
| 63 } | 67 } |
| 64 | 68 |
| 65 void CloudPolicyCore::UpdateRefreshDelayFromPref() { | 69 void CloudPolicyCore::UpdateRefreshDelayFromPref() { |
| 66 if (refresh_scheduler_ && refresh_delay_) | 70 if (refresh_scheduler_ && refresh_delay_) |
| 67 refresh_scheduler_->SetRefreshDelay(refresh_delay_->GetValue()); | 71 refresh_scheduler_->SetRefreshDelay(refresh_delay_->GetValue()); |
| 68 } | 72 } |
| 69 | 73 |
| 70 } // namespace policy | 74 } // namespace policy |
| OLD | NEW |