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

Side by Side Diff: components/policy/core/common/schema_registry.h

Issue 78453005: Move PolicySchema and PolicySchemaRegistry to components/policy/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export nested class on win Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SCHEMA_REGISTRY_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_REGISTRY_H_
6 #define CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_REGISTRY_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "chrome/browser/policy/schema_map.h"
16 #include "components/policy/core/common/policy_namespace.h" 15 #include "components/policy/core/common/policy_namespace.h"
17 #include "components/policy/core/common/schema.h" 16 #include "components/policy/core/common/schema.h"
17 #include "components/policy/core/common/schema_map.h"
18 18
19 namespace policy { 19 namespace policy {
20 20
21 class SchemaMap; 21 class SchemaMap;
22 22
23 // Holds the main reference to the current SchemaMap, and allows a list of 23 // Holds the main reference to the current SchemaMap, and allows a list of
24 // observers to get notified whenever it is updated. 24 // observers to get notified whenever it is updated.
25 // This object is not thread safe and must be used from the owner's thread, 25 // This object is not thread safe and must be used from the owner's thread,
26 // usually UI. 26 // usually UI.
27 class SchemaRegistry : public base::NonThreadSafe { 27 class POLICY_EXPORT SchemaRegistry : public base::NonThreadSafe {
28 public: 28 public:
29 class Observer { 29 class POLICY_EXPORT Observer {
30 public: 30 public:
31 // Invoked whenever schemas are registered or unregistered. 31 // Invoked whenever schemas are registered or unregistered.
32 // |has_new_schemas| is true if a new component has been registered since 32 // |has_new_schemas| is true if a new component has been registered since
33 // the last update; this allows observers to ignore updates when 33 // the last update; this allows observers to ignore updates when
34 // components are unregistered but still get a handle to the current map 34 // components are unregistered but still get a handle to the current map
35 // (e.g. for periodic reloads). 35 // (e.g. for periodic reloads).
36 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) = 0; 36 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) = 0;
37 37
38 // Invoked when all policy domains become ready. 38 // Invoked when all policy domains become ready.
39 virtual void OnSchemaRegistryReady() = 0; 39 virtual void OnSchemaRegistryReady() = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scoped_refptr<SchemaMap> schema_map_; 76 scoped_refptr<SchemaMap> schema_map_;
77 77
78 private: 78 private:
79 ObserverList<Observer, true> observers_; 79 ObserverList<Observer, true> observers_;
80 bool domains_ready_[POLICY_DOMAIN_SIZE]; 80 bool domains_ready_[POLICY_DOMAIN_SIZE];
81 81
82 DISALLOW_COPY_AND_ASSIGN(SchemaRegistry); 82 DISALLOW_COPY_AND_ASSIGN(SchemaRegistry);
83 }; 83 };
84 84
85 // A registry that combines the maps of other registries. 85 // A registry that combines the maps of other registries.
86 class CombinedSchemaRegistry : public SchemaRegistry, 86 class POLICY_EXPORT CombinedSchemaRegistry : public SchemaRegistry,
87 public SchemaRegistry::Observer { 87 public SchemaRegistry::Observer {
88 public: 88 public:
89 CombinedSchemaRegistry(); 89 CombinedSchemaRegistry();
90 virtual ~CombinedSchemaRegistry(); 90 virtual ~CombinedSchemaRegistry();
91 91
92 void Track(SchemaRegistry* registry); 92 void Track(SchemaRegistry* registry);
93 void Untrack(SchemaRegistry* registry); 93 void Untrack(SchemaRegistry* registry);
94 94
95 virtual void RegisterComponents(PolicyDomain domain, 95 virtual void RegisterComponents(PolicyDomain domain,
96 const ComponentMap& components) OVERRIDE; 96 const ComponentMap& components) OVERRIDE;
97 97
98 virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE; 98 virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE;
99 99
100 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE; 100 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE;
101 101
102 virtual void OnSchemaRegistryReady() OVERRIDE; 102 virtual void OnSchemaRegistryReady() OVERRIDE;
103 103
104 private: 104 private:
105 void Combine(bool has_new_schemas); 105 void Combine(bool has_new_schemas);
106 106
107 std::set<SchemaRegistry*> registries_; 107 std::set<SchemaRegistry*> registries_;
108 scoped_refptr<SchemaMap> own_schema_map_; 108 scoped_refptr<SchemaMap> own_schema_map_;
109 109
110 DISALLOW_COPY_AND_ASSIGN(CombinedSchemaRegistry); 110 DISALLOW_COPY_AND_ASSIGN(CombinedSchemaRegistry);
111 }; 111 };
112 112
113 } // namespace policy 113 } // namespace policy
114 114
115 #endif // CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ 115 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_REGISTRY_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/schema_map_unittest.cc ('k') | components/policy/core/common/schema_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698