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 "chrome/browser/policy/policy_bundle.h" | 8 #include "chrome/browser/policy/policy_bundle.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 } | 48 } |
49 | 49 |
50 scoped_ptr<PolicyBundle> bundle(Load()); | 50 scoped_ptr<PolicyBundle> bundle(Load()); |
51 | 51 |
52 // Check if there was a modification while reading. | 52 // Check if there was a modification while reading. |
53 if (!force && !IsSafeToReload(now, &delay)) { | 53 if (!force && !IsSafeToReload(now, &delay)) { |
54 ScheduleNextReload(delay); | 54 ScheduleNextReload(delay); |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 // Filter out mismatching policies. | |
59 for (DescriptorMap::iterator it = descriptor_map_.begin(); | |
60 it != descriptor_map_.end(); ++it) { | |
61 it->second->FilterBundle(bundle.get()); | |
Mattias Nissler (ping if slow)
2013/05/15 10:24:06
I don't think this is a good idea - the idea was t
Joao da Silva
2013/05/19 13:17:55
Note that this only applies to non-CHROME policy,
| |
62 } | |
63 | |
58 update_callback_.Run(bundle.Pass()); | 64 update_callback_.Run(bundle.Pass()); |
59 ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds)); | 65 ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds)); |
60 } | 66 } |
61 | 67 |
68 void AsyncPolicyLoader::RegisterPolicyDomain( | |
69 scoped_refptr<const PolicyDomainDescriptor> descriptor) { | |
70 if (descriptor->domain() != POLICY_DOMAIN_CHROME) { | |
71 descriptor_map_[descriptor->domain()] = descriptor; | |
72 Reload(true); | |
73 } | |
74 } | |
75 | |
62 scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad() { | 76 scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad() { |
63 // This is the first load, early during startup. Use this to record the | 77 // This is the first load, early during startup. Use this to record the |
64 // initial |last_modification_time_|, so that potential changes made before | 78 // initial |last_modification_time_|, so that potential changes made before |
65 // installing the watches can be detected. | 79 // installing the watches can be detected. |
66 last_modification_time_ = LastModificationTime(); | 80 last_modification_time_ = LastModificationTime(); |
67 return Load(); | 81 return Load(); |
68 } | 82 } |
69 | 83 |
70 void AsyncPolicyLoader::Init(const UpdateCallback& update_callback) { | 84 void AsyncPolicyLoader::Init(const UpdateCallback& update_callback) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 const base::TimeDelta age = now - last_modification_clock_; | 128 const base::TimeDelta age = now - last_modification_clock_; |
115 if (age < kSettleInterval) { | 129 if (age < kSettleInterval) { |
116 *delay = kSettleInterval - age; | 130 *delay = kSettleInterval - age; |
117 return false; | 131 return false; |
118 } | 132 } |
119 | 133 |
120 return true; | 134 return true; |
121 } | 135 } |
122 | 136 |
123 } // namespace policy | 137 } // namespace policy |
OLD | NEW |