Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/policy/policy_service_impl.cc

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/policy_service_impl.h" 5 #include "chrome/browser/policy/policy_service_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/policy/policy_domain_descriptor.h"
13 #include "chrome/browser/policy/policy_map.h" 12 #include "chrome/browser/policy/policy_map.h"
14 13
15 namespace policy { 14 namespace policy {
16 15
17 typedef PolicyServiceImpl::Providers::const_iterator Iterator; 16 typedef PolicyServiceImpl::Providers::const_iterator Iterator;
18 17
19 PolicyServiceImpl::PolicyServiceImpl(const Providers& providers) 18 PolicyServiceImpl::PolicyServiceImpl(const Providers& providers)
20 : update_task_ptr_factory_(this) { 19 : update_task_ptr_factory_(this) {
21 for (int domain = 0; domain < POLICY_DOMAIN_SIZE; ++domain) 20 for (int domain = 0; domain < POLICY_DOMAIN_SIZE; ++domain)
22 initialization_complete_[domain] = true; 21 initialization_complete_[domain] = true;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 NOTREACHED(); 54 NOTREACHED();
56 return; 55 return;
57 } 56 }
58 it->second->RemoveObserver(observer); 57 it->second->RemoveObserver(observer);
59 if (!it->second->might_have_observers()) { 58 if (!it->second->might_have_observers()) {
60 delete it->second; 59 delete it->second;
61 observers_.erase(it); 60 observers_.erase(it);
62 } 61 }
63 } 62 }
64 63
65 void PolicyServiceImpl::RegisterPolicyDomain(
66 scoped_refptr<const PolicyDomainDescriptor> descriptor) {
67 domain_descriptors_[descriptor->domain()] = descriptor;
68 for (Iterator it = providers_.begin(); it != providers_.end(); ++it)
69 (*it)->RegisterPolicyDomain(descriptor);
70 }
71
72 const PolicyMap& PolicyServiceImpl::GetPolicies( 64 const PolicyMap& PolicyServiceImpl::GetPolicies(
73 const PolicyNamespace& ns) const { 65 const PolicyNamespace& ns) const {
74 return policy_bundle_.Get(ns); 66 return policy_bundle_.Get(ns);
75 } 67 }
76 68
77 scoped_refptr<const PolicyDomainDescriptor>
78 PolicyServiceImpl::GetPolicyDomainDescriptor(PolicyDomain domain) const {
79 return domain_descriptors_[domain];
80 }
81
82 bool PolicyServiceImpl::IsInitializationComplete(PolicyDomain domain) const { 69 bool PolicyServiceImpl::IsInitializationComplete(PolicyDomain domain) const {
83 DCHECK(domain >= 0 && domain < POLICY_DOMAIN_SIZE); 70 DCHECK(domain >= 0 && domain < POLICY_DOMAIN_SIZE);
84 return initialization_complete_[domain]; 71 return initialization_complete_[domain];
85 } 72 }
86 73
87 void PolicyServiceImpl::RefreshPolicies(const base::Closure& callback) { 74 void PolicyServiceImpl::RefreshPolicies(const base::Closure& callback) {
88 if (!callback.is_null()) 75 if (!callback.is_null())
89 refresh_callbacks_.push_back(callback); 76 refresh_callbacks_.push_back(callback);
90 77
91 if (providers_.empty()) { 78 if (providers_.empty()) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) { 204 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) {
218 std::vector<base::Closure> callbacks; 205 std::vector<base::Closure> callbacks;
219 callbacks.swap(refresh_callbacks_); 206 callbacks.swap(refresh_callbacks_);
220 std::vector<base::Closure>::iterator it; 207 std::vector<base::Closure>::iterator it;
221 for (it = callbacks.begin(); it != callbacks.end(); ++it) 208 for (it = callbacks.begin(); it != callbacks.end(); ++it)
222 it->Run(); 209 it->Run();
223 } 210 }
224 } 211 }
225 212
226 } // namespace policy 213 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_service_impl.h ('k') | chrome/browser/policy/policy_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698