| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // TestBrowserThreadBundle is a convenience class for creating a set of | 5 // TestBrowserThreadBundle is a convenience class for creating a set of |
| 6 // TestBrowserThreads in unit tests. For most tests, it is sufficient to | 6 // TestBrowserThreads in unit tests. For most tests, it is sufficient to |
| 7 // just instantiate the TestBrowserThreadBundle as a member variable. | 7 // just instantiate the TestBrowserThreadBundle as a member variable. |
| 8 // | 8 // |
| 9 // By default, all of the created TestBrowserThreads will be backed by a single | 9 // By default, all of the created TestBrowserThreads will be backed by a single |
| 10 // shared MessageLoop. If a test truly needs separate threads, it can do | 10 // shared MessageLoop. If a test truly needs separate threads, it can do |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // main thread, and starting the other threads. Passing DONT_START_THREADS to | 35 // main thread, and starting the other threads. Passing DONT_START_THREADS to |
| 36 // constructor will delay staring these other threads until the test explicitly | 36 // constructor will delay staring these other threads until the test explicitly |
| 37 // calls Start(). | 37 // calls Start(). |
| 38 // | 38 // |
| 39 // DONT_START_THREADS should only be used when the options specify at least | 39 // DONT_START_THREADS should only be used when the options specify at least |
| 40 // one real thread other than the main thread. | 40 // one real thread other than the main thread. |
| 41 | 41 |
| 42 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 42 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
| 43 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 43 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
| 44 | 44 |
| 45 #include <memory> |
| 46 |
| 45 #include "base/macros.h" | 47 #include "base/macros.h" |
| 46 #include "base/memory/scoped_ptr.h" | |
| 47 | 48 |
| 48 namespace base { | 49 namespace base { |
| 49 class MessageLoop; | 50 class MessageLoop; |
| 50 } // namespace base | 51 } // namespace base |
| 51 | 52 |
| 52 namespace content { | 53 namespace content { |
| 53 | 54 |
| 54 class TestBrowserThread; | 55 class TestBrowserThread; |
| 55 | 56 |
| 56 class TestBrowserThreadBundle { | 57 class TestBrowserThreadBundle { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 75 | 76 |
| 76 // Start the real threads; should only be called from other classes if the | 77 // Start the real threads; should only be called from other classes if the |
| 77 // DONT_START_THREADS option was used when the bundle was created. | 78 // DONT_START_THREADS option was used when the bundle was created. |
| 78 void Start(); | 79 void Start(); |
| 79 | 80 |
| 80 ~TestBrowserThreadBundle(); | 81 ~TestBrowserThreadBundle(); |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 void Init(); | 84 void Init(); |
| 84 | 85 |
| 85 scoped_ptr<base::MessageLoop> message_loop_; | 86 std::unique_ptr<base::MessageLoop> message_loop_; |
| 86 scoped_ptr<TestBrowserThread> ui_thread_; | 87 std::unique_ptr<TestBrowserThread> ui_thread_; |
| 87 scoped_ptr<TestBrowserThread> db_thread_; | 88 std::unique_ptr<TestBrowserThread> db_thread_; |
| 88 scoped_ptr<TestBrowserThread> file_thread_; | 89 std::unique_ptr<TestBrowserThread> file_thread_; |
| 89 scoped_ptr<TestBrowserThread> file_user_blocking_thread_; | 90 std::unique_ptr<TestBrowserThread> file_user_blocking_thread_; |
| 90 scoped_ptr<TestBrowserThread> process_launcher_thread_; | 91 std::unique_ptr<TestBrowserThread> process_launcher_thread_; |
| 91 scoped_ptr<TestBrowserThread> cache_thread_; | 92 std::unique_ptr<TestBrowserThread> cache_thread_; |
| 92 scoped_ptr<TestBrowserThread> io_thread_; | 93 std::unique_ptr<TestBrowserThread> io_thread_; |
| 93 | 94 |
| 94 int options_; | 95 int options_; |
| 95 bool threads_started_; | 96 bool threads_started_; |
| 96 | 97 |
| 97 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle); | 98 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle); |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 } // namespace content | 101 } // namespace content |
| 101 | 102 |
| 102 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 103 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
| OLD | NEW |