Commit 92b7a42d authored by tzik's avatar tzik Committed by Commit bot

Rewrite base::Bind into base::BindOnce on trivial cases in base

This CL is generated by a clang refactoring tool updated in
http://crrev.com/2789153002/, that rewrites base::Bind into base::BindOnce
where the resulting base::Callback is converted into base::OnceCallback
immediately after base::Bind call.

Review-Url: https://codereview.chromium.org/2791243002
Cr-Commit-Position: refs/heads/master@{#463631}
parent df600cdc
......@@ -1463,8 +1463,8 @@ void GlobalActivityTracker::RecordProcessExit(ProcessId process_id,
if (task_runner && !task_runner->RunsTasksOnCurrentThread()) {
task_runner->PostTask(
FROM_HERE,
Bind(&GlobalActivityTracker::CleanupAfterProcess, Unretained(this), pid,
now_stamp, exit_code, Passed(&command_line)));
BindOnce(&GlobalActivityTracker::CleanupAfterProcess, Unretained(this),
pid, now_stamp, exit_code, Passed(&command_line)));
return;
}
......
......@@ -216,7 +216,7 @@ TEST_F(ActivityTrackerTest, ScopedTaskTest) {
ASSERT_EQ(0U, snapshot.activity_stack.size());
{
PendingTask task1(FROM_HERE, base::Bind(&DoNothing));
PendingTask task1(FROM_HERE, base::BindOnce(&DoNothing));
ScopedTaskRunActivity activity1(task1);
ActivityUserData& user_data1 = activity1.user_data();
(void)user_data1; // Tell compiler it's been used.
......@@ -227,7 +227,7 @@ TEST_F(ActivityTrackerTest, ScopedTaskTest) {
EXPECT_EQ(Activity::ACT_TASK, snapshot.activity_stack[0].activity_type);
{
PendingTask task2(FROM_HERE, base::Bind(&DoNothing));
PendingTask task2(FROM_HERE, base::BindOnce(&DoNothing));
ScopedTaskRunActivity activity2(task2);
ActivityUserData& user_data2 = activity2.user_data();
(void)user_data2; // Tell compiler it's been used.
......@@ -413,7 +413,7 @@ TEST_F(ActivityTrackerTest, ProcessDeathTest) {
global->RecordProcessLaunch(other_process_id, FILE_PATH_LITERAL("foo --bar"));
// Do some activities.
PendingTask task(FROM_HERE, base::Bind(&DoNothing));
PendingTask task(FROM_HERE, base::BindOnce(&DoNothing));
ScopedTaskRunActivity activity(task);
ActivityUserData& user_data = activity.user_data();
ASSERT_NE(0U, user_data.id());
......
......@@ -19,7 +19,7 @@ void TestTask(int* result) {
TEST(TaskAnnotatorTest, QueueAndRunTask) {
int result = 0;
PendingTask pending_task(FROM_HERE, Bind(&TestTask, &result));
PendingTask pending_task(FROM_HERE, BindOnce(&TestTask, &result));
TaskAnnotator annotator;
annotator.DidQueueTask("TaskAnnotatorTest::Queue", pending_task);
......
......@@ -44,10 +44,9 @@ class DeferredSequencedTaskRunnerTest : public testing::Test,
}
void PostExecuteTask(int task_id) {
runner_->PostTask(FROM_HERE,
base::Bind(&DeferredSequencedTaskRunnerTest::ExecuteTask,
base::Unretained(this),
task_id));
runner_->PostTask(
FROM_HERE, base::BindOnce(&DeferredSequencedTaskRunnerTest::ExecuteTask,
base::Unretained(this), task_id));
}
void StartRunner() {
......@@ -126,16 +125,17 @@ TEST_F(DeferredSequencedTaskRunnerTest, DeferredStartWithMultipleThreads) {
for (int i = 0; i < 5; ++i) {
thread1.task_runner()->PostTask(
FROM_HERE,
base::Bind(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
base::Unretained(this), 2 * i));
base::BindOnce(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
base::Unretained(this), 2 * i));
thread2.task_runner()->PostTask(
FROM_HERE,
base::Bind(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
base::Unretained(this), 2 * i + 1));
base::BindOnce(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
base::Unretained(this), 2 * i + 1));
if (i == 2) {
thread1.task_runner()->PostTask(
FROM_HERE, base::Bind(&DeferredSequencedTaskRunnerTest::StartRunner,
base::Unretained(this)));
FROM_HERE,
base::BindOnce(&DeferredSequencedTaskRunnerTest::StartRunner,
base::Unretained(this)));
}
}
}
......@@ -157,9 +157,10 @@ TEST_F(DeferredSequencedTaskRunnerTest, ObjectDestructionOrder) {
scoped_refptr<ExecuteTaskOnDestructor> short_lived_object =
new ExecuteTaskOnDestructor(this, 2 * i);
runner_->PostTask(
FROM_HERE, base::Bind(&DeferredSequencedTaskRunnerTest::DoNothing,
base::Unretained(this),
base::RetainedRef(short_lived_object)));
FROM_HERE,
base::BindOnce(&DeferredSequencedTaskRunnerTest::DoNothing,
base::Unretained(this),
base::RetainedRef(short_lived_object)));
}
// |short_lived_object| with id |2 * i| should be destroyed before the
// task |2 * i + 1| is executed.
......
......@@ -124,8 +124,8 @@ void FileDescriptorWatcher::Controller::Watcher::OnFileCanReadWithoutBlocking(
DCHECK(thread_checker_.CalledOnValidThread());
// Run the callback on the sequence on which the watch was initiated.
callback_task_runner_->PostTask(FROM_HERE,
Bind(&Controller::RunCallback, controller_));
callback_task_runner_->PostTask(
FROM_HERE, BindOnce(&Controller::RunCallback, controller_));
}
void FileDescriptorWatcher::Controller::Watcher::OnFileCanWriteWithoutBlocking(
......@@ -135,8 +135,8 @@ void FileDescriptorWatcher::Controller::Watcher::OnFileCanWriteWithoutBlocking(
DCHECK(thread_checker_.CalledOnValidThread());
// Run the callback on the sequence on which the watch was initiated.
callback_task_runner_->PostTask(FROM_HERE,
Bind(&Controller::RunCallback, controller_));
callback_task_runner_->PostTask(
FROM_HERE, BindOnce(&Controller::RunCallback, controller_));
}
void FileDescriptorWatcher::Controller::Watcher::
......@@ -170,7 +170,7 @@ void FileDescriptorWatcher::Controller::StartWatching() {
// Controller's destructor. Since this delete task hasn't been posted yet, it
// can't run before the task posted below.
message_loop_for_io_task_runner_->PostTask(
FROM_HERE, Bind(&Watcher::StartWatching, Unretained(watcher_.get())));
FROM_HERE, BindOnce(&Watcher::StartWatching, Unretained(watcher_.get())));
}
void FileDescriptorWatcher::Controller::RunCallback() {
......
......@@ -255,8 +255,7 @@ InotifyReader::InotifyReader()
if (inotify_fd_ >= 0 && thread_.Start()) {
thread_.task_runner()->PostTask(
FROM_HERE,
Bind(&InotifyReaderCallback, this, inotify_fd_));
FROM_HERE, BindOnce(&InotifyReaderCallback, this, inotify_fd_));
valid_ = true;
}
}
......@@ -331,9 +330,10 @@ void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch,
// access |watches_| safely. Use a WeakPtr to prevent the callback from
// running after |this| is destroyed (i.e. after the watch is cancelled).
task_runner()->PostTask(
FROM_HERE, Bind(&FilePathWatcherImpl::OnFilePathChangedOnOriginSequence,
weak_factory_.GetWeakPtr(), fired_watch, child, created,
deleted, is_dir));
FROM_HERE,
BindOnce(&FilePathWatcherImpl::OnFilePathChangedOnOriginSequence,
weak_factory_.GetWeakPtr(), fired_watch, child, created, deleted,
is_dir));
}
void FilePathWatcherImpl::OnFilePathChangedOnOriginSequence(
......
......@@ -56,8 +56,8 @@ class NotificationCollector
// Called from the file thread by the delegates.
void OnChange(TestDelegate* delegate) {
task_runner_->PostTask(
FROM_HERE, base::Bind(&NotificationCollector::RecordChange, this,
base::Unretained(delegate)));
FROM_HERE, base::BindOnce(&NotificationCollector::RecordChange, this,
base::Unretained(delegate)));
}
void Register(TestDelegate* delegate) {
......
......@@ -37,7 +37,8 @@ class FileHelper {
if (proxy_)
proxy_->SetFile(std::move(file_));
else if (file_.IsValid())
task_runner_->PostTask(FROM_HERE, Bind(&FileDeleter, Passed(&file_)));
task_runner_->PostTask(FROM_HERE,
BindOnce(&FileDeleter, Passed(&file_)));
}
protected:
......@@ -235,7 +236,7 @@ FileProxy::FileProxy(TaskRunner* task_runner) : task_runner_(task_runner) {
FileProxy::~FileProxy() {
if (file_.IsValid())
task_runner_->PostTask(FROM_HERE, Bind(&FileDeleter, Passed(&file_)));
task_runner_->PostTask(FROM_HERE, BindOnce(&FileDeleter, Passed(&file_)));
}
bool FileProxy::CreateOrOpen(const FilePath& file_path,
......@@ -245,9 +246,9 @@ bool FileProxy::CreateOrOpen(const FilePath& file_path,
CreateOrOpenHelper* helper = new CreateOrOpenHelper(this, File());
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&CreateOrOpenHelper::RunWork, Unretained(helper), file_path,
file_flags),
Bind(&CreateOrOpenHelper::Reply, Owned(helper), callback));
BindOnce(&CreateOrOpenHelper::RunWork, Unretained(helper), file_path,
file_flags),
BindOnce(&CreateOrOpenHelper::Reply, Owned(helper), callback));
}
bool FileProxy::CreateTemporary(uint32_t additional_file_flags,
......@@ -256,9 +257,9 @@ bool FileProxy::CreateTemporary(uint32_t additional_file_flags,
CreateTemporaryHelper* helper = new CreateTemporaryHelper(this, File());
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&CreateTemporaryHelper::RunWork, Unretained(helper),
additional_file_flags),
Bind(&CreateTemporaryHelper::Reply, Owned(helper), callback));
BindOnce(&CreateTemporaryHelper::RunWork, Unretained(helper),
additional_file_flags),
BindOnce(&CreateTemporaryHelper::Reply, Owned(helper), callback));
}
bool FileProxy::IsValid() const {
......@@ -286,18 +287,16 @@ bool FileProxy::Close(const StatusCallback& callback) {
DCHECK(file_.IsValid());
GenericFileHelper* helper = new GenericFileHelper(this, std::move(file_));
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&GenericFileHelper::Close, Unretained(helper)),
Bind(&GenericFileHelper::Reply, Owned(helper), callback));
FROM_HERE, BindOnce(&GenericFileHelper::Close, Unretained(helper)),
BindOnce(&GenericFileHelper::Reply, Owned(helper), callback));
}
bool FileProxy::GetInfo(const GetFileInfoCallback& callback) {
DCHECK(file_.IsValid());
GetInfoHelper* helper = new GetInfoHelper(this, std::move(file_));
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&GetInfoHelper::RunWork, Unretained(helper)),
Bind(&GetInfoHelper::Reply, Owned(helper), callback));
FROM_HERE, BindOnce(&GetInfoHelper::RunWork, Unretained(helper)),
BindOnce(&GetInfoHelper::Reply, Owned(helper), callback));
}
bool FileProxy::Read(int64_t offset,
......@@ -309,9 +308,8 @@ bool FileProxy::Read(int64_t offset,
ReadHelper* helper = new ReadHelper(this, std::move(file_), bytes_to_read);
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&ReadHelper::RunWork, Unretained(helper), offset),
Bind(&ReadHelper::Reply, Owned(helper), callback));
FROM_HERE, BindOnce(&ReadHelper::RunWork, Unretained(helper), offset),
BindOnce(&ReadHelper::Reply, Owned(helper), callback));
}
bool FileProxy::Write(int64_t offset,
......@@ -325,9 +323,8 @@ bool FileProxy::Write(int64_t offset,
WriteHelper* helper =
new WriteHelper(this, std::move(file_), buffer, bytes_to_write);
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&WriteHelper::RunWork, Unretained(helper), offset),
Bind(&WriteHelper::Reply, Owned(helper), callback));
FROM_HERE, BindOnce(&WriteHelper::RunWork, Unretained(helper), offset),
BindOnce(&WriteHelper::Reply, Owned(helper), callback));
}
bool FileProxy::SetTimes(Time last_access_time,
......@@ -337,9 +334,9 @@ bool FileProxy::SetTimes(Time last_access_time,
GenericFileHelper* helper = new GenericFileHelper(this, std::move(file_));
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&GenericFileHelper::SetTimes, Unretained(helper), last_access_time,
last_modified_time),
Bind(&GenericFileHelper::Reply, Owned(helper), callback));
BindOnce(&GenericFileHelper::SetTimes, Unretained(helper),
last_access_time, last_modified_time),
BindOnce(&GenericFileHelper::Reply, Owned(helper), callback));
}
bool FileProxy::SetLength(int64_t length, const StatusCallback& callback) {
......@@ -347,17 +344,16 @@ bool FileProxy::SetLength(int64_t length, const StatusCallback& callback) {
GenericFileHelper* helper = new GenericFileHelper(this, std::move(file_));
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&GenericFileHelper::SetLength, Unretained(helper), length),
Bind(&GenericFileHelper::Reply, Owned(helper), callback));
BindOnce(&GenericFileHelper::SetLength, Unretained(helper), length),
BindOnce(&GenericFileHelper::Reply, Owned(helper), callback));
}
bool FileProxy::Flush(const StatusCallback& callback) {
DCHECK(file_.IsValid());
GenericFileHelper* helper = new GenericFileHelper(this, std::move(file_));
return task_runner_->PostTaskAndReply(
FROM_HERE,
Bind(&GenericFileHelper::Flush, Unretained(helper)),
Bind(&GenericFileHelper::Reply, Owned(helper), callback));
FROM_HERE, BindOnce(&GenericFileHelper::Flush, Unretained(helper)),
BindOnce(&GenericFileHelper::Reply, Owned(helper), callback));
}
} // namespace base
......@@ -59,9 +59,9 @@ bool FileUtilProxy::GetFileInfo(
GetFileInfoHelper* helper = new GetFileInfoHelper;
return task_runner->PostTaskAndReply(
FROM_HERE,
Bind(&GetFileInfoHelper::RunWorkForFilePath,
Unretained(helper), file_path),
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback));
BindOnce(&GetFileInfoHelper::RunWorkForFilePath, Unretained(helper),
file_path),
BindOnce(&GetFileInfoHelper::Reply, Owned(helper), callback));
}
// static
......
......@@ -201,8 +201,8 @@ TEST_F(ImportantFileWriterTest, CallbackRunsOnWriterThread) {
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
file_writer_thread.task_runner()->PostTask(
FROM_HERE,
base::Bind(&base::WaitableEvent::Wait, base::Unretained(&wait_helper)));
FROM_HERE, base::BindOnce(&base::WaitableEvent::Wait,
base::Unretained(&wait_helper)));
write_callback_observer_.ObserveNextWriteCallbacks(&writer);
writer.WriteNow(MakeUnique<std::string>("foo"));
......
......@@ -32,7 +32,8 @@ class OffThreadObjectCreator {
Thread creator_thread("creator_thread");
creator_thread.Start();
creator_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(OffThreadObjectCreator::CreateObject, &result));
FROM_HERE,
base::BindOnce(OffThreadObjectCreator::CreateObject, &result));
}
DCHECK(result); // We synchronized on thread destruction above.
return result;
......@@ -73,8 +74,8 @@ class BackgroundThread : public Thread {
WaitableEvent completion(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE, base::Bind(&BackgroundThread::DoCreateArrowFromTarget, arrow,
target, &completion));
FROM_HERE, base::BindOnce(&BackgroundThread::DoCreateArrowFromTarget,
arrow, target, &completion));
completion.Wait();
}
......@@ -82,8 +83,8 @@ class BackgroundThread : public Thread {
WaitableEvent completion(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE, base::Bind(&BackgroundThread::DoCreateArrowFromArrow, arrow,
other, &completion));
FROM_HERE, base::BindOnce(&BackgroundThread::DoCreateArrowFromArrow,
arrow, other, &completion));
completion.Wait();
}
......@@ -92,7 +93,7 @@ class BackgroundThread : public Thread {
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE,
base::Bind(&BackgroundThread::DoDeleteTarget, object, &completion));
base::BindOnce(&BackgroundThread::DoDeleteTarget, object, &completion));
completion.Wait();
}
......@@ -100,8 +101,8 @@ class BackgroundThread : public Thread {
WaitableEvent completion(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE, base::Bind(&BackgroundThread::DoCopyAndAssignArrow, object,
&completion));
FROM_HERE, base::BindOnce(&BackgroundThread::DoCopyAndAssignArrow,
object, &completion));
completion.Wait();
}
......@@ -109,8 +110,8 @@ class BackgroundThread : public Thread {
WaitableEvent completion(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE, base::Bind(&BackgroundThread::DoCopyAndAssignArrowBase,
object, &completion));
FROM_HERE, base::BindOnce(&BackgroundThread::DoCopyAndAssignArrowBase,
object, &completion));
completion.Wait();
}
......@@ -119,7 +120,7 @@ class BackgroundThread : public Thread {
WaitableEvent::InitialState::NOT_SIGNALED);
task_runner()->PostTask(
FROM_HERE,
base::Bind(&BackgroundThread::DoDeleteArrow, object, &completion));
base::BindOnce(&BackgroundThread::DoDeleteArrow, object, &completion));
completion.Wait();
}
......@@ -127,8 +128,9 @@ class BackgroundThread : public Thread {
WaitableEvent completion(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
Target* result = nullptr;
task_runner()->PostTask(FROM_HERE, base::Bind(&BackgroundThread::DoDeRef,
arrow, &result, &completion));
task_runner()->PostTask(
FROM_HERE, base::BindOnce(&BackgroundThread::DoDeRef, arrow, &result,
&completion));
completion.Wait();
return result;
}
......
......@@ -38,8 +38,8 @@ class MessageLoopTaskRunnerTest : public testing::Test {
// Allow us to pause the |task_thread_|'s MessageLoop.
task_thread_.task_runner()->PostTask(
FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper,
Unretained(this)));
FROM_HERE, BindOnce(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper,
Unretained(this)));
}
void TearDown() override {
......@@ -114,8 +114,8 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_Basic) {
new LoopRecorder(&reply_run_on, &reply_deleted_on, &reply_delete_order);
ASSERT_TRUE(task_thread_.task_runner()->PostTaskAndReply(
FROM_HERE, Bind(&RecordLoop, task_recorder),
Bind(&RecordLoopAndQuit, reply_recorder)));
FROM_HERE, BindOnce(&RecordLoop, task_recorder),
BindOnce(&RecordLoopAndQuit, reply_recorder)));
// Die if base::Bind doesn't retain a reference to the recorders.
task_recorder = NULL;
......@@ -152,9 +152,9 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReplyOnDeletedThreadDoesNotLeak) {
UnblockTaskThread();
task_thread_.Stop();
ASSERT_FALSE(
task_runner->PostTaskAndReply(FROM_HERE, Bind(&RecordLoop, task_recorder),
Bind(&RecordLoopAndQuit, reply_recorder)));
ASSERT_FALSE(task_runner->PostTaskAndReply(
FROM_HERE, BindOnce(&RecordLoop, task_recorder),
BindOnce(&RecordLoopAndQuit, reply_recorder)));
// The relay should have properly deleted its resources leaving us as the only
// reference.
......@@ -182,8 +182,8 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_SameLoop) {
// Enqueue the relay.
ASSERT_TRUE(current_loop_->task_runner()->PostTaskAndReply(
FROM_HERE, Bind(&RecordLoop, task_recorder),
Bind(&RecordLoopAndQuit, reply_recorder)));
FROM_HERE, BindOnce(&RecordLoop, task_recorder),
BindOnce(&RecordLoopAndQuit, reply_recorder)));
// Die if base::Bind doesn't retain a reference to the recorders.
task_recorder = NULL;
......@@ -218,8 +218,8 @@ TEST_F(MessageLoopTaskRunnerTest,
// Enqueue the relay.
task_thread_.task_runner()->PostTaskAndReply(
FROM_HERE, Bind(&RecordLoop, task_recorder),
Bind(&RecordLoopAndQuit, reply_recorder));
FROM_HERE, BindOnce(&RecordLoop, task_recorder),
BindOnce(&RecordLoopAndQuit, reply_recorder));
// Die if base::Bind doesn't retain a reference to the recorders.
task_recorder = NULL;
......@@ -331,8 +331,8 @@ TEST_F(MessageLoopTaskRunnerThreadingTest, Delete) {
TEST_F(MessageLoopTaskRunnerThreadingTest, PostTask) {
EXPECT_TRUE(file_thread_->task_runner()->PostTask(
FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::BasicFunction,
Unretained(this))));
FROM_HERE, BindOnce(&MessageLoopTaskRunnerThreadingTest::BasicFunction,
Unretained(this))));
RunLoop().Run();
}
......@@ -345,7 +345,7 @@ TEST_F(MessageLoopTaskRunnerThreadingTest, PostTaskAfterThreadExits) {
test_thread->Stop();
bool ret = task_runner->PostTask(
FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
FROM_HERE, BindOnce(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
EXPECT_FALSE(ret);
}
......@@ -358,7 +358,7 @@ TEST_F(MessageLoopTaskRunnerThreadingTest, PostTaskAfterThreadIsDeleted) {
task_runner = test_thread->task_runner();
}
bool ret = task_runner->PostTask(
FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
FROM_HERE, BindOnce(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
EXPECT_FALSE(ret);
}
......
This diff is collapsed.
......@@ -470,7 +470,7 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
void PostNTasksThenQuit(int posts_remaining) {
if (posts_remaining > 1) {
ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, Bind(&PostNTasksThenQuit, posts_remaining - 1));
FROM_HERE, BindOnce(&PostNTasksThenQuit, posts_remaining - 1));
} else {
MessageLoop::current()->QuitWhenIdle();
}
......@@ -682,7 +682,8 @@ TEST(MessageLoopTest, TaskObserver) {
MessageLoop loop;
loop.AddTaskObserver(&observer);
loop.task_runner()->PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, kNumPosts));
loop.task_runner()->PostTask(FROM_HERE,
BindOnce(&PostNTasksThenQuit, kNumPosts));
RunLoop().Run();
loop.RemoveTaskObserver(&observer);
......@@ -859,9 +860,10 @@ TEST(MessageLoopTest, DestructionObserverTest) {
MLDestructionObserver observer(&task_destroyed, &destruction_observer_called);
loop->AddDestructionObserver(&observer);
loop->task_runner()->PostDelayedTask(
FROM_HERE, Bind(&DestructionObserverProbe::Run,
new DestructionObserverProbe(
&task_destroyed, &destruction_observer_called)),
FROM_HERE,
BindOnce(&DestructionObserverProbe::Run,
new DestructionObserverProbe(&task_destroyed,
&destruction_observer_called)),
kDelay);
delete loop;
EXPECT_TRUE(observer.task_destroyed_before_message_loop());
......@@ -878,13 +880,13 @@ TEST(MessageLoopTest, ThreadMainTaskRunner) {
scoped_refptr<Foo> foo(new Foo());
std::string a("a");
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind(
&Foo::Test1ConstRef, foo, a));
ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, BindOnce(&Foo::Test1ConstRef, foo, a));
// Post quit task;
ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current())));
BindOnce(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current())));
// Now kick things off
RunLoop().Run();
......@@ -1007,8 +1009,7 @@ TEST(MessageLoopTest, OriginalRunnerWorks) {
loop.SetTaskRunner(new_runner);
scoped_refptr<Foo> foo(new Foo());
original_runner->PostTask(FROM_HERE,
Bind(&Foo::Test1ConstRef, foo, "a"));
original_runner->PostTask(FROM_HERE, BindOnce(&Foo::Test1ConstRef, foo, "a"));
RunLoop().RunUntilIdle();
EXPECT_EQ(1, foo->test_count());
}
......
......@@ -237,13 +237,13 @@ TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) {
// The event queue is empty at first.
for (int i = 0; i < 10; ++i) {
loop()->task_runner()->PostTask(FROM_HERE,
Bind(&IncrementInt, &task_count));
BindOnce(&IncrementInt, &task_count));
}
// After all the previous tasks have executed, enqueue an event that will
// quit.
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&EventInjector::AddEvent, Unretained(injector()), 0,
MessageLoop::QuitWhenIdleClosure()));
FROM_HERE, BindOnce(&EventInjector::AddEvent, Unretained(injector()), 0,
MessageLoop::QuitWhenIdleClosure()));
RunLoop().Run();
ASSERT_EQ(10, task_count);
EXPECT_EQ(1, injector()->processed_events());
......@@ -253,7 +253,7 @@ TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) {
task_count = 0;
for (int i = 0; i < 10; ++i) {
loop()->task_runner()->PostDelayedTask(FROM_HERE,
Bind(&IncrementInt, &task_count),
BindOnce(&IncrementInt, &task_count),
TimeDelta::FromMilliseconds(10 * i));
}
// After all the previous tasks have executed, enqueue an event that will
......@@ -261,8 +261,9 @@ TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) {
// This relies on the fact that delayed tasks are executed in delay order.
// That is verified in message_loop_unittest.cc.
loop()->task_runner()->PostDelayedTask(
FROM_HERE, Bind(&EventInjector::AddEvent, Unretained(injector()), 10,
MessageLoop::QuitWhenIdleClosure()),
FROM_HERE,
BindOnce(&EventInjector::AddEvent, Unretained(injector()), 10,
MessageLoop::QuitWhenIdleClosure()),
TimeDelta::FromMilliseconds(150));
RunLoop().Run();
ASSERT_EQ(10, task_count);
......@@ -312,7 +313,7 @@ class ConcurrentHelper : public RefCounted<ConcurrentHelper> {
MessageLoop::current()->QuitWhenIdle();
} else {
ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, Bind(&ConcurrentHelper::FromTask, this));
FROM_HERE, BindOnce(&ConcurrentHelper::FromTask, this));
}
}
......@@ -363,9 +364,9 @@ TEST_F(MessagePumpGLibTest, TestConcurrentEventPostedTask) {
// Similarly post 2 tasks.
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&ConcurrentHelper::FromTask, helper));
FROM_HERE, BindOnce(&ConcurrentHelper::FromTask, helper));
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&ConcurrentHelper::FromTask, helper));
FROM_HERE, BindOnce(&ConcurrentHelper::FromTask, helper));
RunLoop().Run();
EXPECT_EQ(0, helper->event_count());
......@@ -382,8 +383,8 @@ void AddEventsAndDrainGLib(EventInjector* injector) {
injector->AddEvent(0, MessageLoop::QuitWhenIdleClosure());
// Post a couple of dummy tasks
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind(&DoNothing));
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind(&DoNothing));
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, BindOnce(&DoNothing));
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, BindOnce(&DoNothing));
// Drain the events
while (g_main_context_pending(NULL)) {
......@@ -396,7 +397,7 @@ void AddEventsAndDrainGLib(EventInjector* injector) {
TEST_F(MessagePumpGLibTest, TestDrainingGLib) {
// Tests that draining events using GLib works.
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&AddEventsAndDrainGLib, Unretained(injector())));
FROM_HERE, BindOnce(&AddEventsAndDrainGLib, Unretained(injector())));
RunLoop().Run();
EXPECT_EQ(3, injector()->processed_events());
......@@ -448,18 +449,18 @@ void TestGLibLoopInternal(EventInjector* injector) {
injector->AddDummyEvent(0);
// Post a couple of dummy tasks
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
Bind(&IncrementInt, &task_count));
BindOnce(&IncrementInt, &task_count));
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
Bind(&IncrementInt, &task_count));
BindOnce(&IncrementInt, &task_count));
// Delayed events
injector->AddDummyEvent(10);
injector->AddDummyEvent(10);
// Delayed work
ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, Bind(&IncrementInt, &task_count),
FROM_HERE, BindOnce(&IncrementInt, &task_count),
TimeDelta::FromMilliseconds(30));
ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, Bind(&GLibLoopRunner::Quit, runner),
FROM_HERE, BindOnce(&GLibLoopRunner::Quit, runner),
TimeDelta::FromMilliseconds(40));
// Run a nested, straight GLib message loop.
......@@ -481,18 +482,18 @@ void TestGtkLoopInternal(EventInjector* injector) {
injector->AddDummyEvent(0);
// Post a couple of dummy tasks
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
Bind(&IncrementInt, &task_count));
BindOnce(&IncrementInt, &task_count));
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
Bind(&IncrementInt, &task_count));
BindOnce(&IncrementInt, &task_count));
// Delayed events
injector->AddDummyEvent(10);
injector->AddDummyEvent(10);
// Delayed work
ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, Bind(&IncrementInt, &task_count),
FROM_HERE, BindOnce(&IncrementInt, &task_count),
TimeDelta::FromMilliseconds(30));
ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, Bind(&GLibLoopRunner::Quit, runner),
FROM_HERE, BindOnce(&GLibLoopRunner::Quit, runner),
TimeDelta::FromMilliseconds(40));
// Run a nested, straight Gtk message loop.
......@@ -511,7 +512,7 @@ TEST_F(MessagePumpGLibTest, TestGLibLoop) {
// Note that in this case we don't make strong guarantees about niceness
// between events and posted tasks.
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&TestGLibLoopInternal, Unretained(injector())));
FROM_HERE, BindOnce(&TestGLibLoopInternal, Unretained(injector())));
RunLoop().Run();
}
......@@ -521,7 +522,7 @@ TEST_F(MessagePumpGLibTest, TestGtkLoop) {
// Note that in this case we don't make strong guarantees about niceness
// between events and posted tasks.
loop()->task_runner()->PostTask(
FROM_HERE, Bind(&TestGtkLoopInternal, Unretained(injector())));
FROM_HERE, BindOnce(&TestGtkLoopInternal, Unretained(injector())));
RunLoop().Run();
}
......