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

Unified Diff: mojo/edk/system/message_pipe_test_utils.cc

Issue 1496663002: EDK: Make mojo::platform::TaskRunner's PostTask() take an std::function<void()>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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/message_pipe_test_utils.h ('k') | mojo/edk/system/raw_channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe_test_utils.cc
diff --git a/mojo/edk/system/message_pipe_test_utils.cc b/mojo/edk/system/message_pipe_test_utils.cc
index 8d76c97306c887a9373ff31dd8d24329895d1eeb..38597c5de7eb914030dd7d551473b3e0cd3404e3 100644
--- a/mojo/edk/system/message_pipe_test_utils.cc
+++ b/mojo/edk/system/message_pipe_test_utils.cc
@@ -51,6 +51,8 @@ ChannelThread::~ChannelThread() {
void ChannelThread::Start(ScopedPlatformHandle platform_handle,
RefPtr<ChannelEndpoint>&& channel_endpoint) {
test_io_thread_.Start();
+ // TODO(vtl): This is hard to convert to a lambda, since we really need to
+ // move |platform_handle|.
test_io_thread_.PostTaskAndWait(
base::Bind(&ChannelThread::InitChannelOnIOThread, base::Unretained(this),
base::Passed(&platform_handle),
@@ -65,8 +67,10 @@ void ChannelThread::Stop() {
while (!channel_->IsWriteBufferEmpty())
test::Sleep(test::EpsilonTimeout());
- test_io_thread_.PostTaskAndWait(base::Bind(
- &ChannelThread::ShutdownChannelOnIOThread, base::Unretained(this)));
+ test_io_thread_.PostTaskAndWait([this] {
+ channel_->Shutdown();
+ channel_ = nullptr;
+ });
}
test_io_thread_.Stop();
}
@@ -90,12 +94,6 @@ void ChannelThread::InitChannelOnIOThread(
channel_->SetBootstrapEndpoint(std::move(channel_endpoint));
}
-void ChannelThread::ShutdownChannelOnIOThread() {
- CHECK(channel_);
- channel_->Shutdown();
- channel_ = nullptr;
-}
-
#if !defined(OS_IOS)
MultiprocessMessagePipeTestBase::MultiprocessMessagePipeTestBase()
: channel_thread_(&platform_support_) {
@@ -107,7 +105,7 @@ MultiprocessMessagePipeTestBase::~MultiprocessMessagePipeTestBase() {
void MultiprocessMessagePipeTestBase::Init(RefPtr<ChannelEndpoint>&& ep) {
channel_thread_.Start(helper_.server_platform_handle.Pass(), std::move(ep));
}
-#endif
+#endif // !defined(OS_IOS)
} // namespace test
} // namespace system
« no previous file with comments | « mojo/edk/system/message_pipe_test_utils.h ('k') | mojo/edk/system/raw_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698