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

Unified Diff: mojo/edk/system/channel_endpoint_id.h

Issue 638343003: Mojo: Add some tests for ChannelEndpointId, etc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/channel_endpoint_id.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel_endpoint_id.h
diff --git a/mojo/edk/system/channel_endpoint_id.h b/mojo/edk/system/channel_endpoint_id.h
index fc1ad6076eb8d76101250f0eda2603af2ac313c6..673a2195106cea436992ceccca156035caa73958 100644
--- a/mojo/edk/system/channel_endpoint_id.h
+++ b/mojo/edk/system/channel_endpoint_id.h
@@ -11,8 +11,10 @@
#include <ostream>
#include "base/containers/hash_tables.h"
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "build/build_config.h"
+#include "mojo/edk/system/system_impl_export.h"
namespace mojo {
namespace system {
@@ -20,10 +22,11 @@ namespace system {
// ChannelEndpointId -----------------------------------------------------------
class LocalChannelEndpointIdGenerator;
+FORWARD_DECLARE_TEST(LocalChannelEndpointIdGeneratorTest, WrapAround);
// Represents an ID for an endpoint (i.e., one side of a message pipe) on a
// |Channel|. This class must be POD.
-class ChannelEndpointId {
+class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpointId {
public:
ChannelEndpointId() : value_(0) {}
ChannelEndpointId(const ChannelEndpointId& other) : value_(other.value_) {}
@@ -52,6 +55,7 @@ class ChannelEndpointId {
private:
friend class LocalChannelEndpointIdGenerator;
+ FRIEND_TEST_ALL_PREFIXES(LocalChannelEndpointIdGeneratorTest, WrapAround);
uint32_t value_;
@@ -74,21 +78,16 @@ inline std::ostream& operator<<(std::ostream& out,
// A simple generator for "new" local |ChannelEndpointId|s. It does not track
// used/existing IDs; that must be done separately. (This class is not
// thread-safe.)
-class LocalChannelEndpointIdGenerator {
+class MOJO_SYSTEM_IMPL_EXPORT LocalChannelEndpointIdGenerator {
public:
LocalChannelEndpointIdGenerator()
: next_channel_endpoint_id_(ChannelEndpointId::GetBootstrap()) {}
- ChannelEndpointId GetNext() {
- ChannelEndpointId rv = next_channel_endpoint_id_;
- next_channel_endpoint_id_.value_++;
- // Skip over the invalid value, in case we wrap.
- if (!next_channel_endpoint_id_.is_valid())
- next_channel_endpoint_id_.value_++;
- return rv;
- }
+ ChannelEndpointId GetNext();
private:
+ FRIEND_TEST_ALL_PREFIXES(LocalChannelEndpointIdGeneratorTest, WrapAround);
+
ChannelEndpointId next_channel_endpoint_id_;
DISALLOW_COPY_AND_ASSIGN(LocalChannelEndpointIdGenerator);
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/channel_endpoint_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698