| Index: base/message_loop/message_loop_unittest.cc
|
| diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc
|
| index fe3c015f2588752b0322a1dfa1ace7096e5225ab..0dfe21a481efdad1706ce08f80139a3297a9150f 100644
|
| --- a/base/message_loop/message_loop_unittest.cc
|
| +++ b/base/message_loop/message_loop_unittest.cc
|
| @@ -111,10 +111,11 @@ void RunTest_AbortDontRunMoreTasks(bool delayed, bool init_java_first) {
|
|
|
| if (delayed) {
|
| java_thread->message_loop()->task_runner()->PostDelayedTask(
|
| - FROM_HERE, Bind(&AbortMessagePump), TimeDelta::FromMilliseconds(10));
|
| + FROM_HERE, BindOnce(&AbortMessagePump),
|
| + TimeDelta::FromMilliseconds(10));
|
| } else {
|
| java_thread->message_loop()->task_runner()->PostTask(
|
| - FROM_HERE, Bind(&AbortMessagePump));
|
| + FROM_HERE, BindOnce(&AbortMessagePump));
|
| }
|
|
|
| // Wait to ensure we catch the correct exception (and don't crash)
|
| @@ -182,16 +183,17 @@ void RunTest_PostDelayedTask_SharedTimer_SubPump() {
|
| int num_tasks = 1;
|
| Time run_time;
|
|
|
| - message_loop.task_runner()->PostTask(FROM_HERE, Bind(&SubPumpFunc));
|
| + message_loop.task_runner()->PostTask(FROM_HERE, BindOnce(&SubPumpFunc));
|
|
|
| // This very delayed task should never run.
|
| message_loop.task_runner()->PostDelayedTask(
|
| - FROM_HERE, Bind(&RecordRunTimeFunc, &run_time, &num_tasks),
|
| + FROM_HERE, BindOnce(&RecordRunTimeFunc, &run_time, &num_tasks),
|
| TimeDelta::FromSeconds(1000));
|
|
|
| // This slightly delayed task should run from within SubPumpFunc.
|
| - message_loop.task_runner()->PostDelayedTask(
|
| - FROM_HERE, Bind(&PostQuitMessage, 0), TimeDelta::FromMilliseconds(10));
|
| + message_loop.task_runner()->PostDelayedTask(FROM_HERE,
|
| + BindOnce(&PostQuitMessage, 0),
|
| + TimeDelta::FromMilliseconds(10));
|
|
|
| Time start_time = Time::Now();
|
|
|
| @@ -324,7 +326,7 @@ void RecursiveFunc(TaskList* order, int cookie, int depth,
|
| MessageLoop::current()->SetNestableTasksAllowed(true);
|
| ThreadTaskRunnerHandle::Get()->PostTask(
|
| FROM_HERE,
|
| - Bind(&RecursiveFunc, order, cookie, depth - 1, is_reentrant));
|
| + BindOnce(&RecursiveFunc, order, cookie, depth - 1, is_reentrant));
|
| }
|
| order->RecordEnd(RECURSIVE, cookie);
|
| }
|
| @@ -341,19 +343,19 @@ void RecursiveFuncWin(scoped_refptr<SingleThreadTaskRunner> task_runner,
|
| TaskList* order,
|
| bool is_reentrant) {
|
| task_runner->PostTask(FROM_HERE,
|
| - Bind(&RecursiveFunc, order, 1, 2, is_reentrant));
|
| + BindOnce(&RecursiveFunc, order, 1, 2, is_reentrant));
|
| task_runner->PostTask(FROM_HERE,
|
| - Bind(&MessageBoxFunc, order, 2, is_reentrant));
|
| + BindOnce(&MessageBoxFunc, order, 2, is_reentrant));
|
| task_runner->PostTask(FROM_HERE,
|
| - Bind(&RecursiveFunc, order, 3, 2, is_reentrant));
|
| + BindOnce(&RecursiveFunc, order, 3, 2, is_reentrant));
|
| // The trick here is that for recursive task processing, this task will be
|
| // ran _inside_ the MessageBox message loop, dismissing the MessageBox
|
| // without a chance.
|
| // For non-recursive task processing, this will be executed _after_ the
|
| // MessageBox will have been dismissed by the code below, where
|
| // expect_window_ is true.
|
| - task_runner->PostTask(FROM_HERE, Bind(&EndDialogFunc, order, 4));
|
| - task_runner->PostTask(FROM_HERE, Bind(&QuitFunc, order, 5));
|
| + task_runner->PostTask(FROM_HERE, BindOnce(&EndDialogFunc, order, 4));
|
| + task_runner->PostTask(FROM_HERE, BindOnce(&QuitFunc, order, 5));
|
|
|
| // Enforce that every tasks are sent before starting to run the main thread
|
| // message loop.
|
| @@ -392,8 +394,8 @@ void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) {
|
| TaskList order;
|
| win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
|
| worker.task_runner()->PostTask(
|
| - FROM_HERE, Bind(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
| - event.Get(), true, &order, false));
|
| + FROM_HERE, BindOnce(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
| + event.Get(), true, &order, false));
|
| // Let the other thread execute.
|
| WaitForSingleObject(event.Get(), INFINITE);
|
| RunLoop().Run();
|
| @@ -432,8 +434,8 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
|
| TaskList order;
|
| win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
|
| worker.task_runner()->PostTask(
|
| - FROM_HERE, Bind(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
| - event.Get(), false, &order, true));
|
| + FROM_HERE, BindOnce(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
| + event.Get(), false, &order, true));
|
| // Let the other thread execute.
|
| WaitForSingleObject(event.Get(), INFINITE);
|
| RunLoop().Run();
|
| @@ -450,7 +452,7 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
|
| EXPECT_EQ(order.Get(7), TaskItem(MESSAGEBOX, 2, false));
|
| /* The order can subtly change here. The reason is that when RecursiveFunc(1)
|
| is called in the main thread, if it is faster than getting to the
|
| - PostTask(FROM_HERE, Bind(&QuitFunc) execution, the order of task
|
| + PostTask(FROM_HERE, BindOnce(&QuitFunc) execution, the order of task
|
| execution can change. We don't care anyway that the order isn't correct.
|
| EXPECT_EQ(order.Get(8), TaskItem(QUITMESSAGELOOP, 5, true));
|
| EXPECT_EQ(order.Get(9), TaskItem(QUITMESSAGELOOP, 5, false));
|
| @@ -545,7 +547,7 @@ void RunTest_IOHandler() {
|
|
|
| TestIOHandler handler(kPipeName, callback_called.Get(), false);
|
| thread.task_runner()->PostTask(
|
| - FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler)));
|
| + FROM_HERE, BindOnce(&TestIOHandler::Init, Unretained(&handler)));
|
| // Make sure the thread runs and sleeps for lack of work.
|
| PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
|
|
|
| @@ -584,13 +586,13 @@ void RunTest_WaitForIO() {
|
| TestIOHandler handler1(kPipeName1, callback1_called.Get(), false);
|
| TestIOHandler handler2(kPipeName2, callback2_called.Get(), true);
|
| thread.task_runner()->PostTask(
|
| - FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler1)));
|
| + FROM_HERE, BindOnce(&TestIOHandler::Init, Unretained(&handler1)));
|
| // TODO(ajwong): Do we really need such long Sleeps in this function?
|
| // Make sure the thread runs and sleeps for lack of work.
|
| TimeDelta delay = TimeDelta::FromMilliseconds(100);
|
| PlatformThread::Sleep(delay);
|
| thread.task_runner()->PostTask(
|
| - FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler2)));
|
| + FROM_HERE, BindOnce(&TestIOHandler::Init, Unretained(&handler2)));
|
| PlatformThread::Sleep(delay);
|
|
|
| // At this time handler1 is waiting to be called, and the thread is waiting
|
| @@ -710,14 +712,14 @@ TEST(MessageLoopTest, HighResolutionTimer) {
|
| EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
| // Post a fast task to enable the high resolution timers.
|
| message_loop.task_runner()->PostDelayedTask(
|
| - FROM_HERE, Bind(&PostNTasksThenQuit, 1), kFastTimer);
|
| + FROM_HERE, BindOnce(&PostNTasksThenQuit, 1), kFastTimer);
|
| EXPECT_TRUE(message_loop.HasHighResolutionTasks());
|
| RunLoop().Run();
|
| EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
| EXPECT_FALSE(Time::IsHighResolutionTimerInUse());
|
| // Check that a slow task does not trigger the high resolution logic.
|
| message_loop.task_runner()->PostDelayedTask(
|
| - FROM_HERE, Bind(&PostNTasksThenQuit, 1), kSlowTimer);
|
| + FROM_HERE, BindOnce(&PostNTasksThenQuit, 1), kSlowTimer);
|
| EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
| RunLoop().Run();
|
| EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
| @@ -907,9 +909,9 @@ void EmptyFunction() {}
|
|
|
| void PostMultipleTasks() {
|
| ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| - base::Bind(&EmptyFunction));
|
| + base::BindOnce(&EmptyFunction));
|
| ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| - base::Bind(&EmptyFunction));
|
| + base::BindOnce(&EmptyFunction));
|
| }
|
|
|
| static const int kSignalMsg = WM_USER + 2;
|
| @@ -938,11 +940,11 @@ LRESULT CALLBACK TestWndProcThunk(HWND hwnd, UINT message,
|
| // that the pump's incoming task queue does not become empty during the
|
| // test.
|
| ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| - base::Bind(&PostMultipleTasks));
|
| + base::BindOnce(&PostMultipleTasks));
|
| // Next, we post a task that posts a windows message to trigger the second
|
| // stage of the test.
|
| ThreadTaskRunnerHandle::Get()->PostTask(
|
| - FROM_HERE, base::Bind(&PostWindowsMessage, hwnd));
|
| + FROM_HERE, base::BindOnce(&PostWindowsMessage, hwnd));
|
| break;
|
| case 2:
|
| // Since we're about to enter a modal loop, tell the message loop that we
|
| @@ -950,7 +952,7 @@ LRESULT CALLBACK TestWndProcThunk(HWND hwnd, UINT message,
|
| MessageLoop::current()->SetNestableTasksAllowed(true);
|
| bool did_run = false;
|
| ThreadTaskRunnerHandle::Get()->PostTask(
|
| - FROM_HERE, base::Bind(&EndTest, &did_run, hwnd));
|
| + FROM_HERE, base::BindOnce(&EndTest, &did_run, hwnd));
|
| // Run a nested windows-style message loop and verify that our task runs. If
|
| // it doesn't, then we'll loop here until the test times out.
|
| MSG msg;
|
|
|