summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 18:57:20 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 18:57:20 +0000
commit26c3af239ff216aaa0484164c9a24cbc17869766 (patch)
tree2d87b328035b0dd87e3ff9b09cc64ef215ce7836 /mojo
parent7c905da0710c4cb8796a031a2c68768fc1e52d83 (diff)
downloadchromium_src-26c3af239ff216aaa0484164c9a24cbc17869766.zip
chromium_src-26c3af239ff216aaa0484164c9a24cbc17869766.tar.gz
chromium_src-26c3af239ff216aaa0484164c9a24cbc17869766.tar.bz2
Mojo: foo_[0-9] -> foo[0-9].
For foolish consistency. I'll never make this mistake again. R=sky@chromium.org Review URL: https://codereview.chromium.org/140503005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/public/system/core_cpp.h18
-rw-r--r--mojo/public/tests/system/core_cpp_unittest.cc269
-rw-r--r--mojo/public/tests/system/core_perftest.cc28
-rw-r--r--mojo/public/tests/system/core_unittest.cc47
-rw-r--r--mojo/system/core_impl.cc14
-rw-r--r--mojo/system/core_impl_unittest.cc12
-rw-r--r--mojo/system/message_pipe.cc8
-rw-r--r--mojo/system/message_pipe.h4
-rw-r--r--mojo/system/message_pipe_dispatcher_unittest.cc238
-rw-r--r--mojo/system/remote_message_pipe_posix_unittest.cc209
-rw-r--r--mojo/system/waiter_list_unittest.cc98
11 files changed, 471 insertions, 474 deletions
diff --git a/mojo/public/system/core_cpp.h b/mojo/public/system/core_cpp.h
index e1d3924..2b1fb8a 100644
--- a/mojo/public/system/core_cpp.h
+++ b/mojo/public/system/core_cpp.h
@@ -186,17 +186,17 @@ MOJO_COMPILE_ASSERT(sizeof(ScopedMessagePipeHandle) ==
// TODO(vtl): In C++11, we could instead return a pair of
// |ScopedMessagePipeHandle|s.
-inline void CreateMessagePipe(ScopedMessagePipeHandle* message_pipe_0,
- ScopedMessagePipeHandle* message_pipe_1) {
- assert(message_pipe_0);
- assert(message_pipe_1);
- MessagePipeHandle h_0;
- MessagePipeHandle h_1;
+inline void CreateMessagePipe(ScopedMessagePipeHandle* message_pipe0,
+ ScopedMessagePipeHandle* message_pipe1) {
+ assert(message_pipe0);
+ assert(message_pipe1);
+ MessagePipeHandle h0;
+ MessagePipeHandle h1;
MojoResult result MOJO_ALLOW_UNUSED =
- MojoCreateMessagePipe(h_0.mutable_value(), h_1.mutable_value());
+ MojoCreateMessagePipe(h0.mutable_value(), h1.mutable_value());
assert(result == MOJO_RESULT_OK);
- message_pipe_0->reset(h_0);
- message_pipe_1->reset(h_1);
+ message_pipe0->reset(h0);
+ message_pipe1->reset(h1);
}
class MessagePipe {
diff --git a/mojo/public/tests/system/core_cpp_unittest.cc b/mojo/public/tests/system/core_cpp_unittest.cc
index 8bce421..7fe3a32 100644
--- a/mojo/public/tests/system/core_cpp_unittest.cc
+++ b/mojo/public/tests/system/core_cpp_unittest.cc
@@ -23,58 +23,58 @@ TEST(CoreCppTest, Basic) {
{
EXPECT_EQ(MOJO_HANDLE_INVALID, kInvalidHandleValue);
- Handle h_0;
- EXPECT_EQ(kInvalidHandleValue, h_0.value());
- EXPECT_EQ(kInvalidHandleValue, *h_0.mutable_value());
- EXPECT_FALSE(h_0.is_valid());
-
- Handle h_1(static_cast<MojoHandle>(123));
- EXPECT_EQ(static_cast<MojoHandle>(123), h_1.value());
- EXPECT_EQ(static_cast<MojoHandle>(123), *h_1.mutable_value());
- EXPECT_TRUE(h_1.is_valid());
- *h_1.mutable_value() = static_cast<MojoHandle>(456);
- EXPECT_EQ(static_cast<MojoHandle>(456), h_1.value());
- EXPECT_TRUE(h_1.is_valid());
-
- h_1.swap(h_0);
- EXPECT_EQ(static_cast<MojoHandle>(456), h_0.value());
- EXPECT_TRUE(h_0.is_valid());
- EXPECT_FALSE(h_1.is_valid());
-
- h_1.set_value(static_cast<MojoHandle>(789));
- h_0.swap(h_1);
- EXPECT_EQ(static_cast<MojoHandle>(789), h_0.value());
- EXPECT_TRUE(h_0.is_valid());
- EXPECT_EQ(static_cast<MojoHandle>(456), h_1.value());
- EXPECT_TRUE(h_1.is_valid());
+ Handle h0;
+ EXPECT_EQ(kInvalidHandleValue, h0.value());
+ EXPECT_EQ(kInvalidHandleValue, *h0.mutable_value());
+ EXPECT_FALSE(h0.is_valid());
+
+ Handle h1(static_cast<MojoHandle>(123));
+ EXPECT_EQ(static_cast<MojoHandle>(123), h1.value());
+ EXPECT_EQ(static_cast<MojoHandle>(123), *h1.mutable_value());
+ EXPECT_TRUE(h1.is_valid());
+ *h1.mutable_value() = static_cast<MojoHandle>(456);
+ EXPECT_EQ(static_cast<MojoHandle>(456), h1.value());
+ EXPECT_TRUE(h1.is_valid());
+
+ h1.swap(h0);
+ EXPECT_EQ(static_cast<MojoHandle>(456), h0.value());
+ EXPECT_TRUE(h0.is_valid());
+ EXPECT_FALSE(h1.is_valid());
+
+ h1.set_value(static_cast<MojoHandle>(789));
+ h0.swap(h1);
+ EXPECT_EQ(static_cast<MojoHandle>(789), h0.value());
+ EXPECT_TRUE(h0.is_valid());
+ EXPECT_EQ(static_cast<MojoHandle>(456), h1.value());
+ EXPECT_TRUE(h1.is_valid());
// Make sure copy constructor works.
- Handle h_2(h_0);
- EXPECT_EQ(static_cast<MojoHandle>(789), h_2.value());
+ Handle h2(h0);
+ EXPECT_EQ(static_cast<MojoHandle>(789), h2.value());
// And assignment.
- h_2 = h_1;
- EXPECT_EQ(static_cast<MojoHandle>(456), h_2.value());
+ h2 = h1;
+ EXPECT_EQ(static_cast<MojoHandle>(456), h2.value());
// Make sure that we can put |Handle|s into |std::map|s.
- h_0 = Handle(static_cast<MojoHandle>(987));
- h_1 = Handle(static_cast<MojoHandle>(654));
- h_2 = Handle(static_cast<MojoHandle>(321));
- Handle h_3;
+ h0 = Handle(static_cast<MojoHandle>(987));
+ h1 = Handle(static_cast<MojoHandle>(654));
+ h2 = Handle(static_cast<MojoHandle>(321));
+ Handle h3;
std::map<Handle, int> handle_to_int;
- handle_to_int[h_0] = 0;
- handle_to_int[h_1] = 1;
- handle_to_int[h_2] = 2;
- handle_to_int[h_3] = 3;
+ handle_to_int[h0] = 0;
+ handle_to_int[h1] = 1;
+ handle_to_int[h2] = 2;
+ handle_to_int[h3] = 3;
EXPECT_EQ(4u, handle_to_int.size());
- EXPECT_FALSE(handle_to_int.find(h_0) == handle_to_int.end());
- EXPECT_EQ(0, handle_to_int[h_0]);
- EXPECT_FALSE(handle_to_int.find(h_1) == handle_to_int.end());
- EXPECT_EQ(1, handle_to_int[h_1]);
- EXPECT_FALSE(handle_to_int.find(h_2) == handle_to_int.end());
- EXPECT_EQ(2, handle_to_int[h_2]);
- EXPECT_FALSE(handle_to_int.find(h_3) == handle_to_int.end());
- EXPECT_EQ(3, handle_to_int[h_3]);
+ EXPECT_FALSE(handle_to_int.find(h0) == handle_to_int.end());
+ EXPECT_EQ(0, handle_to_int[h0]);
+ EXPECT_FALSE(handle_to_int.find(h1) == handle_to_int.end());
+ EXPECT_EQ(1, handle_to_int[h1]);
+ EXPECT_FALSE(handle_to_int.find(h2) == handle_to_int.end());
+ EXPECT_EQ(2, handle_to_int[h2]);
+ EXPECT_FALSE(handle_to_int.find(h3) == handle_to_int.end());
+ EXPECT_EQ(3, handle_to_int[h3]);
EXPECT_TRUE(handle_to_int.find(Handle(static_cast<MojoHandle>(13579))) ==
handle_to_int.end());
@@ -133,70 +133,69 @@ TEST(CoreCppTest, Basic) {
MOJO_READ_MESSAGE_FLAG_NONE));
// Basic tests of waiting and closing.
- MojoHandle hv_0 = kInvalidHandleValue;
+ MojoHandle hv0 = kInvalidHandleValue;
{
- ScopedMessagePipeHandle h_0;
- ScopedMessagePipeHandle h_1;
- EXPECT_FALSE(h_0.get().is_valid());
- EXPECT_FALSE(h_1.get().is_valid());
-
- CreateMessagePipe(&h_0, &h_1);
- EXPECT_TRUE(h_0.get().is_valid());
- EXPECT_TRUE(h_1.get().is_valid());
- EXPECT_NE(h_0.get().value(), h_1.get().value());
+ ScopedMessagePipeHandle h0;
+ ScopedMessagePipeHandle h1;
+ EXPECT_FALSE(h0.get().is_valid());
+ EXPECT_FALSE(h1.get().is_valid());
+
+ CreateMessagePipe(&h0, &h1);
+ EXPECT_TRUE(h0.get().is_valid());
+ EXPECT_TRUE(h1.get().is_valid());
+ EXPECT_NE(h0.get().value(), h1.get().value());
// Save the handle values, so we can check that things got closed
// correctly.
- hv_0 = h_0.get().value();
- MojoHandle hv_1 = h_1.get().value();
+ hv0 = h0.get().value();
+ MojoHandle hv1 = h1.get().value();
EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
- Wait(h_0.get(), MOJO_WAIT_FLAG_READABLE, 0));
+ Wait(h0.get(), MOJO_WAIT_FLAG_READABLE, 0));
std::vector<Handle> wh;
- wh.push_back(h_0.get());
- wh.push_back(h_1.get());
+ wh.push_back(h0.get());
+ wh.push_back(h1.get());
std::vector<MojoWaitFlags> wf;
wf.push_back(MOJO_WAIT_FLAG_READABLE);
wf.push_back(MOJO_WAIT_FLAG_WRITABLE);
EXPECT_EQ(1, WaitMany(wh, wf, 1000));
- // Test closing |h_1| explicitly.
- Close(h_1.Pass());
- EXPECT_FALSE(h_1.get().is_valid());
+ // Test closing |h1| explicitly.
+ Close(h1.Pass());
+ EXPECT_FALSE(h1.get().is_valid());
- // Make sure |h_1| is closed.
+ // Make sure |h1| is closed.
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- MojoWait(hv_1,
- MOJO_WAIT_FLAG_EVERYTHING,
+ MojoWait(hv1, MOJO_WAIT_FLAG_EVERYTHING,
MOJO_DEADLINE_INDEFINITE));
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- Wait(h_0.get(), MOJO_WAIT_FLAG_READABLE,
+ Wait(h0.get(), MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE));
}
- // |hv_0| should have been closed when |h_0| went out of scope, so this
- // close should fail.
- EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(hv_0));
+ // |hv0| should have been closed when |h0| went out of scope, so this close
+ // should fail.
+ EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(hv0));
// Actually test writing/reading messages.
{
- ScopedMessagePipeHandle h_0;
- ScopedMessagePipeHandle h_1;
- CreateMessagePipe(&h_0, &h_1);
+ ScopedMessagePipeHandle h0;
+ ScopedMessagePipeHandle h1;
+ CreateMessagePipe(&h0, &h1);
const char kHello[] = "hello";
const uint32_t kHelloSize = static_cast<uint32_t>(sizeof(kHello));
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_0.get(),
+ WriteMessageRaw(h0.get(),
kHello, kHelloSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(MOJO_RESULT_OK,
- Wait(h_1.get(), MOJO_WAIT_FLAG_READABLE,
+ Wait(h1.get(), MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE));
char buffer[10] = { 0 };
uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_OK,
- ReadMessageRaw(h_1.get(),
+ ReadMessageRaw(h1.get(),
buffer, &buffer_size,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_NONE));
@@ -204,27 +203,27 @@ TEST(CoreCppTest, Basic) {
EXPECT_STREQ(kHello, buffer);
// Send a handle over the previously-establish |MessagePipe|.
- ScopedMessagePipeHandle h_2;
- ScopedMessagePipeHandle h_3;
- CreateMessagePipe(&h_2, &h_3);
+ ScopedMessagePipeHandle h2;
+ ScopedMessagePipeHandle h3;
+ CreateMessagePipe(&h2, &h3);
- // Write a message to |h_2|, before we send |h_3|.
+ // Write a message to |h2|, before we send |h3|.
const char kWorld[] = "world!";
const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld));
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_2.get(),
+ WriteMessageRaw(h2.get(),
kWorld, kWorldSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // Send |h_3| over |h_1| to |h_0|.
+ // Send |h3| over |h1| to |h0|.
MojoHandle handles[5];
- handles[0] = h_3.release().value();
+ handles[0] = h3.release().value();
EXPECT_NE(kInvalidHandleValue, handles[0]);
- EXPECT_FALSE(h_3.get().is_valid());
+ EXPECT_FALSE(h3.get().is_valid());
uint32_t handles_count = 1;
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_1.get(),
+ WriteMessageRaw(h1.get(),
kHello, kHelloSize,
handles, handles_count,
MOJO_WRITE_MESSAGE_FLAG_NONE));
@@ -233,7 +232,7 @@ TEST(CoreCppTest, Basic) {
// Read "hello" and the sent handle.
EXPECT_EQ(MOJO_RESULT_OK,
- Wait(h_0.get(), MOJO_WAIT_FLAG_READABLE,
+ Wait(h0.get(), MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE));
memset(buffer, 0, sizeof(buffer));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
@@ -241,7 +240,7 @@ TEST(CoreCppTest, Basic) {
handles[i] = kInvalidHandleValue;
handles_count = static_cast<uint32_t>(MOJO_ARRAYSIZE(handles));
EXPECT_EQ(MOJO_RESULT_OK,
- ReadMessageRaw(h_0.get(),
+ ReadMessageRaw(h0.get(),
buffer, &buffer_size,
handles, &handles_count,
MOJO_READ_MESSAGE_FLAG_NONE));
@@ -251,11 +250,11 @@ TEST(CoreCppTest, Basic) {
EXPECT_NE(kInvalidHandleValue, handles[0]);
// Read from the sent/received handle.
- h_3.reset(MessagePipeHandle(handles[0]));
+ h3.reset(MessagePipeHandle(handles[0]));
// Save |handles[0]| to check that it gets properly closed.
- hv_0 = handles[0];
+ hv0 = handles[0];
EXPECT_EQ(MOJO_RESULT_OK,
- Wait(h_3.get(), MOJO_WAIT_FLAG_READABLE,
+ Wait(h3.get(), MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE));
memset(buffer, 0, sizeof(buffer));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
@@ -263,7 +262,7 @@ TEST(CoreCppTest, Basic) {
handles[i] = kInvalidHandleValue;
handles_count = static_cast<uint32_t>(MOJO_ARRAYSIZE(handles));
EXPECT_EQ(MOJO_RESULT_OK,
- ReadMessageRaw(h_3.get(),
+ ReadMessageRaw(h3.get(),
buffer, &buffer_size,
handles, &handles_count,
MOJO_READ_MESSAGE_FLAG_NONE));
@@ -271,7 +270,7 @@ TEST(CoreCppTest, Basic) {
EXPECT_STREQ(kWorld, buffer);
EXPECT_EQ(0u, handles_count);
}
- EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(hv_0));
+ EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(hv0));
}
// TODO(vtl): Test |CloseRaw()|.
@@ -282,95 +281,95 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
// Tear down a |MessagePipe| which still has a message enqueued, with the
// message also having a valid |MessagePipe| handle.
{
- ScopedMessagePipeHandle h_0;
- ScopedMessagePipeHandle h_1;
- CreateMessagePipe(&h_0, &h_1);
+ ScopedMessagePipeHandle h0;
+ ScopedMessagePipeHandle h1;
+ CreateMessagePipe(&h0, &h1);
// Send a handle over the previously-establish |MessagePipe|.
- ScopedMessagePipeHandle h_2;
- ScopedMessagePipeHandle h_3;
- CreateMessagePipe(&h_2, &h_3);
+ ScopedMessagePipeHandle h2;
+ ScopedMessagePipeHandle h3;
+ CreateMessagePipe(&h2, &h3);
- // Write a message to |h_2|, before we send |h_3|.
+ // Write a message to |h2|, before we send |h3|.
const char kWorld[] = "world!";
const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld));
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_2.get(),
+ WriteMessageRaw(h2.get(),
kWorld, kWorldSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // And also a message to |h_3|.
+ // And also a message to |h3|.
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_3.get(),
+ WriteMessageRaw(h3.get(),
kWorld, kWorldSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // Send |h_3| over |h_1| to |h_0|.
+ // Send |h3| over |h1| to |h0|.
const char kHello[] = "hello";
const uint32_t kHelloSize = static_cast<uint32_t>(sizeof(kHello));
- MojoHandle h_3_value;
- h_3_value = h_3.release().value();
- EXPECT_NE(kInvalidHandleValue, h_3_value);
- EXPECT_FALSE(h_3.get().is_valid());
+ MojoHandle h3_value;
+ h3_value = h3.release().value();
+ EXPECT_NE(kInvalidHandleValue, h3_value);
+ EXPECT_FALSE(h3.get().is_valid());
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_1.get(),
+ WriteMessageRaw(h1.get(),
kHello, kHelloSize,
- &h_3_value, 1,
+ &h3_value, 1,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // |h_3_value| should actually be invalid now.
- EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(h_3_value));
+ // |h3_value| should actually be invalid now.
+ EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(h3_value));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_0.release().value()));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_1.release().value()));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_2.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h2.release().value()));
}
// Do this in a different order: make the enqueued |MessagePipe| handle only
// half-alive.
{
- ScopedMessagePipeHandle h_0;
- ScopedMessagePipeHandle h_1;
- CreateMessagePipe(&h_0, &h_1);
+ ScopedMessagePipeHandle h0;
+ ScopedMessagePipeHandle h1;
+ CreateMessagePipe(&h0, &h1);
// Send a handle over the previously-establish |MessagePipe|.
- ScopedMessagePipeHandle h_2;
- ScopedMessagePipeHandle h_3;
- CreateMessagePipe(&h_2, &h_3);
+ ScopedMessagePipeHandle h2;
+ ScopedMessagePipeHandle h3;
+ CreateMessagePipe(&h2, &h3);
- // Write a message to |h_2|, before we send |h_3|.
+ // Write a message to |h2|, before we send |h3|.
const char kWorld[] = "world!";
const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld));
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_2.get(),
+ WriteMessageRaw(h2.get(),
kWorld, kWorldSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // And also a message to |h_3|.
+ // And also a message to |h3|.
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_3.get(),
+ WriteMessageRaw(h3.get(),
kWorld, kWorldSize,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // Send |h_3| over |h_1| to |h_0|.
+ // Send |h3| over |h1| to |h0|.
const char kHello[] = "hello";
const uint32_t kHelloSize = static_cast<uint32_t>(sizeof(kHello));
- MojoHandle h_3_value;
- h_3_value = h_3.release().value();
- EXPECT_NE(kInvalidHandleValue, h_3_value);
- EXPECT_FALSE(h_3.get().is_valid());
+ MojoHandle h3_value;
+ h3_value = h3.release().value();
+ EXPECT_NE(kInvalidHandleValue, h3_value);
+ EXPECT_FALSE(h3.get().is_valid());
EXPECT_EQ(MOJO_RESULT_OK,
- WriteMessageRaw(h_1.get(),
+ WriteMessageRaw(h1.get(),
kHello, kHelloSize,
- &h_3_value, 1,
+ &h3_value, 1,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // |h_3_value| should actually be invalid now.
- EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(h_3_value));
+ // |h3_value| should actually be invalid now.
+ EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(h3_value));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_2.release().value()));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_0.release().value()));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_1.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h2.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0.release().value()));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1.release().value()));
}
}
diff --git a/mojo/public/tests/system/core_perftest.cc b/mojo/public/tests/system/core_perftest.cc
index 247ac2b..318b708 100644
--- a/mojo/public/tests/system/core_perftest.cc
+++ b/mojo/public/tests/system/core_perftest.cc
@@ -25,24 +25,24 @@ class CorePerftest : public testing::Test {
static void MessagePipe_CreateAndClose(void* closure) {
CorePerftest* self = static_cast<CorePerftest*>(closure);
MojoResult result MOJO_ALLOW_UNUSED;
- result = MojoCreateMessagePipe(&self->h_0_, &self->h_1_);
+ result = MojoCreateMessagePipe(&self->h0_, &self->h1_);
assert(result == MOJO_RESULT_OK);
- result = MojoClose(self->h_0_);
+ result = MojoClose(self->h0_);
assert(result == MOJO_RESULT_OK);
- result = MojoClose(self->h_1_);
+ result = MojoClose(self->h1_);
assert(result == MOJO_RESULT_OK);
}
static void MessagePipe_WriteAndRead(void* closure) {
CorePerftest* self = static_cast<CorePerftest*>(closure);
MojoResult result MOJO_ALLOW_UNUSED;
- result = MojoWriteMessage(self->h_0_,
+ result = MojoWriteMessage(self->h0_,
self->buffer_, self->num_bytes_,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE);
assert(result == MOJO_RESULT_OK);
uint32_t read_bytes = self->num_bytes_;
- result = MojoReadMessage(self->h_1_,
+ result = MojoReadMessage(self->h1_,
self->buffer_, &read_bytes,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_NONE);
@@ -52,7 +52,7 @@ class CorePerftest : public testing::Test {
static void MessagePipe_EmptyRead(void* closure) {
CorePerftest* self = static_cast<CorePerftest*>(closure);
MojoResult result MOJO_ALLOW_UNUSED;
- result = MojoReadMessage(self->h_0_,
+ result = MojoReadMessage(self->h0_,
NULL, NULL,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
@@ -60,8 +60,8 @@ class CorePerftest : public testing::Test {
}
protected:
- MojoHandle h_0_;
- MojoHandle h_1_;
+ MojoHandle h0_;
+ MojoHandle h1_;
void* buffer_;
uint32_t num_bytes_;
@@ -83,7 +83,7 @@ TEST_F(CorePerftest, MessagePipe_CreateAndClose) {
TEST_F(CorePerftest, MessagePipe_WriteAndRead) {
MojoResult result MOJO_ALLOW_UNUSED;
- result = MojoCreateMessagePipe(&h_0_, &h_1_);
+ result = MojoCreateMessagePipe(&h0_, &h1_);
assert(result == MOJO_RESULT_OK);
char buffer[10000] = { 0 };
buffer_ = buffer;
@@ -103,22 +103,22 @@ TEST_F(CorePerftest, MessagePipe_WriteAndRead) {
mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_10000bytes",
&CorePerftest::MessagePipe_WriteAndRead,
this);
- result = MojoClose(h_0_);
+ result = MojoClose(h0_);
assert(result == MOJO_RESULT_OK);
- result = MojoClose(h_1_);
+ result = MojoClose(h1_);
assert(result == MOJO_RESULT_OK);
}
TEST_F(CorePerftest, MessagePipe_EmptyRead) {
MojoResult result MOJO_ALLOW_UNUSED;
- result = MojoCreateMessagePipe(&h_0_, &h_1_);
+ result = MojoCreateMessagePipe(&h0_, &h1_);
assert(result == MOJO_RESULT_OK);
mojo::test::IterateAndReportPerf("MessagePipe_EmptyRead",
&CorePerftest::MessagePipe_EmptyRead,
this);
- result = MojoClose(h_0_);
+ result = MojoClose(h0_);
assert(result == MOJO_RESULT_OK);
- result = MojoClose(h_1_);
+ result = MojoClose(h1_);
assert(result == MOJO_RESULT_OK);
}
diff --git a/mojo/public/tests/system/core_unittest.cc b/mojo/public/tests/system/core_unittest.cc
index 01f677b..32174c3 100644
--- a/mojo/public/tests/system/core_unittest.cc
+++ b/mojo/public/tests/system/core_unittest.cc
@@ -20,7 +20,7 @@ TEST(CoreTest, GetTimeTicksNow) {
}
TEST(CoreTest, Basic) {
- MojoHandle h_0;
+ MojoHandle h0;
MojoWaitFlags wf;
char buffer[10] = { 0 };
uint32_t buffer_size;
@@ -29,80 +29,79 @@ TEST(CoreTest, Basic) {
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(MOJO_HANDLE_INVALID));
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
MojoWait(MOJO_HANDLE_INVALID, MOJO_WAIT_FLAG_EVERYTHING, 1000000));
- h_0 = MOJO_HANDLE_INVALID;
+ h0 = MOJO_HANDLE_INVALID;
wf = MOJO_WAIT_FLAG_EVERYTHING;
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- MojoWaitMany(&h_0, &wf, 1, MOJO_DEADLINE_INDEFINITE));
+ MojoWaitMany(&h0, &wf, 1, MOJO_DEADLINE_INDEFINITE));
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- MojoWriteMessage(h_0,
+ MojoWriteMessage(h0,
buffer, 3,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- MojoReadMessage(h_0,
+ MojoReadMessage(h0,
buffer, &buffer_size,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_NONE));
- MojoHandle h_1;
- EXPECT_EQ(MOJO_RESULT_OK, MojoCreateMessagePipe(&h_0, &h_1));
+ MojoHandle h1;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoCreateMessagePipe(&h0, &h1));
// Shouldn't be readable.
EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
- MojoWait(h_0, MOJO_WAIT_FLAG_READABLE, 0));
+ MojoWait(h0, MOJO_WAIT_FLAG_READABLE, 0));
// Should be writable.
EXPECT_EQ(MOJO_RESULT_OK,
- MojoWait(h_0, MOJO_WAIT_FLAG_WRITABLE, 0));
+ MojoWait(h0, MOJO_WAIT_FLAG_WRITABLE, 0));
// Try to read.
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- MojoReadMessage(h_0,
+ MojoReadMessage(h0,
buffer, &buffer_size,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_NONE));
- // Write to |h_1|.
+ // Write to |h1|.
static const char hello[] = "hello";
memcpy(buffer, hello, sizeof(hello));
buffer_size = static_cast<uint32_t>(sizeof(hello));
EXPECT_EQ(MOJO_RESULT_OK,
- MojoWriteMessage(h_1,
+ MojoWriteMessage(h1,
hello, buffer_size,
NULL, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
- // |h_0| should be readable.
+ // |h0| should be readable.
wf = MOJO_WAIT_FLAG_READABLE;
EXPECT_EQ(MOJO_RESULT_OK,
- MojoWaitMany(&h_0, &wf, 1, MOJO_DEADLINE_INDEFINITE));
+ MojoWaitMany(&h0, &wf, 1, MOJO_DEADLINE_INDEFINITE));
- // Read from |h_0|.
+ // Read from |h0|.
memset(buffer, 0, sizeof(buffer));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_OK,
- MojoReadMessage(h_0,
+ MojoReadMessage(h0,
buffer, &buffer_size,
NULL, NULL,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(static_cast<uint32_t>(sizeof(hello)), buffer_size);
EXPECT_EQ(0, memcmp(hello, buffer, sizeof(hello)));
- // |h_0| should no longer be readable.
+ // |h0| should no longer be readable.
EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
- MojoWait(h_0, MOJO_WAIT_FLAG_READABLE, 10));
+ MojoWait(h0, MOJO_WAIT_FLAG_READABLE, 10));
- // Close |h_0|.
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_0));
+ // Close |h0|.
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0));
- // |h_1| should no longer be readable or writable.
+ // |h1| should no longer be readable or writable.
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- MojoWait(h_1,
- MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE,
+ MojoWait(h1, MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE,
1000));
- EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h_1));
+ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1));
}
// TODO(vtl): Add multi-threaded tests.
diff --git a/mojo/system/core_impl.cc b/mojo/system/core_impl.cc
index 74cda83..5bda3c8 100644
--- a/mojo/system/core_impl.cc
+++ b/mojo/system/core_impl.cc
@@ -155,20 +155,18 @@ MojoResult CoreImpl::CreateMessagePipe(MojoHandle* message_pipe_handle0,
if (!VerifyUserPointer<MojoHandle>(message_pipe_handle1, 1))
return MOJO_RESULT_INVALID_ARGUMENT;
- scoped_refptr<MessagePipeDispatcher> dispatcher_0(
- new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> dispatcher_1(
- new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> dispatcher0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> dispatcher1(new MessagePipeDispatcher());
MojoHandle h0, h1;
{
base::AutoLock locker(handle_table_lock_);
- h0 = AddDispatcherNoLock(dispatcher_0);
+ h0 = AddDispatcherNoLock(dispatcher0);
if (h0 == MOJO_HANDLE_INVALID)
return MOJO_RESULT_RESOURCE_EXHAUSTED;
- h1 = AddDispatcherNoLock(dispatcher_1);
+ h1 = AddDispatcherNoLock(dispatcher1);
if (h1 == MOJO_HANDLE_INVALID) {
handle_table_.erase(h0);
return MOJO_RESULT_RESOURCE_EXHAUSTED;
@@ -176,8 +174,8 @@ MojoResult CoreImpl::CreateMessagePipe(MojoHandle* message_pipe_handle0,
}
scoped_refptr<MessagePipe> message_pipe(new MessagePipe());
- dispatcher_0->Init(message_pipe, 0);
- dispatcher_1->Init(message_pipe, 1);
+ dispatcher0->Init(message_pipe, 0);
+ dispatcher1->Init(message_pipe, 1);
*message_pipe_handle0 = h0;
*message_pipe_handle1 = h1;
diff --git a/mojo/system/core_impl_unittest.cc b/mojo/system/core_impl_unittest.cc
index 522bf07..8550bb0 100644
--- a/mojo/system/core_impl_unittest.cc
+++ b/mojo/system/core_impl_unittest.cc
@@ -251,11 +251,11 @@ TEST_F(CoreImplTest, InvalidArguments) {
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(0u, info.GetWriteMessageCallCount());
- MockHandleInfo info_2;
- MojoHandle h_2 = CreateMockHandle(&info_2);
+ MockHandleInfo info2;
+ MojoHandle h2 = CreateMockHandle(&info2);
// This is "okay", but |MockDispatcher| doesn't implement it.
- handles[0] = h_2;
+ handles[0] = h2;
EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED,
core()->WriteMessage(h, NULL, 0, handles, 1,
MOJO_WRITE_MESSAGE_FLAG_NONE));
@@ -275,15 +275,15 @@ TEST_F(CoreImplTest, InvalidArguments) {
EXPECT_EQ(1u, info.GetWriteMessageCallCount());
// Can't send a handle twice in the same message.
- handles[1] = h_2;
+ handles[1] = h2;
EXPECT_EQ(MOJO_RESULT_BUSY,
core()->WriteMessage(h, NULL, 0, handles, 2,
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(1u, info.GetWriteMessageCallCount());
- // Note: Since we never successfully sent anything with it, |h_2| should
+ // Note: Since we never successfully sent anything with it, |h2| should
// still be valid.
- EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_2));
+ EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h2));
EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h));
}
diff --git a/mojo/system/message_pipe.cc b/mojo/system/message_pipe.cc
index 4083cd8..65da768 100644
--- a/mojo/system/message_pipe.cc
+++ b/mojo/system/message_pipe.cc
@@ -15,10 +15,10 @@
namespace mojo {
namespace system {
-MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint_0,
- scoped_ptr<MessagePipeEndpoint> endpoint_1) {
- endpoints_[0].reset(endpoint_0.release());
- endpoints_[1].reset(endpoint_1.release());
+MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0,
+ scoped_ptr<MessagePipeEndpoint> endpoint1) {
+ endpoints_[0].reset(endpoint0.release());
+ endpoints_[1].reset(endpoint1.release());
}
MessagePipe::MessagePipe() {
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index 111d690..0849a66 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -30,8 +30,8 @@ class Waiter;
class MOJO_SYSTEM_IMPL_EXPORT MessagePipe :
public base::RefCountedThreadSafe<MessagePipe> {
public:
- MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint_0,
- scoped_ptr<MessagePipeEndpoint> endpoint_1);
+ MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0,
+ scoped_ptr<MessagePipeEndpoint> endpoint1);
// Convenience constructor that constructs a |MessagePipe| with two new
// |LocalMessagePipeEndpoint|s.
diff --git a/mojo/system/message_pipe_dispatcher_unittest.cc b/mojo/system/message_pipe_dispatcher_unittest.cc
index 1069f49..938634d 100644
--- a/mojo/system/message_pipe_dispatcher_unittest.cc
+++ b/mojo/system/message_pipe_dispatcher_unittest.cc
@@ -38,114 +38,114 @@ TEST(MessagePipeDispatcherTest, Basic) {
uint32_t buffer_size;
int64_t elapsed_micros;
- // Run this test both with |d_0| as port 0, |d_1| as port 1 and vice versa.
+ // Run this test both with |d0| as port 0, |d1| as port 1 and vice versa.
for (unsigned i = 0; i < 2; i++) {
- scoped_refptr<MessagePipeDispatcher> d_0(new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> d_1(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d1(new MessagePipeDispatcher());
{
scoped_refptr<MessagePipe> mp(new MessagePipe());
- d_0->Init(mp, i); // 0, 1.
- d_1->Init(mp, i ^ 1); // 1, 0.
+ d0->Init(mp, i); // 0, 1.
+ d1->Init(mp, i ^ 1); // 1, 0.
}
Waiter w;
// Try adding a writable waiter when already writable.
w.Init();
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 0));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 0));
// Shouldn't need to remove the waiter (it was not added).
- // Add a readable waiter to |d_0|, then make it readable (by writing to
- // |d_1|), then wait.
+ // Add a readable waiter to |d0|, then make it readable (by writing to
+ // |d1|), then wait.
w.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1));
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d_1->WriteMessage(buffer, kBufferSize,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(buffer, kBufferSize,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
stopwatch.Start();
EXPECT_EQ(1, w.Wait(MOJO_DEADLINE_INDEFINITE));
elapsed_micros = stopwatch.Elapsed();
EXPECT_LT(elapsed_micros, kEpsilonMicros);
- d_0->RemoveWaiter(&w);
+ d0->RemoveWaiter(&w);
// Try adding a readable waiter when already readable (from above).
w.Init();
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 2));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 2));
// Shouldn't need to remove the waiter (it was not added).
- // Make |d_0| no longer readable (by reading from it).
+ // Make |d0| no longer readable (by reading from it).
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d0->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
- // Wait for zero time for readability on |d_0| (will time out).
+ // Wait for zero time for readability on |d0| (will time out).
w.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
stopwatch.Start();
EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, w.Wait(0));
elapsed_micros = stopwatch.Elapsed();
EXPECT_LT(elapsed_micros, kEpsilonMicros);
- d_0->RemoveWaiter(&w);
+ d0->RemoveWaiter(&w);
- // Wait for non-zero, finite time for readability on |d_0| (will time out).
+ // Wait for non-zero, finite time for readability on |d0| (will time out).
w.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
stopwatch.Start();
EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, w.Wait(2 * kEpsilonMicros));
elapsed_micros = stopwatch.Elapsed();
EXPECT_GT(elapsed_micros, (2-1) * kEpsilonMicros);
EXPECT_LT(elapsed_micros, (2+1) * kEpsilonMicros);
- d_0->RemoveWaiter(&w);
+ d0->RemoveWaiter(&w);
- EXPECT_EQ(MOJO_RESULT_OK, d_0->Close());
- EXPECT_EQ(MOJO_RESULT_OK, d_1->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
}
}
TEST(MessagePipeDispatcherTest, InvalidParams) {
char buffer[1];
- scoped_refptr<MessagePipeDispatcher> d_0(new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> d_1(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d1(new MessagePipeDispatcher());
{
scoped_refptr<MessagePipe> mp(new MessagePipe());
- d_0->Init(mp, 0);
- d_1->Init(mp, 1);
+ d0->Init(mp, 0);
+ d1->Init(mp, 1);
}
// |WriteMessage|:
// Null buffer with nonzero buffer size.
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- d_0->WriteMessage(NULL, 1,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(NULL, 1,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
// Huge buffer size.
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
- d_0->WriteMessage(buffer, std::numeric_limits<uint32_t>::max(),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(buffer, std::numeric_limits<uint32_t>::max(),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
// |ReadMessage|:
// Null buffer with nonzero buffer size.
uint32_t buffer_size = 1;
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
- d_0->ReadMessage(NULL, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d0->ReadMessage(NULL, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
- EXPECT_EQ(MOJO_RESULT_OK, d_0->Close());
- EXPECT_EQ(MOJO_RESULT_OK, d_1->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
}
// Test what happens when one end is closed (single-threaded test).
@@ -154,102 +154,102 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
const uint32_t kBufferSize = static_cast<uint32_t>(sizeof(buffer));
uint32_t buffer_size;
- // Run this test both with |d_0| as port 0, |d_1| as port 1 and vice versa.
+ // Run this test both with |d0| as port 0, |d1| as port 1 and vice versa.
for (unsigned i = 0; i < 2; i++) {
- scoped_refptr<MessagePipeDispatcher> d_0(new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> d_1(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d1(new MessagePipeDispatcher());
{
scoped_refptr<MessagePipe> mp(new MessagePipe());
- d_0->Init(mp, i); // 0, 1.
- d_1->Init(mp, i ^ 1); // 1, 0.
+ d0->Init(mp, i); // 0, 1.
+ d1->Init(mp, i ^ 1); // 1, 0.
}
Waiter w;
- // Write (twice) to |d_1|.
+ // Write (twice) to |d1|.
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d_1->WriteMessage(buffer, kBufferSize,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(buffer, kBufferSize,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
buffer[0] = 234567890;
EXPECT_EQ(MOJO_RESULT_OK,
- d_1->WriteMessage(buffer, kBufferSize,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(buffer, kBufferSize,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
- // Try waiting for readable on |d_0|; should fail (already satisfied).
+ // Try waiting for readable on |d0|; should fail (already satisfied).
w.Init();
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 0));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 0));
- // Try reading from |d_1|; should fail (nothing to read).
+ // Try reading from |d1|; should fail (nothing to read).
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- d_1->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d1->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
- // Close |d_1|.
- EXPECT_EQ(MOJO_RESULT_OK, d_1->Close());
+ // Close |d1|.
+ EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
- // Try waiting for readable on |d_0|; should fail (already satisfied).
+ // Try waiting for readable on |d0|; should fail (already satisfied).
w.Init();
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 1));
- // Read from |d_0|.
+ // Read from |d0|.
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d0->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
- // Try waiting for readable on |d_0|; should fail (already satisfied).
+ // Try waiting for readable on |d0|; should fail (already satisfied).
w.Init();
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 2));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 2));
- // Read again from |d_0|.
+ // Read again from |d0|.
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d0->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(234567890, buffer[0]);
- // Try waiting for readable on |d_0|; should fail (unsatisfiable).
+ // Try waiting for readable on |d0|; should fail (unsatisfiable).
w.Init();
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_READABLE, 3));
- // Try waiting for writable on |d_0|; should fail (unsatisfiable).
+ // Try waiting for writable on |d0|; should fail (unsatisfiable).
w.Init();
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- d_0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 4));
+ d0->AddWaiter(&w, MOJO_WAIT_FLAG_WRITABLE, 4));
- // Try reading from |d_0|; should fail (nothing to read and other end
+ // Try reading from |d0|; should fail (nothing to read and other end
// closed).
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- d_0->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d0->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
- // Try writing to |d_0|; should fail (other end closed).
+ // Try writing to |d0|; should fail (other end closed).
buffer[0] = 345678901;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- d_0->WriteMessage(buffer, kBufferSize,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(buffer, kBufferSize,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
- EXPECT_EQ(MOJO_RESULT_OK, d_0->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
}
}
@@ -262,33 +262,33 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
MojoResult result;
int64_t elapsed_micros;
- // Run this test both with |d_0| as port 0, |d_1| as port 1 and vice versa.
+ // Run this test both with |d0| as port 0, |d1| as port 1 and vice versa.
for (unsigned i = 0; i < 2; i++) {
- scoped_refptr<MessagePipeDispatcher> d_0(new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> d_1(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d1(new MessagePipeDispatcher());
{
scoped_refptr<MessagePipe> mp(new MessagePipe());
- d_0->Init(mp, i); // 0, 1.
- d_1->Init(mp, i ^ 1); // 1, 0.
+ d0->Init(mp, i); // 0, 1.
+ d1->Init(mp, i ^ 1); // 1, 0.
}
- // Wait for readable on |d_1|, which will become readable after some time.
+ // Wait for readable on |d1|, which will become readable after some time.
{
- test::WaiterThread thread(d_1,
- MOJO_WAIT_FLAG_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- 0,
- &did_wait, &result);
+ test::WaiterThread thread(d1,
+ MOJO_WAIT_FLAG_READABLE,
+ MOJO_DEADLINE_INDEFINITE,
+ 0,
+ &did_wait, &result);
stopwatch.Start();
thread.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
- // Wake it up by writing to |d_0|.
+ // Wake it up by writing to |d0|.
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d_0->WriteMessage(buffer, kBufferSize,
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(buffer, kBufferSize,
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
} // Joins the thread.
elapsed_micros = stopwatch.Elapsed();
EXPECT_TRUE(did_wait);
@@ -296,9 +296,9 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
EXPECT_GT(elapsed_micros, (2-1) * kEpsilonMicros);
EXPECT_LT(elapsed_micros, (2+1) * kEpsilonMicros);
- // Now |d_1| is already readable. Try waiting for it again.
+ // Now |d1| is already readable. Try waiting for it again.
{
- test::WaiterThread thread(d_1,
+ test::WaiterThread thread(d1,
MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE,
1,
@@ -311,20 +311,20 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, result);
EXPECT_LT(elapsed_micros, kEpsilonMicros);
- // Consume what we wrote to |d_0|.
+ // Consume what we wrote to |d0|.
buffer[0] = 0;
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
- d_1->ReadMessage(buffer, &buffer_size,
- 0, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ d1->ReadMessage(buffer, &buffer_size,
+ 0, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
- // Wait for readable on |d_1| and close |d_0| after some time, which should
+ // Wait for readable on |d1| and close |d0| after some time, which should
// cancel that wait.
{
- test::WaiterThread thread(d_1,
+ test::WaiterThread thread(d1,
MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE,
0,
@@ -333,7 +333,7 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
thread.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
- EXPECT_EQ(MOJO_RESULT_OK, d_0->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
} // Joins the thread.
elapsed_micros = stopwatch.Elapsed();
EXPECT_TRUE(did_wait);
@@ -341,22 +341,22 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
EXPECT_GT(elapsed_micros, (2-1) * kEpsilonMicros);
EXPECT_LT(elapsed_micros, (2+1) * kEpsilonMicros);
- EXPECT_EQ(MOJO_RESULT_OK, d_1->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
}
for (unsigned i = 0; i < 2; i++) {
- scoped_refptr<MessagePipeDispatcher> d_0(new MessagePipeDispatcher());
- scoped_refptr<MessagePipeDispatcher> d_1(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d0(new MessagePipeDispatcher());
+ scoped_refptr<MessagePipeDispatcher> d1(new MessagePipeDispatcher());
{
scoped_refptr<MessagePipe> mp(new MessagePipe());
- d_0->Init(mp, i); // 0, 1.
- d_1->Init(mp, i ^ 1); // 1, 0.
+ d0->Init(mp, i); // 0, 1.
+ d1->Init(mp, i ^ 1); // 1, 0.
}
- // Wait for readable on |d_1| and close |d_1| after some time, which should
+ // Wait for readable on |d1| and close |d1| after some time, which should
// cancel that wait.
{
- test::WaiterThread thread(d_1,
+ test::WaiterThread thread(d1,
MOJO_WAIT_FLAG_READABLE,
MOJO_DEADLINE_INDEFINITE,
0,
@@ -365,7 +365,7 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
thread.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
- EXPECT_EQ(MOJO_RESULT_OK, d_1->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
} // Joins the thread.
elapsed_micros = stopwatch.Elapsed();
EXPECT_TRUE(did_wait);
@@ -373,7 +373,7 @@ TEST(MessagePipeDispatcherTest, BasicThreaded) {
EXPECT_GT(elapsed_micros, (2-1) * kEpsilonMicros);
EXPECT_LT(elapsed_micros, (2+1) * kEpsilonMicros);
- EXPECT_EQ(MOJO_RESULT_OK, d_0->Close());
+ EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
}
}
diff --git a/mojo/system/remote_message_pipe_posix_unittest.cc b/mojo/system/remote_message_pipe_posix_unittest.cc
index 1493f0e..f390509 100644
--- a/mojo/system/remote_message_pipe_posix_unittest.cc
+++ b/mojo/system/remote_message_pipe_posix_unittest.cc
@@ -51,13 +51,13 @@ class RemoteMessagePipeTest : public test::TestWithIOThreadBase {
// This connects MP 0, port 1 and MP 1, port 0 (leaving MP 0, port 0 and MP 1,
// port 1 as the user-visible endpoints) to channel 0 and 1, respectively. MP
// 0, port 1 and MP 1, port 0 must have |ProxyMessagePipeEndpoint|s.
- void ConnectMessagePipes(scoped_refptr<MessagePipe> mp_0,
- scoped_refptr<MessagePipe> mp_1) {
+ void ConnectMessagePipes(scoped_refptr<MessagePipe> mp0,
+ scoped_refptr<MessagePipe> mp1) {
test::PostTaskAndWait(
io_thread_task_runner(),
FROM_HERE,
base::Bind(&RemoteMessagePipeTest::ConnectMessagePipesOnIOThread,
- base::Unretained(this), mp_0, mp_1));
+ base::Unretained(this), mp0, mp1));
}
// This connects |mp|'s port |channel_index ^ 1| to channel |channel_index|.
@@ -91,8 +91,8 @@ class RemoteMessagePipeTest : public test::TestWithIOThreadBase {
platform_handles_[channel_index].Pass()));
}
- void ConnectMessagePipesOnIOThread(scoped_refptr<MessagePipe> mp_0,
- scoped_refptr<MessagePipe> mp_1) {
+ void ConnectMessagePipesOnIOThread(scoped_refptr<MessagePipe> mp0,
+ scoped_refptr<MessagePipe> mp1) {
CHECK_EQ(base::MessageLoop::current(), io_thread_message_loop());
if (!channels_[0].get())
@@ -100,13 +100,13 @@ class RemoteMessagePipeTest : public test::TestWithIOThreadBase {
if (!channels_[1].get())
CreateAndInitChannel(1);
- MessageInTransit::EndpointId local_id_0 =
- channels_[0]->AttachMessagePipeEndpoint(mp_0, 1);
- MessageInTransit::EndpointId local_id_1 =
- channels_[1]->AttachMessagePipeEndpoint(mp_1, 0);
+ MessageInTransit::EndpointId local_id0 =
+ channels_[0]->AttachMessagePipeEndpoint(mp0, 1);
+ MessageInTransit::EndpointId local_id1 =
+ channels_[1]->AttachMessagePipeEndpoint(mp1, 0);
- channels_[0]->RunMessagePipeEndpoint(local_id_0, local_id_1);
- channels_[1]->RunMessagePipeEndpoint(local_id_1, local_id_0);
+ channels_[0]->RunMessagePipeEndpoint(local_id0, local_id1);
+ channels_[1]->RunMessagePipeEndpoint(local_id1, local_id0);
}
void BootstrapMessagePipeOnIOThread(unsigned channel_index,
@@ -152,13 +152,13 @@ TEST_F(RemoteMessagePipeTest, Basic) {
// connected to MP 1, port 0, which will be attached to channel 1. This leaves
// MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints.
- scoped_refptr<MessagePipe> mp_0(new MessagePipe(
+ scoped_refptr<MessagePipe> mp0(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint())));
- scoped_refptr<MessagePipe> mp_1(new MessagePipe(
+ scoped_refptr<MessagePipe> mp1(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint())));
- ConnectMessagePipes(mp_0, mp_1);
+ ConnectMessagePipes(mp0, mp1);
// Write in one direction: MP 0, port 0 -> ... -> MP 1, port 1.
@@ -166,25 +166,25 @@ TEST_F(RemoteMessagePipeTest, Basic) {
// it later, it might already be readable.)
waiter.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
+ mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
// Write to MP 0, port 0.
EXPECT_EQ(MOJO_RESULT_OK,
- mp_0->WriteMessage(0,
- hello, sizeof(hello),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp0->WriteMessage(0,
+ hello, sizeof(hello),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
// Wait.
EXPECT_EQ(123, waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_1->RemoveWaiter(1, &waiter);
+ mp1->RemoveWaiter(1, &waiter);
// Read from MP 1, port 1.
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp1->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(sizeof(hello), static_cast<size_t>(buffer_size));
EXPECT_EQ(0, strcmp(buffer, hello));
@@ -192,44 +192,44 @@ TEST_F(RemoteMessagePipeTest, Basic) {
waiter.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- mp_0->AddWaiter(0, &waiter, MOJO_WAIT_FLAG_READABLE, 456));
+ mp0->AddWaiter(0, &waiter, MOJO_WAIT_FLAG_READABLE, 456));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->WriteMessage(1,
- world, sizeof(world),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp1->WriteMessage(1,
+ world, sizeof(world),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(456, waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_0->RemoveWaiter(0, &waiter);
+ mp0->RemoveWaiter(0, &waiter);
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_0->ReadMessage(0,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp0->ReadMessage(0,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(sizeof(world), static_cast<size_t>(buffer_size));
EXPECT_EQ(0, strcmp(buffer, world));
// Close MP 0, port 0.
- mp_0->Close(0);
+ mp0->Close(0);
// Try to wait for MP 1, port 1 to become readable. This will eventually fail
// when it realizes that MP 0, port 0 has been closed. (It may also fail
// immediately.)
waiter.Init();
- MojoResult result = mp_1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 789);
+ MojoResult result = mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 789);
if (result == MOJO_RESULT_OK) {
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_1->RemoveWaiter(1, &waiter);
+ mp1->RemoveWaiter(1, &waiter);
} else {
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result);
}
// And MP 1, port 1.
- mp_1->Close(1);
+ mp1->Close(1);
}
TEST_F(RemoteMessagePipeTest, Multiplex) {
@@ -241,66 +241,66 @@ TEST_F(RemoteMessagePipeTest, Multiplex) {
// Connect message pipes as in the |Basic| test.
- scoped_refptr<MessagePipe> mp_0(new MessagePipe(
+ scoped_refptr<MessagePipe> mp0(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint())));
- scoped_refptr<MessagePipe> mp_1(new MessagePipe(
+ scoped_refptr<MessagePipe> mp1(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint())));
- ConnectMessagePipes(mp_0, mp_1);
+ ConnectMessagePipes(mp0, mp1);
// Now put another message pipe on the channel.
- scoped_refptr<MessagePipe> mp_2(new MessagePipe(
+ scoped_refptr<MessagePipe> mp2(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint())));
- scoped_refptr<MessagePipe> mp_3(new MessagePipe(
+ scoped_refptr<MessagePipe> mp3(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint())));
- ConnectMessagePipes(mp_2, mp_3);
+ ConnectMessagePipes(mp2, mp3);
// Write: MP 2, port 0 -> MP 3, port 1.
waiter.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- mp_3->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 789));
+ mp3->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 789));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_2->WriteMessage(0,
- hello, sizeof(hello),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp2->WriteMessage(0,
+ hello, sizeof(hello),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(789, waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_3->RemoveWaiter(1, &waiter);
+ mp3->RemoveWaiter(1, &waiter);
// Make sure there's nothing on MP 0, port 0 or MP 1, port 1 or MP 2, port 0.
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_0->ReadMessage(0,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp0->ReadMessage(0,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_1->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp1->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_2->ReadMessage(0,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp2->ReadMessage(0,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
// Read from MP 3, port 1.
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_3->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp3->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(sizeof(hello), static_cast<size_t>(buffer_size));
EXPECT_EQ(0, strcmp(buffer, hello));
@@ -308,43 +308,43 @@ TEST_F(RemoteMessagePipeTest, Multiplex) {
waiter.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
+ mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_0->WriteMessage(0,
- world, sizeof(world),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp0->WriteMessage(0,
+ world, sizeof(world),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(123, waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_1->RemoveWaiter(1, &waiter);
+ mp1->RemoveWaiter(1, &waiter);
// Make sure there's nothing on the other ports.
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_0->ReadMessage(0,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp0->ReadMessage(0,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_2->ReadMessage(0,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp2->ReadMessage(0,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
- mp_3->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp3->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp1->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(sizeof(world), static_cast<size_t>(buffer_size));
EXPECT_EQ(0, strcmp(buffer, world));
}
@@ -359,24 +359,24 @@ TEST_F(RemoteMessagePipeTest, CloseBeforeConnect) {
// connected to MP 1, port 0, which will be attached to channel 1. This leaves
// MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints.
- scoped_refptr<MessagePipe> mp_0(new MessagePipe(
+ scoped_refptr<MessagePipe> mp0(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint())));
// Write to MP 0, port 0.
EXPECT_EQ(MOJO_RESULT_OK,
- mp_0->WriteMessage(0,
- hello, sizeof(hello),
- NULL,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ mp0->WriteMessage(0,
+ hello, sizeof(hello),
+ NULL,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
- BootstrapMessagePipeNoWait(0, mp_0);
+ BootstrapMessagePipeNoWait(0, mp0);
// Close MP 0, port 0 before channel 1 is even connected.
- mp_0->Close(0);
+ mp0->Close(0);
- scoped_refptr<MessagePipe> mp_1(new MessagePipe(
+ scoped_refptr<MessagePipe> mp1(new MessagePipe(
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()),
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint())));
@@ -384,26 +384,27 @@ TEST_F(RemoteMessagePipeTest, CloseBeforeConnect) {
// it later, it might already be readable.)
waiter.Init();
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
+ mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123));
- BootstrapMessagePipeNoWait(1, mp_1);
+ BootstrapMessagePipeNoWait(1, mp1);
// Wait.
EXPECT_EQ(123, waiter.Wait(MOJO_DEADLINE_INDEFINITE));
- mp_1->RemoveWaiter(1, &waiter);
+ mp1->RemoveWaiter(1, &waiter);
// Read from MP 1, port 1.
EXPECT_EQ(MOJO_RESULT_OK,
- mp_1->ReadMessage(1,
- buffer, &buffer_size,
- NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE));
+ mp1->ReadMessage(1,
+ buffer, &buffer_size,
+ NULL, NULL,
+ MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(sizeof(hello), static_cast<size_t>(buffer_size));
EXPECT_EQ(0, strcmp(buffer, hello));
// And MP 1, port 1.
- mp_1->Close(1);
+ mp1->Close(1);
}
+
} // namespace
} // namespace system
} // namespace mojo
diff --git a/mojo/system/waiter_list_unittest.cc b/mojo/system/waiter_list_unittest.cc
index fa6564c..437d334 100644
--- a/mojo/system/waiter_list_unittest.cc
+++ b/mojo/system/waiter_list_unittest.cc
@@ -146,71 +146,71 @@ TEST(WaiterListTest, BasicAwakeUnsatisfiable) {
}
TEST(WaiterListTest, MultipleWaiters) {
- MojoResult result_1;
- MojoResult result_2;
- MojoResult result_3;
- MojoResult result_4;
+ MojoResult result1;
+ MojoResult result2;
+ MojoResult result3;
+ MojoResult result4;
// Cancel two waiters.
{
WaiterList waiter_list;
- test::SimpleWaiterThread thread_1(&result_1);
- waiter_list.AddWaiter(thread_1.waiter(), MOJO_WAIT_FLAG_READABLE, 0);
- thread_1.Start();
- test::SimpleWaiterThread thread_2(&result_2);
- waiter_list.AddWaiter(thread_2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 1);
- thread_2.Start();
+ test::SimpleWaiterThread thread1(&result1);
+ waiter_list.AddWaiter(thread1.waiter(), MOJO_WAIT_FLAG_READABLE, 0);
+ thread1.Start();
+ test::SimpleWaiterThread thread2(&result2);
+ waiter_list.AddWaiter(thread2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 1);
+ thread2.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
waiter_list.CancelAllWaiters();
} // Join threads.
- EXPECT_EQ(MOJO_RESULT_CANCELLED, result_1);
- EXPECT_EQ(MOJO_RESULT_CANCELLED, result_2);
+ EXPECT_EQ(MOJO_RESULT_CANCELLED, result1);
+ EXPECT_EQ(MOJO_RESULT_CANCELLED, result2);
// Awake one waiter, cancel other.
{
WaiterList waiter_list;
- test::SimpleWaiterThread thread_1(&result_1);
- waiter_list.AddWaiter(thread_1.waiter(), MOJO_WAIT_FLAG_READABLE, 2);
- thread_1.Start();
- test::SimpleWaiterThread thread_2(&result_2);
- waiter_list.AddWaiter(thread_2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 3);
- thread_2.Start();
+ test::SimpleWaiterThread thread1(&result1);
+ waiter_list.AddWaiter(thread1.waiter(), MOJO_WAIT_FLAG_READABLE, 2);
+ thread1.Start();
+ test::SimpleWaiterThread thread2(&result2);
+ waiter_list.AddWaiter(thread2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 3);
+ thread2.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
waiter_list.AwakeWaitersForStateChange(MOJO_WAIT_FLAG_READABLE,
MOJO_WAIT_FLAG_READABLE |
MOJO_WAIT_FLAG_WRITABLE);
- waiter_list.RemoveWaiter(thread_1.waiter());
+ waiter_list.RemoveWaiter(thread1.waiter());
waiter_list.CancelAllWaiters();
} // Join threads.
- EXPECT_EQ(2, result_1);
- EXPECT_EQ(MOJO_RESULT_CANCELLED, result_2);
+ EXPECT_EQ(2, result1);
+ EXPECT_EQ(MOJO_RESULT_CANCELLED, result2);
// Cancel one waiter, awake other for unsatisfiability.
{
WaiterList waiter_list;
- test::SimpleWaiterThread thread_1(&result_1);
- waiter_list.AddWaiter(thread_1.waiter(), MOJO_WAIT_FLAG_READABLE, 4);
- thread_1.Start();
- test::SimpleWaiterThread thread_2(&result_2);
- waiter_list.AddWaiter(thread_2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 5);
- thread_2.Start();
+ test::SimpleWaiterThread thread1(&result1);
+ waiter_list.AddWaiter(thread1.waiter(), MOJO_WAIT_FLAG_READABLE, 4);
+ thread1.Start();
+ test::SimpleWaiterThread thread2(&result2);
+ waiter_list.AddWaiter(thread2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 5);
+ thread2.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(2 * kEpsilonMicros));
waiter_list.AwakeWaitersForStateChange(0, MOJO_WAIT_FLAG_READABLE);
- waiter_list.RemoveWaiter(thread_2.waiter());
+ waiter_list.RemoveWaiter(thread2.waiter());
waiter_list.CancelAllWaiters();
} // Join threads.
- EXPECT_EQ(MOJO_RESULT_CANCELLED, result_1);
- EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result_2);
+ EXPECT_EQ(MOJO_RESULT_CANCELLED, result1);
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result2);
// Cancel one waiter, awake other for unsatisfiability.
{
WaiterList waiter_list;
- test::SimpleWaiterThread thread_1(&result_1);
- waiter_list.AddWaiter(thread_1.waiter(), MOJO_WAIT_FLAG_READABLE, 6);
- thread_1.Start();
+ test::SimpleWaiterThread thread1(&result1);
+ waiter_list.AddWaiter(thread1.waiter(), MOJO_WAIT_FLAG_READABLE, 6);
+ thread1.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(1 * kEpsilonMicros));
@@ -220,9 +220,9 @@ TEST(WaiterListTest, MultipleWaiters) {
MOJO_WAIT_FLAG_READABLE |
MOJO_WAIT_FLAG_WRITABLE);
- test::SimpleWaiterThread thread_2(&result_2);
- waiter_list.AddWaiter(thread_2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 7);
- thread_2.Start();
+ test::SimpleWaiterThread thread2(&result2);
+ waiter_list.AddWaiter(thread2.waiter(), MOJO_WAIT_FLAG_WRITABLE, 7);
+ thread2.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(1 * kEpsilonMicros));
@@ -231,34 +231,34 @@ TEST(WaiterListTest, MultipleWaiters) {
waiter_list.AwakeWaitersForStateChange(MOJO_WAIT_FLAG_READABLE,
MOJO_WAIT_FLAG_READABLE |
MOJO_WAIT_FLAG_WRITABLE);
- waiter_list.RemoveWaiter(thread_1.waiter());
+ waiter_list.RemoveWaiter(thread1.waiter());
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(1 * kEpsilonMicros));
- test::SimpleWaiterThread thread_3(&result_3);
- waiter_list.AddWaiter(thread_3.waiter(), MOJO_WAIT_FLAG_WRITABLE, 8);
- thread_3.Start();
+ test::SimpleWaiterThread thread3(&result3);
+ waiter_list.AddWaiter(thread3.waiter(), MOJO_WAIT_FLAG_WRITABLE, 8);
+ thread3.Start();
- test::SimpleWaiterThread thread_4(&result_4);
- waiter_list.AddWaiter(thread_4.waiter(), MOJO_WAIT_FLAG_READABLE, 9);
- thread_4.Start();
+ test::SimpleWaiterThread thread4(&result4);
+ waiter_list.AddWaiter(thread4.waiter(), MOJO_WAIT_FLAG_READABLE, 9);
+ thread4.Start();
base::PlatformThread::Sleep(
base::TimeDelta::FromMicroseconds(1 * kEpsilonMicros));
// Awake #2 and #3 for unsatisfiability.
waiter_list.AwakeWaitersForStateChange(0, MOJO_WAIT_FLAG_READABLE);
- waiter_list.RemoveWaiter(thread_2.waiter());
- waiter_list.RemoveWaiter(thread_3.waiter());
+ waiter_list.RemoveWaiter(thread2.waiter());
+ waiter_list.RemoveWaiter(thread3.waiter());
// Cancel #4.
waiter_list.CancelAllWaiters();
} // Join threads.
- EXPECT_EQ(6, result_1);
- EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result_2);
- EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result_3);
- EXPECT_EQ(MOJO_RESULT_CANCELLED, result_4);
+ EXPECT_EQ(6, result1);
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result2);
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result3);
+ EXPECT_EQ(MOJO_RESULT_CANCELLED, result4);
}
} // namespace