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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 for (ComponentMap::const_iterator comp_it = reg_component_map.begin(); | 179 for (ComponentMap::const_iterator comp_it = reg_component_map.begin(); |
180 comp_it != reg_component_map.end(); ++comp_it) { | 180 comp_it != reg_component_map.end(); ++comp_it) { |
181 map[domain_it->first][comp_it->first] = comp_it->second; | 181 map[domain_it->first][comp_it->first] = comp_it->second; |
182 } | 182 } |
183 } | 183 } |
184 } | 184 } |
185 schema_map_ = new SchemaMap(map); | 185 schema_map_ = new SchemaMap(map); |
186 Notify(has_new_schemas); | 186 Notify(has_new_schemas); |
187 } | 187 } |
188 | 188 |
189 ForwardingSchemaRegistry::ForwardingSchemaRegistry(SchemaRegistry* wrapped) | 189 ForwardingSchemaRegistry::ForwardingSchemaRegistry(SchemaRegistry* wrapped, |
190 : wrapped_(wrapped) { | 190 bool forward_readiness) |
191 : wrapped_(wrapped), forward_readiness_(forward_readiness) { | |
191 schema_map_ = wrapped_->schema_map(); | 192 schema_map_ = wrapped_->schema_map(); |
192 wrapped_->AddObserver(this); | 193 wrapped_->AddObserver(this); |
193 wrapped_->AddInternalObserver(this); | 194 wrapped_->AddInternalObserver(this); |
195 UpdateReadiness(); | |
194 } | 196 } |
195 | 197 |
196 ForwardingSchemaRegistry::~ForwardingSchemaRegistry() { | 198 ForwardingSchemaRegistry::~ForwardingSchemaRegistry() { |
197 if (wrapped_) { | 199 if (wrapped_) { |
198 wrapped_->RemoveObserver(this); | 200 wrapped_->RemoveObserver(this); |
199 wrapped_->RemoveInternalObserver(this); | 201 wrapped_->RemoveInternalObserver(this); |
200 } | 202 } |
201 } | 203 } |
202 | 204 |
203 void ForwardingSchemaRegistry::RegisterComponents( | 205 void ForwardingSchemaRegistry::RegisterComponents( |
(...skipping 11 matching lines...) Expand all Loading... | |
215 if (wrapped_) | 217 if (wrapped_) |
216 wrapped_->UnregisterComponent(ns); | 218 wrapped_->UnregisterComponent(ns); |
217 // Ignore otherwise. | 219 // Ignore otherwise. |
218 } | 220 } |
219 | 221 |
220 void ForwardingSchemaRegistry::OnSchemaRegistryUpdated(bool has_new_schemas) { | 222 void ForwardingSchemaRegistry::OnSchemaRegistryUpdated(bool has_new_schemas) { |
221 schema_map_ = wrapped_->schema_map(); | 223 schema_map_ = wrapped_->schema_map(); |
222 Notify(has_new_schemas); | 224 Notify(has_new_schemas); |
223 } | 225 } |
224 | 226 |
227 void ForwardingSchemaRegistry::OnSchemaRegistryReady() { | |
228 UpdateReadiness(); | |
229 } | |
230 | |
225 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( | 231 void ForwardingSchemaRegistry::OnSchemaRegistryShuttingDown( |
226 SchemaRegistry* registry) { | 232 SchemaRegistry* registry) { |
227 DCHECK_EQ(wrapped_, registry); | 233 DCHECK_EQ(wrapped_, registry); |
228 wrapped_->RemoveObserver(this); | 234 wrapped_->RemoveObserver(this); |
229 wrapped_->RemoveInternalObserver(this); | 235 wrapped_->RemoveInternalObserver(this); |
230 wrapped_ = NULL; | 236 wrapped_ = NULL; |
231 // Keep serving the same |schema_map_|. | 237 // Keep serving the same |schema_map_|. |
232 } | 238 } |
233 | 239 |
240 void ForwardingSchemaRegistry::UpdateReadiness() { | |
Andrew T Wilson (Slow)
2016/10/28 14:49:56
How can UpdateReadiness() be called when wrapped_
emaxx
2016/10/31 15:51:20
You are right, check for NULL wrapped_ is unnecess
| |
241 if (forward_readiness_ && wrapped_ && wrapped_->IsReady()) { | |
242 for (int i = 0; i < POLICY_DOMAIN_SIZE; ++i) | |
243 SetReady(static_cast<PolicyDomain>(i)); | |
244 } | |
245 } | |
246 | |
234 } // namespace policy | 247 } // namespace policy |
OLD | NEW |