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 #include "content/public/test/test_utils.h" | 5 #include "content/public/test/test_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/task_scheduler/task_scheduler.h" | |
16 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "content/common/site_isolation_policy.h" | 21 #include "content/common/site_isolation_policy.h" |
21 #include "content/common/url_schemes.h" | 22 #include "content/common/url_schemes.h" |
22 #include "content/public/browser/browser_child_process_host_iterator.h" | 23 #include "content/public/browser/browser_child_process_host_iterator.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 base::ThreadTaskRunnerHandle::Get(), FROM_HERE, run_loop.QuitClosure()); | 151 base::ThreadTaskRunnerHandle::Get(), FROM_HERE, run_loop.QuitClosure()); |
151 BrowserThread::PostTask( | 152 BrowserThread::PostTask( |
152 thread_id, FROM_HERE, | 153 thread_id, FROM_HERE, |
153 base::Bind(&DeferredQuitRunLoop, post_quit_run_loop_to_ui_thread, | 154 base::Bind(&DeferredQuitRunLoop, post_quit_run_loop_to_ui_thread, |
154 kNumQuitDeferrals)); | 155 kNumQuitDeferrals)); |
155 RunThisRunLoop(&run_loop); | 156 RunThisRunLoop(&run_loop); |
156 } | 157 } |
157 | 158 |
158 void RunAllBlockingPoolTasksUntilIdle() { | 159 void RunAllBlockingPoolTasksUntilIdle() { |
159 while (true) { | 160 while (true) { |
161 // Flush blocking pool tasks. | |
robliao
2017/03/17 01:00:14
Remove this comment as it's stating what the next
fdoray
2017/03/31 20:26:04
Removed unnecessary comment.
I have a few CLs to
| |
160 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 162 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
161 | 163 |
164 // Also flush TaskScheduler tasks since all blocking pool call sites are | |
165 // being migrated to TaskScheduler. | |
166 base::TaskScheduler::GetInstance()->FlushForTesting(); | |
167 | |
162 TaskObserver task_observer; | 168 TaskObserver task_observer; |
163 base::MessageLoop::current()->AddTaskObserver(&task_observer); | 169 base::MessageLoop::current()->AddTaskObserver(&task_observer); |
164 base::RunLoop().RunUntilIdle(); | 170 base::RunLoop().RunUntilIdle(); |
165 base::MessageLoop::current()->RemoveTaskObserver(&task_observer); | 171 base::MessageLoop::current()->RemoveTaskObserver(&task_observer); |
166 | 172 |
167 if (!task_observer.processed()) | 173 if (!task_observer.processed()) |
168 break; | 174 break; |
169 } | 175 } |
170 } | 176 } |
171 | 177 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 | 394 |
389 void WebContentsDestroyedWatcher::Wait() { | 395 void WebContentsDestroyedWatcher::Wait() { |
390 run_loop_.Run(); | 396 run_loop_.Run(); |
391 } | 397 } |
392 | 398 |
393 void WebContentsDestroyedWatcher::WebContentsDestroyed() { | 399 void WebContentsDestroyedWatcher::WebContentsDestroyed() { |
394 run_loop_.Quit(); | 400 run_loop_.Quit(); |
395 } | 401 } |
396 | 402 |
397 } // namespace content | 403 } // namespace content |
OLD | NEW |