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.
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_MAP_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_MAP_H_
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "components/policy/core/common/policy_namespace.h"
14 #include "components/policy/core/common/schema.h"
15 #include "components/policy/policy_export.h"
21 typedef std::map
<std::string
, Schema
> ComponentMap
;
22 typedef std::map
<PolicyDomain
, ComponentMap
> DomainMap
;
24 // Contains a mapping of policy namespaces (domain + component ID) to its
25 // corresponding Schema.
26 class POLICY_EXPORT SchemaMap
: public base::RefCountedThreadSafe
<SchemaMap
> {
29 // Takes ownership of |map| (its contents will be swapped).
30 explicit SchemaMap(DomainMap
& map
);
32 const DomainMap
& GetDomains() const;
34 const ComponentMap
* GetComponents(PolicyDomain domain
) const;
36 const Schema
* GetSchema(const PolicyNamespace
& ns
) const;
38 // Removes all the policies in |bundle| that don't match the known schemas.
39 // Unknown components are also dropped.
40 void FilterBundle(PolicyBundle
* bundle
) const;
42 // Returns true if this map contains at least one component of a domain other
43 // than POLICY_DOMAIN_CHROME.
44 bool HasComponents() const;
46 void GetChanges(const scoped_refptr
<SchemaMap
>& older
,
47 PolicyNamespaceList
* removed
,
48 PolicyNamespaceList
* added
) const;
51 friend class base::RefCountedThreadSafe
<SchemaMap
>;
53 void GetNamespacesNotInOther(const SchemaMap
* other
,
54 PolicyNamespaceList
* list
) const;
60 DISALLOW_COPY_AND_ASSIGN(SchemaMap
);
65 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_MAP_H_