| Index: mojo/edk/system/remote_message_pipe_unittest.cc
|
| diff --git a/mojo/edk/system/remote_message_pipe_unittest.cc b/mojo/edk/system/remote_message_pipe_unittest.cc
|
| index 560ae64fad2baf59c827ba9dbaff3ac84bdd8b57..22495e30b11f164c03d672b8fb8c677dc29c4464 100644
|
| --- a/mojo/edk/system/remote_message_pipe_unittest.cc
|
| +++ b/mojo/edk/system/remote_message_pipe_unittest.cc
|
| @@ -10,7 +10,6 @@
|
| #include <utility>
|
| #include <vector>
|
|
|
| -#include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "mojo/edk/embedder/platform_channel_pair.h"
|
| #include "mojo/edk/embedder/platform_shared_buffer.h"
|
| @@ -54,13 +53,11 @@ class RemoteMessagePipeTest : public testing::Test {
|
| ~RemoteMessagePipeTest() override {}
|
|
|
| void SetUp() override {
|
| - io_thread_.PostTaskAndWait(base::Bind(
|
| - &RemoteMessagePipeTest::SetUpOnIOThread, base::Unretained(this)));
|
| + io_thread_.PostTaskAndWait([this]() { SetUpOnIOThread(); });
|
| }
|
|
|
| void TearDown() override {
|
| - io_thread_.PostTaskAndWait(base::Bind(
|
| - &RemoteMessagePipeTest::TearDownOnIOThread, base::Unretained(this)));
|
| + io_thread_.PostTaskAndWait([this]() { TearDownOnIOThread(); });
|
| }
|
|
|
| protected:
|
| @@ -69,10 +66,9 @@ class RemoteMessagePipeTest : public testing::Test {
|
| // hosted on the channel).
|
| void BootstrapChannelEndpoints(RefPtr<ChannelEndpoint>&& ep0,
|
| RefPtr<ChannelEndpoint>&& ep1) {
|
| - io_thread_.PostTaskAndWait(
|
| - base::Bind(&RemoteMessagePipeTest::BootstrapChannelEndpointsOnIOThread,
|
| - base::Unretained(this), base::Passed(ep0),
|
| - base::Passed(ep1)));
|
| + io_thread_.PostTaskAndWait([this, &ep0, &ep1]() {
|
| + BootstrapChannelEndpointsOnIOThread(std::move(ep0), std::move(ep1));
|
| + });
|
| }
|
|
|
| // This bootstraps |ep| on |channels_[channel_index]|. It assumes/requires
|
| @@ -80,15 +76,15 @@ class RemoteMessagePipeTest : public testing::Test {
|
| // hosted on the channel). This returns *without* waiting.
|
| void BootstrapChannelEndpointNoWait(unsigned channel_index,
|
| RefPtr<ChannelEndpoint>&& ep) {
|
| - io_thread_.PostTask(
|
| - base::Bind(&RemoteMessagePipeTest::BootstrapChannelEndpointOnIOThread,
|
| - base::Unretained(this), channel_index, base::Passed(&ep)));
|
| + // Note: We have to copy |ep| here, since we're not waiting for it.
|
| + // TODO(vtl): With C++14 lambda captures, we'll be able to move it.
|
| + io_thread_.PostTask([this, channel_index, ep]() mutable {
|
| + BootstrapChannelEndpointOnIOThread(channel_index, std::move(ep));
|
| + });
|
| }
|
|
|
| void RestoreInitialState() {
|
| - io_thread_.PostTaskAndWait(
|
| - base::Bind(&RemoteMessagePipeTest::RestoreInitialStateOnIOThread,
|
| - base::Unretained(this)));
|
| + io_thread_.PostTaskAndWait([this]() { RestoreInitialStateOnIOThread(); });
|
| }
|
|
|
| embedder::PlatformSupport* platform_support() { return &platform_support_; }
|
| @@ -129,10 +125,8 @@ class RemoteMessagePipeTest : public testing::Test {
|
| RawChannel::Create(platform_handles_[channel_index].Pass()));
|
| }
|
|
|
| - // TODO(vtl): The arguments should be rvalue references, but that doesn't
|
| - // currently work correctly with base::Bind.
|
| - void BootstrapChannelEndpointsOnIOThread(RefPtr<ChannelEndpoint> ep0,
|
| - RefPtr<ChannelEndpoint> ep1) {
|
| + void BootstrapChannelEndpointsOnIOThread(RefPtr<ChannelEndpoint>&& ep0,
|
| + RefPtr<ChannelEndpoint>&& ep1) {
|
| CHECK(io_thread()->IsCurrentAndRunning());
|
|
|
| if (!channels_[0])
|
| @@ -144,10 +138,8 @@ class RemoteMessagePipeTest : public testing::Test {
|
| channels_[1]->SetBootstrapEndpoint(std::move(ep1));
|
| }
|
|
|
| - // TODO(vtl): |ep| should be an rvalue reference, but that doesn't currently
|
| - // work correctly with base::Bind.
|
| void BootstrapChannelEndpointOnIOThread(unsigned channel_index,
|
| - RefPtr<ChannelEndpoint> ep) {
|
| + RefPtr<ChannelEndpoint>&& ep) {
|
| CHECK(io_thread()->IsCurrentAndRunning());
|
| CHECK(channel_index == 0 || channel_index == 1);
|
|
|
| @@ -1131,7 +1123,7 @@ TEST_F(RemoteMessagePipeTest, RacingClosesStress) {
|
| BootstrapChannelEndpointNoWait(1, std::move(ep1));
|
|
|
| if (i & 1u) {
|
| - io_thread()->PostTask(base::Bind(&test::Sleep, delay));
|
| + io_thread()->PostTask([delay]() { test::Sleep(delay); });
|
| }
|
| if (i & 2u)
|
| test::Sleep(delay);
|
| @@ -1139,7 +1131,7 @@ TEST_F(RemoteMessagePipeTest, RacingClosesStress) {
|
| mp0->Close(0);
|
|
|
| if (i & 4u) {
|
| - io_thread()->PostTask(base::Bind(&test::Sleep, delay));
|
| + io_thread()->PostTask([delay]() { test::Sleep(delay); });
|
| }
|
| if (i & 8u)
|
| test::Sleep(delay);
|
|
|