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 #include "content/public/test/test_browser_thread_bundle.h" | 5 #include "content/public/test/test_browser_thread_bundle.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | |
7 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/scoped_task_scheduler.h" | |
9 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
10 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 TestBrowserThreadBundle::TestBrowserThreadBundle() | 16 TestBrowserThreadBundle::TestBrowserThreadBundle() |
15 : TestBrowserThreadBundle(DEFAULT) {} | 17 : TestBrowserThreadBundle(DEFAULT) {} |
16 | 18 |
17 TestBrowserThreadBundle::TestBrowserThreadBundle(int options) | 19 TestBrowserThreadBundle::TestBrowserThreadBundle(int options) |
18 : options_(options), threads_started_(false) { | 20 : options_(options), threads_started_(false) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 CHECK(!(options_ & IO_MAINLOOP) || !(options_ & REAL_IO_THREAD)); | 59 CHECK(!(options_ & IO_MAINLOOP) || !(options_ & REAL_IO_THREAD)); |
58 // There must be a thread to start to use DONT_START_THREADS | 60 // There must be a thread to start to use DONT_START_THREADS |
59 CHECK((options_ & ~IO_MAINLOOP) != DONT_START_THREADS); | 61 CHECK((options_ & ~IO_MAINLOOP) != DONT_START_THREADS); |
60 | 62 |
61 if (options_ & IO_MAINLOOP) { | 63 if (options_ & IO_MAINLOOP) { |
62 message_loop_.reset(new base::MessageLoopForIO()); | 64 message_loop_.reset(new base::MessageLoopForIO()); |
63 } else { | 65 } else { |
64 message_loop_.reset(new base::MessageLoopForUI()); | 66 message_loop_.reset(new base::MessageLoopForUI()); |
65 } | 67 } |
66 | 68 |
69 scoped_task_scheduler_ = base::MakeUnique<base::test::ScopedTaskScheduler>(); | |
gab
2016/12/09 20:04:17
I know MakeUnique is prefered today, but the ultim
fdoray
2016/12/12 18:18:50
Done.
| |
70 | |
67 ui_thread_.reset( | 71 ui_thread_.reset( |
68 new TestBrowserThread(BrowserThread::UI, message_loop_.get())); | 72 new TestBrowserThread(BrowserThread::UI, message_loop_.get())); |
69 | 73 |
70 if (options_ & REAL_DB_THREAD) { | 74 if (options_ & REAL_DB_THREAD) { |
71 db_thread_.reset(new TestBrowserThread(BrowserThread::DB)); | 75 db_thread_.reset(new TestBrowserThread(BrowserThread::DB)); |
72 } else { | 76 } else { |
73 db_thread_.reset( | 77 db_thread_.reset( |
74 new TestBrowserThread(BrowserThread::DB, message_loop_.get())); | 78 new TestBrowserThread(BrowserThread::DB, message_loop_.get())); |
75 } | 79 } |
76 | 80 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 if (options_ & REAL_FILE_THREAD) | 112 if (options_ & REAL_FILE_THREAD) |
109 file_thread_->Start(); | 113 file_thread_->Start(); |
110 | 114 |
111 if (options_ & REAL_IO_THREAD) | 115 if (options_ & REAL_IO_THREAD) |
112 io_thread_->StartIOThread(); | 116 io_thread_->StartIOThread(); |
113 | 117 |
114 threads_started_ = true; | 118 threads_started_ = true; |
115 } | 119 } |
116 | 120 |
117 } // namespace content | 121 } // namespace content |
OLD | NEW |