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

Side by Side Diff: components/policy/core/common/policy_namespace.h

Issue 2600783002: Remove base::ScopedPtrHashMap from components/policy/. (Closed)
Patch Set: Created 3 years, 12 months 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
« no previous file with comments | « components/policy/core/common/cloud/component_cloud_policy_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/component_cloud_policy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698