Chromium Code Reviews| 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 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 } | 186 } |
| 187 schema_map_ = new SchemaMap(map); | 187 schema_map_ = new SchemaMap(map); |
| 188 Notify(has_new_schemas); | 188 Notify(has_new_schemas); |
| 189 } | 189 } |
| 190 | 190 |
| 191 ForwardingSchemaRegistry::ForwardingSchemaRegistry(SchemaRegistry* wrapped) | 191 ForwardingSchemaRegistry::ForwardingSchemaRegistry(SchemaRegistry* wrapped) |
| 192 : wrapped_(wrapped) { | 192 : wrapped_(wrapped) { |
| 193 schema_map_ = wrapped_->schema_map(); | 193 schema_map_ = wrapped_->schema_map(); |
| 194 wrapped_->AddObserver(this); | 194 wrapped_->AddObserver(this); |
| 195 wrapped_->AddInternalObserver(this); | 195 wrapped_->AddInternalObserver(this); |
| 196 // This registry is always ready. | |
| 197 for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i) | |
| 198 SetReady(static_cast<PolicyDomain>(i)); | |
| 199 } | 196 } |
| 200 | 197 |
| 201 ForwardingSchemaRegistry::~ForwardingSchemaRegistry() { | 198 ForwardingSchemaRegistry::~ForwardingSchemaRegistry() { |
| 202 if (wrapped_) { | 199 if (wrapped_) { |
| 203 wrapped_->RemoveObserver(this); | 200 wrapped_->RemoveObserver(this); |
| 204 wrapped_->RemoveInternalObserver(this); | 201 wrapped_->RemoveInternalObserver(this); |
| 205 } | 202 } |
| 206 } | 203 } |
| 207 | 204 |
| 208 void ForwardingSchemaRegistry::RegisterComponents( | 205 void ForwardingSchemaRegistry::RegisterComponents( |
| 209 PolicyDomain domain, | 206 PolicyDomain domain, |
| 210 const ComponentMap& components) { | 207 const ComponentMap& components) { |
| 211 if (wrapped_) | 208 // POLICY_DOMAIN_CHROME is skipped to avoid spurious updated when a new |
|
bartfab (slow)
2014/06/23 09:53:38
Nit: s/updated/updates/
Joao da Silva
2014/07/16 11:47:52
Done.
| |
| 209 // Profile is created. If the ForwardingSchemaRegistry is meant to be used | |
|
bartfab (slow)
2014/06/23 09:53:38
Nit: s/meant to be//
Joao da Silva
2014/07/16 11:47:52
Done.
| |
| 210 // outside device-level accounts then this should become configurable. | |
| 211 if (wrapped_ && domain != POLICY_DOMAIN_CHROME) | |
| 212 wrapped_->RegisterComponents(domain, components); | 212 wrapped_->RegisterComponents(domain, components); |
| 213 // Ignore otherwise. | 213 // Ignore otherwise. |
| 214 } | 214 } |
| 215 | 215 |
| 216 void ForwardingSchemaRegistry::UnregisterComponent(const PolicyNamespace& ns) { | 216 void ForwardingSchemaRegistry::UnregisterComponent(const PolicyNamespace& ns) { |
| 217 if (wrapped_) | 217 if (wrapped_) |
| 218 wrapped_->UnregisterComponent(ns); | 218 wrapped_->UnregisterComponent(ns); |
| 219 // Ignore otherwise. | 219 // Ignore otherwise. |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ForwardingSchemaRegistry::OnSchemaRegistryUpdated(bool has_new_schemas) { | 222 void ForwardingSchemaRegistry::OnSchemaRegistryUpdated(bool has_new_schemas) { |
| 223 schema_map_ = wrapped_->schema_map(); | 223 schema_map_ = wrapped_->schema_map(); |
| 224 Notify(has_new_schemas); | 224 Notify(has_new_schemas); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ForwardingSchemaRegistry::OnSchemaRegistryReady() { | 227 void ForwardingSchemaRegistry::OnSchemaRegistryReady() { |
| 228 // Ignore. | 228 // Ignore. |
| 229 } | 229 } |
| 230 | 230 |
| 231 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( | 231 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( |
| 232 SchemaRegistry* registry) { | 232 SchemaRegistry* registry) { |
| 233 DCHECK_EQ(wrapped_, registry); | 233 DCHECK_EQ(wrapped_, registry); |
| 234 wrapped_->RemoveObserver(this); | 234 wrapped_->RemoveObserver(this); |
| 235 wrapped_->RemoveInternalObserver(this); | 235 wrapped_->RemoveInternalObserver(this); |
| 236 wrapped_ = NULL; | 236 wrapped_ = NULL; |
| 237 // Keep serving the same |schema_map_|. | 237 // Keep serving the same |schema_map_|. |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace policy | 240 } // namespace policy |
| OLD | NEW |