| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bool operator<(const PolicyNamespace& other) const; | 47 bool operator<(const PolicyNamespace& other) const; |
| 48 bool operator==(const PolicyNamespace& other) const; | 48 bool operator==(const PolicyNamespace& other) const; |
| 49 bool operator!=(const PolicyNamespace& other) const; | 49 bool operator!=(const PolicyNamespace& other) const; |
| 50 | 50 |
| 51 PolicyDomain domain; | 51 PolicyDomain domain; |
| 52 std::string component_id; | 52 std::string component_id; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 typedef std::vector<PolicyNamespace> PolicyNamespaceList; | 55 typedef std::vector<PolicyNamespace> PolicyNamespaceList; |
| 56 | 56 |
| 57 } // namespace policy | 57 struct PolicyNamespaceHash { |
| 58 | 58 size_t operator()(const policy::PolicyNamespace& ns) const { |
| 59 // Define a custom std::hash for PolicyNamespace so that it can be used as | 59 return std::hash<std::string>()(ns.component_id) ^ |
| 60 // a key in hash_maps, and in particular in ScopedPtrHashMaps (which uses the | 60 (UINT64_C(1) << ns.domain); |
| 61 // default std::hash). | |
| 62 namespace BASE_HASH_NAMESPACE { | |
| 63 | |
| 64 template <> | |
| 65 struct hash<policy::PolicyNamespace> { | |
| 66 std::size_t operator()(const policy::PolicyNamespace& ns) const { | |
| 67 return hash<std::string>()(ns.component_id) ^ (UINT64_C(1) << ns.domain); | |
| 68 } | 61 } |
| 69 }; | 62 }; |
| 70 | 63 |
| 71 } // namespace BASE_HASH_NAMESPACE | 64 } // namespace policy |
| 72 | 65 |
| 73 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ | 66 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ |
| OLD | NEW |