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

Unified Diff: components/policy/core/common/schema_registry.h

Issue 349643002: Decoupled the SchemaRegistryService from SchemaRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.cc ('k') | components/policy/core/common/schema_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/schema_registry.h
diff --git a/components/policy/core/common/schema_registry.h b/components/policy/core/common/schema_registry.h
index b9f7fa8777e02f181d70d6441be6c52755a40589..6df4db2b19a7565337e8ce2a619990584e37afcc 100644
--- a/components/policy/core/common/schema_registry.h
+++ b/components/policy/core/common/schema_registry.h
@@ -43,6 +43,16 @@ class POLICY_EXPORT SchemaRegistry : public base::NonThreadSafe {
virtual ~Observer();
};
+ // This observer is only meant to be used by subclasses.
+ class POLICY_EXPORT InternalObserver {
+ public:
+ // Invoked when |registry| is about to be destroyed.
+ virtual void OnSchemaRegistryShuttingDown(SchemaRegistry* registry) = 0;
+
+ protected:
+ virtual ~InternalObserver();
+ };
+
SchemaRegistry();
virtual ~SchemaRegistry();
@@ -69,7 +79,8 @@ class POLICY_EXPORT SchemaRegistry : public base::NonThreadSafe {
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- bool HasObservers() const;
+ void AddInternalObserver(InternalObserver* observer);
+ void RemoveInternalObserver(InternalObserver* observer);
protected:
void Notify(bool has_new_schemas);
@@ -78,30 +89,35 @@ class POLICY_EXPORT SchemaRegistry : public base::NonThreadSafe {
private:
ObserverList<Observer, true> observers_;
+ ObserverList<InternalObserver, true> internal_observers_;
bool domains_ready_[POLICY_DOMAIN_SIZE];
DISALLOW_COPY_AND_ASSIGN(SchemaRegistry);
};
// A registry that combines the maps of other registries.
-class POLICY_EXPORT CombinedSchemaRegistry : public SchemaRegistry,
- public SchemaRegistry::Observer {
+class POLICY_EXPORT CombinedSchemaRegistry
+ : public SchemaRegistry,
+ public SchemaRegistry::Observer,
+ public SchemaRegistry::InternalObserver {
public:
CombinedSchemaRegistry();
virtual ~CombinedSchemaRegistry();
void Track(SchemaRegistry* registry);
- void Untrack(SchemaRegistry* registry);
+ // SchemaRegistry:
virtual void RegisterComponents(PolicyDomain domain,
const ComponentMap& components) OVERRIDE;
-
virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE;
+ // SchemaRegistry::Observer:
virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE;
-
virtual void OnSchemaRegistryReady() OVERRIDE;
+ // SchemaRegistry::InternalObserver:
+ virtual void OnSchemaRegistryShuttingDown(SchemaRegistry* registry) OVERRIDE;
+
private:
void Combine(bool has_new_schemas);
@@ -111,6 +127,35 @@ class POLICY_EXPORT CombinedSchemaRegistry : public SchemaRegistry,
DISALLOW_COPY_AND_ASSIGN(CombinedSchemaRegistry);
};
+// A registry that wraps another schema registry.
+class POLICY_EXPORT ForwardingSchemaRegistry
+ : public SchemaRegistry,
+ public SchemaRegistry::Observer,
+ public SchemaRegistry::InternalObserver {
+ public:
+ // This registry will stop updating its SchemaMap when |wrapped| is
+ // destroyed.
+ explicit ForwardingSchemaRegistry(SchemaRegistry* wrapped);
+ virtual ~ForwardingSchemaRegistry();
+
+ // SchemaRegistry:
+ virtual void RegisterComponents(PolicyDomain domain,
+ const ComponentMap& components) OVERRIDE;
+ virtual void UnregisterComponent(const PolicyNamespace& ns) OVERRIDE;
+
+ // SchemaRegistry::Observer:
+ virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE;
+ virtual void OnSchemaRegistryReady() OVERRIDE;
+
+ // SchemaRegistry::InternalObserver:
+ virtual void OnSchemaRegistryShuttingDown(SchemaRegistry* registry) OVERRIDE;
+
+ private:
+ SchemaRegistry* wrapped_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingSchemaRegistry);
+};
+
} // namespace policy
#endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_REGISTRY_H_
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.cc ('k') | components/policy/core/common/schema_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698