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

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

Issue 10805057: Modified PolicyService to register observers by domain only, instead of domain and component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nit Created 8 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/policy_service.cc ('k') | chrome/browser/policy/policy_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ 5 #ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ 6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 16 matching lines...) Expand all
27 27
28 // The PolicyServiceImpl will merge policies from |providers|. |providers| 28 // The PolicyServiceImpl will merge policies from |providers|. |providers|
29 // must be sorted in decreasing order of priority; the first provider will 29 // must be sorted in decreasing order of priority; the first provider will
30 // have the highest priority. The PolicyServiceImpl does not take ownership of 30 // have the highest priority. The PolicyServiceImpl does not take ownership of
31 // the providers, but handles OnProviderGoingAway() if they are destroyed. 31 // the providers, but handles OnProviderGoingAway() if they are destroyed.
32 explicit PolicyServiceImpl(const Providers& providers); 32 explicit PolicyServiceImpl(const Providers& providers);
33 virtual ~PolicyServiceImpl(); 33 virtual ~PolicyServiceImpl();
34 34
35 // PolicyService overrides: 35 // PolicyService overrides:
36 virtual void AddObserver(PolicyDomain domain, 36 virtual void AddObserver(PolicyDomain domain,
37 const std::string& component_id,
38 PolicyService::Observer* observer) OVERRIDE; 37 PolicyService::Observer* observer) OVERRIDE;
39 virtual void RemoveObserver(PolicyDomain domain, 38 virtual void RemoveObserver(PolicyDomain domain,
40 const std::string& component_id,
41 PolicyService::Observer* observer) OVERRIDE; 39 PolicyService::Observer* observer) OVERRIDE;
42 virtual const PolicyMap& GetPolicies( 40 virtual const PolicyMap& GetPolicies(
43 PolicyDomain domain, 41 PolicyDomain domain,
44 const std::string& component_id) const OVERRIDE; 42 const std::string& component_id) const OVERRIDE;
45 virtual bool IsInitializationComplete() const OVERRIDE; 43 virtual bool IsInitializationComplete() const OVERRIDE;
46 virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE; 44 virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE;
47 45
48 private: 46 private:
49 typedef ObserverList<PolicyService::Observer, true> Observers; 47 typedef ObserverList<PolicyService::Observer, true> Observers;
50 typedef std::map<PolicyBundle::PolicyNamespace, Observers*> ObserverMap; 48 typedef std::map<PolicyDomain, Observers*> ObserverMap;
51 typedef std::vector<ConfigurationPolicyObserverRegistrar*> RegistrarList; 49 typedef std::vector<ConfigurationPolicyObserverRegistrar*> RegistrarList;
52 50
53 // ConfigurationPolicyProvider::Observer overrides: 51 // ConfigurationPolicyProvider::Observer overrides:
54 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; 52 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE;
55 virtual void OnProviderGoingAway( 53 virtual void OnProviderGoingAway(
56 ConfigurationPolicyProvider* provider) OVERRIDE; 54 ConfigurationPolicyProvider* provider) OVERRIDE;
57 55
58 // Returns an iterator to the entry in |registrars_| that corresponds to 56 // Returns an iterator to the entry in |registrars_| that corresponds to
59 // |provider|, or |registrars_.end()|. 57 // |provider|, or |registrars_.end()|.
60 RegistrarList::iterator GetRegistrar(ConfigurationPolicyProvider* provider); 58 RegistrarList::iterator GetRegistrar(ConfigurationPolicyProvider* provider);
(...skipping 15 matching lines...) Expand all
76 // Invokes all the refresh callbacks if there are no more refreshes pending. 74 // Invokes all the refresh callbacks if there are no more refreshes pending.
77 void CheckRefreshComplete(); 75 void CheckRefreshComplete();
78 76
79 // Contains a registrar for each of the providers passed in the constructor, 77 // Contains a registrar for each of the providers passed in the constructor,
80 // in order of decreasing priority. 78 // in order of decreasing priority.
81 RegistrarList registrars_; 79 RegistrarList registrars_;
82 80
83 // Maps each policy namespace to its current policies. 81 // Maps each policy namespace to its current policies.
84 PolicyBundle policy_bundle_; 82 PolicyBundle policy_bundle_;
85 83
86 // Maps each policy namespace to its observer list. 84 // Maps each policy domain to its observer list.
87 ObserverMap observers_; 85 ObserverMap observers_;
88 86
89 // True if all the providers are initialized. 87 // True if all the providers are initialized.
90 bool initialization_complete_; 88 bool initialization_complete_;
91 89
92 // Set of providers that have a pending update that was triggered by a 90 // Set of providers that have a pending update that was triggered by a
93 // call to RefreshPolicies(). 91 // call to RefreshPolicies().
94 std::set<ConfigurationPolicyProvider*> refresh_pending_; 92 std::set<ConfigurationPolicyProvider*> refresh_pending_;
95 93
96 // List of callbacks to invoke once all providers refresh after a 94 // List of callbacks to invoke once all providers refresh after a
97 // RefreshPolicies() call. 95 // RefreshPolicies() call.
98 std::vector<base::Closure> refresh_callbacks_; 96 std::vector<base::Closure> refresh_callbacks_;
99 97
100 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); 98 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl);
101 }; 99 };
102 100
103 } // namespace policy 101 } // namespace policy
104 102
105 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ 103 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_service.cc ('k') | chrome/browser/policy/policy_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698