| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class RunLoop; | 13 class RunLoop; |
| 14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace content { | |
| 18 class TestBrowserThreadBundle; | |
| 19 } | |
| 20 | |
| 21 namespace sync_file_system { | 17 namespace sync_file_system { |
| 22 | 18 |
| 23 template <typename R> | 19 template <typename R> |
| 24 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result); | 20 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result); |
| 25 | 21 |
| 26 template <typename R> base::Callback<void(R)> | 22 template <typename R> base::Callback<void(R)> |
| 27 AssignAndQuitCallback(base::RunLoop* run_loop, R* result); | 23 AssignAndQuitCallback(base::RunLoop* run_loop, R* result); |
| 28 | 24 |
| 29 // This sets up FILE, IO and UI browser threads for testing. | |
| 30 // (UI thread is set to the current thread.) | |
| 31 class MultiThreadTestHelper { | |
| 32 public: | |
| 33 MultiThreadTestHelper(); | |
| 34 ~MultiThreadTestHelper(); | |
| 35 | |
| 36 void SetUp(); | |
| 37 void TearDown(); | |
| 38 | |
| 39 base::SingleThreadTaskRunner* ui_task_runner() { | |
| 40 return ui_task_runner_.get(); | |
| 41 } | |
| 42 | |
| 43 base::SingleThreadTaskRunner* file_task_runner() { | |
| 44 return file_task_runner_.get(); | |
| 45 } | |
| 46 | |
| 47 base::SingleThreadTaskRunner* io_task_runner() { | |
| 48 return io_task_runner_.get(); | |
| 49 } | |
| 50 | |
| 51 private: | |
| 52 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; | |
| 53 | |
| 54 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | |
| 55 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | |
| 56 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
| 57 }; | |
| 58 | |
| 59 } // namespace sync_file_system | 25 } // namespace sync_file_system |
| 60 | 26 |
| 61 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ | 27 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_TEST_UTIL_H_ |
| OLD | NEW |