cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / policy / core / common / policy_bundle.h
blob0266672e474e73fd92d10720df8282cd181f39ef
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_POLICY_BUNDLE_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_BUNDLE_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "components/policy/core/common/policy_map.h"
13 #include "components/policy/core/common/policy_namespace.h"
14 #include "components/policy/policy_export.h"
16 namespace policy {
18 // Maps policy namespaces to PolicyMaps.
19 class POLICY_EXPORT PolicyBundle {
20 public:
21 typedef std::map<PolicyNamespace, PolicyMap*> MapType;
22 typedef MapType::iterator iterator;
23 typedef MapType::const_iterator const_iterator;
25 PolicyBundle();
26 virtual ~PolicyBundle();
28 // Returns the PolicyMap for namespace |ns|.
29 PolicyMap& Get(const PolicyNamespace& ns);
30 const PolicyMap& Get(const PolicyNamespace& ns) const;
32 // Swaps the internal representation of |this| with |other|.
33 void Swap(PolicyBundle* other);
35 // |this| becomes a copy of |other|. Any existing PolicyMaps are dropped.
36 void CopyFrom(const PolicyBundle& other);
38 // Merges the PolicyMaps of |this| with those of |other| for each namespace
39 // in common. Also adds copies of the (namespace, PolicyMap) pairs in |other|
40 // that don't have an entry in |this|.
41 // Each policy in each PolicyMap is replaced only if the policy from |other|
42 // has a higher priority.
43 // See PolicyMap::MergeFrom for details on merging individual PolicyMaps.
44 void MergeFrom(const PolicyBundle& other);
46 // Returns true if |other| has the same keys and value as |this|.
47 bool Equals(const PolicyBundle& other) const;
49 // Returns iterators to the beginning and end of the underlying container.
50 iterator begin() { return policy_bundle_.begin(); }
51 iterator end() { return policy_bundle_.end(); }
53 // These can be used to iterate over and read the PolicyMaps, but not to
54 // modify them.
55 const_iterator begin() const { return policy_bundle_.begin(); }
56 const_iterator end() const { return policy_bundle_.end(); }
58 // Erases all the existing pairs.
59 void Clear();
61 private:
62 MapType policy_bundle_;
64 // An empty PolicyMap that is returned by const Get() for namespaces that
65 // do not exist in |policy_bundle_|.
66 const PolicyMap kEmpty_;
68 DISALLOW_COPY_AND_ASSIGN(PolicyBundle);
71 } // namespace policy
73 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_BUNDLE_H_