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

Unified Diff: chrome/browser/policy/schema_registry.cc

Issue 60823003: Introduced a ForwardingPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed ios 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/schema_registry.h ('k') | chrome/browser/policy/schema_registry_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/schema_registry.cc
diff --git a/chrome/browser/policy/schema_registry.cc b/chrome/browser/policy/schema_registry.cc
index f005bd02354a5b5a53074553320941d705a6c4bc..d1c083523d6961ae2df54aadc995520bfcc26039 100644
--- a/chrome/browser/policy/schema_registry.cc
+++ b/chrome/browser/policy/schema_registry.cc
@@ -10,7 +10,13 @@ namespace policy {
SchemaRegistry::Observer::~Observer() {}
-SchemaRegistry::SchemaRegistry() : schema_map_(new SchemaMap) {}
+SchemaRegistry::SchemaRegistry() : schema_map_(new SchemaMap) {
+ for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i)
+ domains_ready_[i] = false;
+#if !defined(ENABLE_EXTENSIONS)
+ domains_ready_[POLICY_DOMAIN_EXTENSIONS] = true;
+#endif
+}
SchemaRegistry::~SchemaRegistry() {}
@@ -44,6 +50,22 @@ void SchemaRegistry::UnregisterComponent(const PolicyNamespace& ns) {
}
}
+bool SchemaRegistry::IsReady() const {
+ for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i) {
+ if (!domains_ready_[i])
+ return false;
+ }
+ return true;
+}
+
+void SchemaRegistry::SetReady(PolicyDomain domain) {
+ if (domains_ready_[domain])
+ return;
+ domains_ready_[domain] = true;
+ if (IsReady())
+ FOR_EACH_OBSERVER(Observer, observers_, OnSchemaRegistryReady());
+}
+
void SchemaRegistry::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
@@ -62,7 +84,13 @@ bool SchemaRegistry::HasObservers() const {
}
CombinedSchemaRegistry::CombinedSchemaRegistry()
- : own_schema_map_(new SchemaMap) {}
+ : own_schema_map_(new SchemaMap) {
+ // The combined registry is always ready, since it can always start tracking
+ // another registry that is not ready yet and going from "ready" to "not
+ // ready" is not allowed.
+ for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i)
+ SetReady(static_cast<PolicyDomain>(i));
+}
CombinedSchemaRegistry::~CombinedSchemaRegistry() {}
@@ -111,6 +139,10 @@ void CombinedSchemaRegistry::OnSchemaRegistryUpdated(bool has_new_schemas) {
Combine(has_new_schemas);
}
+void CombinedSchemaRegistry::OnSchemaRegistryReady() {
+ // Ignore.
+}
+
void CombinedSchemaRegistry::Combine(bool has_new_schemas) {
// If two registries publish a Schema for the same component then it's
// undefined which version gets in the combined registry.
« no previous file with comments | « chrome/browser/policy/schema_registry.h ('k') | chrome/browser/policy/schema_registry_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698