OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/location.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
9 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
10 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 namespace sync_file_system { | 14 namespace sync_file_system { |
14 namespace drive_backend { | 15 namespace drive_backend { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 void SimpleCallback(bool* called, int) { | 19 void SimpleCallback(bool* called, int) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 62 } |
62 | 63 |
63 TEST(DriveBackendCallbackHelperTest, RunOnOtherThreadTest) { | 64 TEST(DriveBackendCallbackHelperTest, RunOnOtherThreadTest) { |
64 base::MessageLoop message_loop; | 65 base::MessageLoop message_loop; |
65 base::Thread thread("WorkerThread"); | 66 base::Thread thread("WorkerThread"); |
66 thread.Start(); | 67 thread.Start(); |
67 | 68 |
68 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner = | 69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner = |
69 base::ThreadTaskRunnerHandle::Get(); | 70 base::ThreadTaskRunnerHandle::Get(); |
70 scoped_refptr<base::SequencedTaskRunner> worker_task_runner = | 71 scoped_refptr<base::SequencedTaskRunner> worker_task_runner = |
71 thread.message_loop_proxy(); | 72 thread.task_runner(); |
72 | 73 |
73 bool called = false; | 74 bool called = false; |
74 base::RunLoop run_loop; | 75 base::RunLoop run_loop; |
75 worker_task_runner->PostTask( | 76 worker_task_runner->PostTask( |
76 FROM_HERE, | 77 FROM_HERE, |
77 RelayCallbackToTaskRunner( | 78 RelayCallbackToTaskRunner( |
78 ui_task_runner.get(), | 79 ui_task_runner.get(), |
79 FROM_HERE, | 80 FROM_HERE, |
80 base::Bind(&VerifyCalledOnTaskRunner, ui_task_runner, &called))); | 81 base::Bind(&VerifyCalledOnTaskRunner, ui_task_runner, &called))); |
81 worker_task_runner->PostTask( | 82 worker_task_runner->PostTask( |
(...skipping 10 matching lines...) Expand all Loading... |
92 TEST(DriveBackendCallbackHelperTest, PassNullFunctionTest) { | 93 TEST(DriveBackendCallbackHelperTest, PassNullFunctionTest) { |
93 base::MessageLoop message_loop; | 94 base::MessageLoop message_loop; |
94 base::Closure closure = RelayCallbackToCurrentThread( | 95 base::Closure closure = RelayCallbackToCurrentThread( |
95 FROM_HERE, | 96 FROM_HERE, |
96 base::Closure()); | 97 base::Closure()); |
97 EXPECT_TRUE(closure.is_null()); | 98 EXPECT_TRUE(closure.is_null()); |
98 } | 99 } |
99 | 100 |
100 } // namespace drive_backend | 101 } // namespace drive_backend |
101 } // namespace sync_file_system | 102 } // namespace sync_file_system |
OLD | NEW |