| 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 |
| 11 #include <ostream> | 11 #include <ostream> |
| 12 | 12 |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "build/build_config.h" | |
| 17 #include "mojo/edk/system/system_impl_export.h" | 16 #include "mojo/edk/system/system_impl_export.h" |
| 18 | 17 |
| 19 namespace mojo { | 18 namespace mojo { |
| 20 namespace system { | 19 namespace system { |
| 21 | 20 |
| 22 // ChannelEndpointId ----------------------------------------------------------- | 21 // ChannelEndpointId ----------------------------------------------------------- |
| 23 | 22 |
| 24 class LocalChannelEndpointIdGenerator; | 23 class LocalChannelEndpointIdGenerator; |
| 25 FORWARD_DECLARE_TEST(LocalChannelEndpointIdGeneratorTest, WrapAround); | 24 FORWARD_DECLARE_TEST(LocalChannelEndpointIdGeneratorTest, WrapAround); |
| 26 FORWARD_DECLARE_TEST(RemoteChannelEndpointIdGeneratorTest, WrapAround); | 25 FORWARD_DECLARE_TEST(RemoteChannelEndpointIdGeneratorTest, WrapAround); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 DISALLOW_COPY_AND_ASSIGN(RemoteChannelEndpointIdGenerator); | 126 DISALLOW_COPY_AND_ASSIGN(RemoteChannelEndpointIdGenerator); |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 } // namespace system | 129 } // namespace system |
| 131 } // namespace mojo | 130 } // namespace mojo |
| 132 | 131 |
| 133 // Define "hash" functions for |ChannelEndpointId|s, so they can be used in hash | 132 // Define "hash" functions for |ChannelEndpointId|s, so they can be used in hash |
| 134 // tables. | 133 // tables. |
| 135 // TODO(vtl): Once we can use |std::unordered_{map,set}|, update this (and | 134 // TODO(vtl): Once we can use |std::unordered_{map,set}|, update this (and |
| 136 // remove the base/containers/hash_tables.h and build/build_config.h includes). | 135 // remove the base/containers/hash_tables.h include). |
| 137 namespace BASE_HASH_NAMESPACE { | 136 namespace BASE_HASH_NAMESPACE { |
| 138 | 137 |
| 139 #if defined(COMPILER_GCC) | |
| 140 | |
| 141 template <> | 138 template <> |
| 142 struct hash<mojo::system::ChannelEndpointId> { | 139 struct hash<mojo::system::ChannelEndpointId> { |
| 143 size_t operator()(mojo::system::ChannelEndpointId channel_endpoint_id) const { | 140 size_t operator()(mojo::system::ChannelEndpointId channel_endpoint_id) const { |
| 144 return static_cast<size_t>(channel_endpoint_id.value()); | 141 return static_cast<size_t>(channel_endpoint_id.value()); |
| 145 } | 142 } |
| 146 }; | 143 }; |
| 147 | 144 |
| 148 #elif defined(COMPILER_MSVC) | |
| 149 | |
| 150 inline size_t hash_value(mojo::system::ChannelEndpointId channel_endpoint_id) { | |
| 151 return static_cast<size_t>(channel_endpoint_id.value()); | |
| 152 } | |
| 153 #endif | |
| 154 | |
| 155 } // namespace BASE_HASH_NAMESPACE | 145 } // namespace BASE_HASH_NAMESPACE |
| 156 | 146 |
| 157 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ | 147 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_ID_H_ |
| OLD | NEW |