OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_POLICY_SCHEMA_MAP_H_ | |
6 #define CHROME_BROWSER_POLICY_SCHEMA_MAP_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/memory/ref_counted.h" | |
12 #include "components/policy/core/common/policy_namespace.h" | |
13 | |
14 namespace policy { | |
15 | |
16 class PolicyBundle; | |
17 class Schema; | |
18 | |
19 typedef std::map<std::string, Schema> ComponentMap; | |
bartfab (slow)
2013/10/30 12:34:49
Is a forward-declaration of Schema really sufficie
Joao da Silva
2013/10/31 13:34:56
It is, but this could be confusing for users of th
| |
20 typedef std::map<PolicyDomain, ComponentMap> DomainMap; | |
21 | |
22 // Contains a mapping of policy namespaces (domain + component ID) to its | |
23 // corresponding Schema. | |
24 class SchemaMap : public base::RefCountedThreadSafe<SchemaMap> { | |
25 public: | |
26 SchemaMap(); | |
27 // Takes ownership of |map| (its contents will be swapped). | |
28 explicit SchemaMap(DomainMap& map); | |
29 | |
30 const DomainMap& GetDomains() const; | |
31 | |
32 const ComponentMap& GetComponents(PolicyDomain domain) const; | |
bartfab (slow)
2013/10/30 12:34:49
Could this return a pointer instead, eliminating t
Joao da Silva
2013/10/31 13:34:56
Done.
| |
33 | |
34 const Schema* GetSchema(PolicyDomain domain, | |
bartfab (slow)
2013/10/30 12:34:49
Why this accessor? Would it not be cleaner to have
Joao da Silva
2013/10/31 13:34:56
Done.
| |
35 const std::string& component_id) const; | |
36 | |
37 const Schema* GetSchema(const PolicyNamespace& ns) const; | |
38 | |
39 // Removes all the policies in |bundle| that don't match the known schemas. | |
40 // Unknown components are also dropped. | |
41 void FilterBundle(PolicyBundle* bundle) const; | |
42 | |
43 private: | |
44 friend class base::RefCountedThreadSafe<SchemaMap>; | |
45 | |
46 ~SchemaMap(); | |
47 | |
48 DomainMap map_; | |
49 const ComponentMap kEmptyComponentMap_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(SchemaMap); | |
bartfab (slow)
2013/10/30 12:34:49
#include "base/basictypes.h"
Joao da Silva
2013/10/31 13:34:56
Done.
| |
52 }; | |
53 | |
54 } // namespace policy | |
55 | |
56 #endif // CHROME_BROWSER_POLICY_SCHEMA_MAP_H_ | |
OLD | NEW |