| 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/async_policy_loader.h" | 5 #include "chrome/browser/policy/async_policy_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
| 10 #include "chrome/browser/policy/policy_bundle.h" | 10 #include "chrome/browser/policy/policy_bundle.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Filter out mismatching policies. | 61 // Filter out mismatching policies. |
| 62 for (DescriptorMap::iterator it = descriptor_map_.begin(); | 62 for (DescriptorMap::iterator it = descriptor_map_.begin(); |
| 63 it != descriptor_map_.end(); ++it) { | 63 it != descriptor_map_.end(); ++it) { |
| 64 it->second->FilterBundle(bundle.get()); | 64 it->second->FilterBundle(bundle.get()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 update_callback_.Run(bundle.Pass()); | 67 update_callback_.Run(bundle.Pass()); |
| 68 ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds)); | 68 ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 scoped_refptr<const PolicyDomainDescriptor> AsyncPolicyLoader::get_descriptor( |
| 72 PolicyDomain domain) const { |
| 73 DescriptorMap::const_iterator iter = descriptor_map().find(domain); |
| 74 if (iter != descriptor_map().end()) |
| 75 return iter->second; |
| 76 return NULL; |
| 77 } |
| 78 |
| 71 void AsyncPolicyLoader::RegisterPolicyDomain( | 79 void AsyncPolicyLoader::RegisterPolicyDomain( |
| 72 scoped_refptr<const PolicyDomainDescriptor> descriptor) { | 80 scoped_refptr<const PolicyDomainDescriptor> descriptor) { |
| 73 InitialRegisterPolicyDomain(descriptor); | 81 InitialRegisterPolicyDomain(descriptor); |
| 74 Reload(true); | 82 Reload(true); |
| 75 } | 83 } |
| 76 | 84 |
| 77 scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad() { | 85 scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad() { |
| 78 // This is the first load, early during startup. Use this to record the | 86 // This is the first load, early during startup. Use this to record the |
| 79 // initial |last_modification_time_|, so that potential changes made before | 87 // initial |last_modification_time_|, so that potential changes made before |
| 80 // installing the watches can be detected. | 88 // installing the watches can be detected. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 const base::TimeDelta age = now - last_modification_clock_; | 141 const base::TimeDelta age = now - last_modification_clock_; |
| 134 if (age < kSettleInterval) { | 142 if (age < kSettleInterval) { |
| 135 *delay = kSettleInterval - age; | 143 *delay = kSettleInterval - age; |
| 136 return false; | 144 return false; |
| 137 } | 145 } |
| 138 | 146 |
| 139 return true; | 147 return true; |
| 140 } | 148 } |
| 141 | 149 |
| 142 } // namespace policy | 150 } // namespace policy |
| OLD | NEW |