| 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 #include "components/policy/core/common/schema_registry.h" | 5 #include "components/policy/core/common/schema_registry.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace policy { | 9 namespace policy { |
| 10 | 10 |
| 11 SchemaRegistry::Observer::~Observer() {} | 11 SchemaRegistry::Observer::~Observer() {} |
| 12 | 12 |
| 13 SchemaRegistry::InternalObserver::~InternalObserver() {} | 13 SchemaRegistry::InternalObserver::~InternalObserver() {} |
| 14 | 14 |
| 15 SchemaRegistry::SchemaRegistry() : schema_map_(new SchemaMap) { | 15 SchemaRegistry::SchemaRegistry() : schema_map_(new SchemaMap) { |
| 16 for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i) | 16 for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i) |
| 17 domains_ready_[i] = false; | 17 domains_ready_[i] = false; |
| 18 #if !defined(ENABLE_EXTENSIONS) | 18 #if !defined(ENABLE_EXTENSIONS) |
| 19 domains_ready_[POLICY_DOMAIN_EXTENSIONS] = true; | 19 domains_ready_[POLICY_DOMAIN_EXTENSIONS] = true; |
| 20 #endif | 20 #endif |
| 21 } | 21 } |
| 22 | 22 |
| 23 SchemaRegistry::~SchemaRegistry() { | 23 SchemaRegistry::~SchemaRegistry() { |
| 24 FOR_EACH_OBSERVER(InternalObserver, | 24 FOR_EACH_OBSERVER(InternalObserver, |
| 25 internal_observers_, | 25 internal_observers_, |
| 26 OnSchemaRegistryShuttingDown(this)); | 26 OnSchemaRegistryShuttingDown(this)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 const scoped_refptr<SchemaMap>& SchemaRegistry::schema_map() const { |
| 30 return schema_map_; |
| 31 } |
| 32 |
| 29 void SchemaRegistry::RegisterComponent(const PolicyNamespace& ns, | 33 void SchemaRegistry::RegisterComponent(const PolicyNamespace& ns, |
| 30 const Schema& schema) { | 34 const Schema& schema) { |
| 31 ComponentMap map; | 35 ComponentMap map; |
| 32 map[ns.component_id] = schema; | 36 map[ns.component_id] = schema; |
| 33 RegisterComponents(ns.domain, map); | 37 RegisterComponents(ns.domain, map); |
| 34 } | 38 } |
| 35 | 39 |
| 36 void SchemaRegistry::RegisterComponents(PolicyDomain domain, | 40 void SchemaRegistry::RegisterComponents(PolicyDomain domain, |
| 37 const ComponentMap& components) { | 41 const ComponentMap& components) { |
| 38 // Don't issue notifications if nothing is being registered. | 42 // Don't issue notifications if nothing is being registered. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( | 227 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( |
| 224 SchemaRegistry* registry) { | 228 SchemaRegistry* registry) { |
| 225 DCHECK_EQ(wrapped_, registry); | 229 DCHECK_EQ(wrapped_, registry); |
| 226 wrapped_->RemoveObserver(this); | 230 wrapped_->RemoveObserver(this); |
| 227 wrapped_->RemoveInternalObserver(this); | 231 wrapped_->RemoveInternalObserver(this); |
| 228 wrapped_ = NULL; | 232 wrapped_ = NULL; |
| 229 // Keep serving the same |schema_map_|. | 233 // Keep serving the same |schema_map_|. |
| 230 } | 234 } |
| 231 | 235 |
| 232 } // namespace policy | 236 } // namespace policy |
| OLD | NEW |