| OLD | NEW |
| 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 CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ | 6 #define CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 SchemaRegistry : public base::NonThreadSafe { |
| 28 public: | 28 public: |
| 29 class Observer { | 29 class Observer { |
| 30 public: | 30 public: |
| 31 // Invoked whenever schemas are registered or unregistered. | 31 // Invoked whenever schemas are registered or unregistered. |
| 32 // |current_map| is a reference to the current map, also returned by | |
| 33 // schema_map(); | |
| 34 // |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 |
| 35 // the last update; this allows observers to ignore updates when | 33 // the last update; this allows observers to ignore updates when |
| 36 // 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 |
| 37 // (e.g. for periodic reloads). | 35 // (e.g. for periodic reloads). |
| 38 virtual void OnSchemaRegistryUpdated( | 36 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) = 0; |
| 39 const scoped_refptr<SchemaMap>& current_map, | |
| 40 bool has_new_schemas) = 0; | |
| 41 | 37 |
| 42 protected: | 38 protected: |
| 43 virtual ~Observer(); | 39 virtual ~Observer(); |
| 44 }; | 40 }; |
| 45 | 41 |
| 46 SchemaRegistry(); | 42 SchemaRegistry(); |
| 47 virtual ~SchemaRegistry(); | 43 virtual ~SchemaRegistry(); |
| 48 | 44 |
| 49 const scoped_refptr<SchemaMap>& schema_map() const { return schema_map_; } | 45 const scoped_refptr<SchemaMap>& schema_map() const { return schema_map_; } |
| 50 | 46 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual ~CombinedSchemaRegistry(); | 78 virtual ~CombinedSchemaRegistry(); |
| 83 | 79 |
| 84 void Track(SchemaRegistry* registry); | 80 void Track(SchemaRegistry* registry); |
| 85 void Untrack(SchemaRegistry* registry); | 81 void Untrack(SchemaRegistry* registry); |
| 86 | 82 |
| 87 virtual void RegisterComponents(PolicyDomain domain, | 83 virtual void RegisterComponents(PolicyDomain domain, |
| 88 const ComponentMap& components) OVERRIDE; | 84 const ComponentMap& components) OVERRIDE; |
| 89 | 85 |
| 90 virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE; | 86 virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE; |
| 91 | 87 |
| 92 virtual void OnSchemaRegistryUpdated( | 88 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE; |
| 93 const scoped_refptr<SchemaMap>& current_map, | |
| 94 bool has_new_schemas) OVERRIDE; | |
| 95 | 89 |
| 96 private: | 90 private: |
| 97 void Combine(bool has_new_schemas); | 91 void Combine(bool has_new_schemas); |
| 98 | 92 |
| 99 std::set<SchemaRegistry*> registries_; | 93 std::set<SchemaRegistry*> registries_; |
| 100 scoped_refptr<SchemaMap> own_schema_map_; | 94 scoped_refptr<SchemaMap> own_schema_map_; |
| 101 | 95 |
| 102 DISALLOW_COPY_AND_ASSIGN(CombinedSchemaRegistry); | 96 DISALLOW_COPY_AND_ASSIGN(CombinedSchemaRegistry); |
| 103 }; | 97 }; |
| 104 | 98 |
| 105 } // namespace policy | 99 } // namespace policy |
| 106 | 100 |
| 107 #endif // CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ | 101 #endif // CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_H_ |
| OLD | NEW |