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

Unified Diff: ipc/mojo/async_handle_waiter_unittest.cc

Issue 929433005: WIP: A couple of more ChannelMojo speedup ideas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build and test fix Created 5 years, 10 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 | « ipc/mojo/async_handle_waiter.cc ('k') | ipc/mojo/ipc_message_pipe_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/async_handle_waiter_unittest.cc
diff --git a/ipc/mojo/async_handle_waiter_unittest.cc b/ipc/mojo/async_handle_waiter_unittest.cc
index fbaf3ca421e64b43971eaa9aade6f328b5131195..faa935f04f968b988c01454c592d68507454a86d 100644
--- a/ipc/mojo/async_handle_waiter_unittest.cc
+++ b/ipc/mojo/async_handle_waiter_unittest.cc
@@ -25,7 +25,8 @@ void ReadOneByteOfX(MojoHandle pipe) {
CHECK_EQ(buffer, 'X');
}
-class AsyncHandleWaiterTest : public testing::Test {
+class AsyncHandleWaiterTest : public testing::Test,
+ public AsyncHandleWaiter::Delegate {
public:
AsyncHandleWaiterTest() : worker_("test_worker") {
worker_.StartWithOptions(
@@ -36,8 +37,7 @@ class AsyncHandleWaiterTest : public testing::Test {
message_loop_.reset(new base::MessageLoopForIO());
ResetSignaledStates();
mojo::CreateMessagePipe(nullptr, &pipe_to_write_, &pipe_to_read_);
- target_.reset(new AsyncHandleWaiter(base::Bind(
- &AsyncHandleWaiterTest::HandleIsReady, base::Unretained(this))));
+ target_.reset(new AsyncHandleWaiter(this));
}
protected:
@@ -78,7 +78,11 @@ class AsyncHandleWaiterTest : public testing::Test {
EXPECT_EQ(MOJO_RESULT_UNKNOWN, signaled_result_);
}
- void HandleIsReady(MojoResult result) {
+ void MessageWasArrived(const void* bytes, uint32_t num_bytes) override {
+ EXPECT_TRUE(false);
+ }
+
+ void PipeIsReady(MojoResult result) override {
CHECK_EQ(base::MessageLoop::current(), message_loop_.get());
CHECK_EQ(signaled_result_, MOJO_RESULT_UNKNOWN);
signaled_result_ = result;
@@ -139,14 +143,18 @@ TEST_F(AsyncHandleWaiterTest, DeleteWaiterBeforeSignal) {
WaitAndAssertNotSignaled();
}
-class HandlerThatReenters {
+class HandlerThatReenters : public AsyncHandleWaiter::Delegate {
public:
HandlerThatReenters(base::RunLoop* loop, MojoHandle handle)
: target_(nullptr), handle_(handle), loop_(loop), step_(0) {}
void set_target(AsyncHandleWaiter* target) { target_ = target; }
- void HandleIsReady(MojoResult result) {
+ void MessageWasArrived(const void* bytes, uint32_t num_bytes) override {
+ CHECK(false);
+ }
+
+ void PipeIsReady(MojoResult result) override {
switch (step_) {
case 0:
RestartAndClose(result);
@@ -190,8 +198,7 @@ class HandlerThatReenters {
TEST_F(AsyncHandleWaiterTest, RestartWaitingWhileSignaled) {
HandlerThatReenters handler(run_loop_.get(), pipe_to_read_.get().value());
- target_.reset(new AsyncHandleWaiter(base::Bind(
- &HandlerThatReenters::HandleIsReady, base::Unretained(&handler))));
+ target_.reset(new AsyncHandleWaiter(&handler));
handler.set_target(target_.get());
EXPECT_EQ(MOJO_RESULT_OK, Start());
« no previous file with comments | « ipc/mojo/async_handle_waiter.cc ('k') | ipc/mojo/ipc_message_pipe_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698