cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / policy / core / common / policy_namespace.h
blob58a705ae0adc6785290862a703d184a1f9bd6916
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_NAMESPACE_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
8 #include <stdint.h>
10 #include <string>
11 #include <vector>
13 #include "base/containers/hash_tables.h"
14 #include "components/policy/policy_export.h"
16 namespace policy {
18 // Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID
19 // string depends on the domain; for example, if the PolicyDomain is
20 // "extensions" then the ID identifies the extension that the policies control.
21 enum PolicyDomain {
22 // The component ID for chrome policies is always the empty string.
23 POLICY_DOMAIN_CHROME,
25 // The extensions policy domain is a work in progress. Included here for
26 // tests.
27 POLICY_DOMAIN_EXTENSIONS,
29 // Must be the last entry.
30 POLICY_DOMAIN_SIZE,
33 // Groups a policy domain and a component ID in a single object representing
34 // a policy namespace. Objects of this class can be used as keys in std::maps.
35 struct POLICY_EXPORT PolicyNamespace {
36 public:
37 PolicyNamespace();
38 PolicyNamespace(PolicyDomain domain, const std::string& component_id);
39 PolicyNamespace(const PolicyNamespace& other);
40 ~PolicyNamespace();
42 PolicyNamespace& operator=(const PolicyNamespace& other);
43 bool operator<(const PolicyNamespace& other) const;
44 bool operator==(const PolicyNamespace& other) const;
45 bool operator!=(const PolicyNamespace& other) const;
47 PolicyDomain domain;
48 std::string component_id;
51 typedef std::vector<PolicyNamespace> PolicyNamespaceList;
53 } // namespace policy
55 // Define a custom std::hash for PolicyNamespace so that it can be used as
56 // a key in hash_maps, and in particular in ScopedPtrHashMaps (which uses the
57 // default std::hash).
58 namespace BASE_HASH_NAMESPACE {
60 template <>
61 struct hash<policy::PolicyNamespace> {
62 std::size_t operator()(const policy::PolicyNamespace& ns) const {
63 return hash<std::string>()(ns.component_id) ^ (UINT64_C(1) << ns.domain);
67 } // namespace BASE_HASH_NAMESPACE
69 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_