OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ |
6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ | 6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // Copying and assignment allowed. | 75 // Copying and assignment allowed. |
76 }; | 76 }; |
77 // This wrapper should add no overhead. | 77 // This wrapper should add no overhead. |
78 // TODO(vtl): Rewrite |sizeof(uint32_t)| as |sizeof(ChannelEndpointId::value)| | 78 // TODO(vtl): Rewrite |sizeof(uint32_t)| as |sizeof(ChannelEndpointId::value)| |
79 // once we have sufficient C++11 support. | 79 // once we have sufficient C++11 support. |
80 static_assert(sizeof(ChannelEndpointId) == sizeof(uint32_t), | 80 static_assert(sizeof(ChannelEndpointId) == sizeof(uint32_t), |
81 "ChannelEndpointId has incorrect size"); | 81 "ChannelEndpointId has incorrect size"); |
82 | 82 |
83 // So logging macros and |DCHECK_EQ()|, etc. work. | 83 // So logging macros and |DCHECK_EQ()|, etc. work. |
84 inline std::ostream& operator<<(std::ostream& out, | 84 MOJO_SYSTEM_IMPL_EXPORT inline std::ostream& operator<<( |
85 const ChannelEndpointId& channel_endpoint_id) { | 85 std::ostream& out, |
| 86 const ChannelEndpointId& channel_endpoint_id) { |
86 return out << channel_endpoint_id.value(); | 87 return out << channel_endpoint_id.value(); |
87 } | 88 } |
88 | 89 |
89 // LocalChannelEndpointIdGenerator --------------------------------------------- | 90 // LocalChannelEndpointIdGenerator --------------------------------------------- |
90 | 91 |
91 // A generator for "new" local |ChannelEndpointId|s. It does not track | 92 // A generator for "new" local |ChannelEndpointId|s. It does not track |
92 // used/existing IDs; that must be done separately. (This class is not | 93 // used/existing IDs; that must be done separately. (This class is not |
93 // thread-safe.) | 94 // thread-safe.) |
94 class MOJO_SYSTEM_IMPL_EXPORT LocalChannelEndpointIdGenerator { | 95 class MOJO_SYSTEM_IMPL_EXPORT LocalChannelEndpointIdGenerator { |
95 public: | 96 public: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 template <> | 139 template <> |
139 struct hash<mojo::system::ChannelEndpointId> { | 140 struct hash<mojo::system::ChannelEndpointId> { |
140 size_t operator()(mojo::system::ChannelEndpointId channel_endpoint_id) const { | 141 size_t operator()(mojo::system::ChannelEndpointId channel_endpoint_id) const { |
141 return static_cast<size_t>(channel_endpoint_id.value()); | 142 return static_cast<size_t>(channel_endpoint_id.value()); |
142 } | 143 } |
143 }; | 144 }; |
144 | 145 |
145 } // namespace BASE_HASH_NAMESPACE | 146 } // namespace BASE_HASH_NAMESPACE |
146 | 147 |
147 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ | 148 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ |
OLD | NEW |