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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 void SchemaRegistry::RegisterComponent(const PolicyNamespace& ns, | 23 void SchemaRegistry::RegisterComponent(const PolicyNamespace& ns, |
24 const Schema& schema) { | 24 const Schema& schema) { |
25 ComponentMap map; | 25 ComponentMap map; |
26 map[ns.component_id] = schema; | 26 map[ns.component_id] = schema; |
27 RegisterComponents(ns.domain, map); | 27 RegisterComponents(ns.domain, map); |
28 } | 28 } |
29 | 29 |
30 void SchemaRegistry::RegisterComponents(PolicyDomain domain, | 30 void SchemaRegistry::RegisterComponents(PolicyDomain domain, |
31 const ComponentMap& components) { | 31 const ComponentMap& components) { |
| 32 // Don't issue notifications if nothing is being registered. |
| 33 if (components.empty()) |
| 34 return; |
32 // Assume that a schema was updated if the namespace was already registered | 35 // Assume that a schema was updated if the namespace was already registered |
33 // before. | 36 // before. |
34 DomainMap map(schema_map_->GetDomains()); | 37 DomainMap map(schema_map_->GetDomains()); |
35 for (ComponentMap::const_iterator it = components.begin(); | 38 for (ComponentMap::const_iterator it = components.begin(); |
36 it != components.end(); ++it) { | 39 it != components.end(); ++it) { |
37 map[domain][it->first] = it->second; | 40 map[domain][it->first] = it->second; |
38 } | 41 } |
39 schema_map_ = new SchemaMap(map); | 42 schema_map_ = new SchemaMap(map); |
40 Notify(true); | 43 Notify(true); |
41 } | 44 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 comp_it != reg_component_map.end(); ++comp_it) { | 169 comp_it != reg_component_map.end(); ++comp_it) { |
167 map[domain_it->first][comp_it->first] = comp_it->second; | 170 map[domain_it->first][comp_it->first] = comp_it->second; |
168 } | 171 } |
169 } | 172 } |
170 } | 173 } |
171 schema_map_ = new SchemaMap(map); | 174 schema_map_ = new SchemaMap(map); |
172 Notify(has_new_schemas); | 175 Notify(has_new_schemas); |
173 } | 176 } |
174 | 177 |
175 } // namespace policy | 178 } // namespace policy |
OLD | NEW |