Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: chrome/browser/policy/schema_map.h

Issue 50143010: Added a SchemaMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-5-ref-counted-schema
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698