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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); | 307 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); |
308 } | 308 } |
309 | 309 |
310 bool WaitForWorkerProcessCount(int count) { | 310 bool WaitForWorkerProcessCount(int count) { |
311 int cur_process_count; | 311 int cur_process_count; |
312 for (int i = 0; i < 100; ++i) { | 312 for (int i = 0; i < 100; ++i) { |
313 BrowserThread::PostTask( | 313 BrowserThread::PostTask( |
314 BrowserThread::IO, FROM_HERE, | 314 BrowserThread::IO, FROM_HERE, |
315 base::Bind(&CountWorkerProcesses, &cur_process_count)); | 315 base::Bind(&CountWorkerProcesses, &cur_process_count)); |
316 | 316 |
317 base::RunLoop run_loop; | 317 content::RunMessageLoop(); |
318 content::RunThisRunLoop(&run_loop); | |
319 if (cur_process_count == count) | 318 if (cur_process_count == count) |
320 return true; | 319 return true; |
321 | 320 |
322 // Sometimes the worker processes can take a while to shut down on the | 321 // Sometimes the worker processes can take a while to shut down on the |
323 // bots, so use a longer timeout period to avoid spurious failures. | 322 // bots, so use a longer timeout period to avoid spurious failures. |
324 base::PlatformThread::Sleep(TestTimeouts::action_max_timeout() / 100); | 323 base::PlatformThread::Sleep(TestTimeouts::action_max_timeout() / 100); |
325 } | 324 } |
326 | 325 |
327 EXPECT_EQ(cur_process_count, count); | 326 EXPECT_EQ(cur_process_count, count); |
328 return false; | 327 return false; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 495 |
497 // First window has hit its limit. Now launch second window which creates | 496 // First window has hit its limit. Now launch second window which creates |
498 // the same worker that was queued in the first window, to ensure it gets | 497 // the same worker that was queued in the first window, to ensure it gets |
499 // connected to the first window too. | 498 // connected to the first window too. |
500 query = StringPrintf("?id=%d", max_workers_per_tab); | 499 query = StringPrintf("?id=%d", max_workers_per_tab); |
501 url = GetTestURL("single_shared_worker.html", query); | 500 url = GetTestURL("single_shared_worker.html", query); |
502 content::NavigateToURL(CreateBrowser(), url); | 501 content::NavigateToURL(CreateBrowser(), url); |
503 | 502 |
504 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); | 503 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); |
505 } | 504 } |
OLD | NEW |