| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cancelable_callback.h" | 6 #include "base/cancelable_callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 ui_test_utils::NavigateToURL(browser(), url); | 324 ui_test_utils::NavigateToURL(browser(), url); |
| 325 | 325 |
| 326 scoped_refptr<WorkerData> worker_data = WaitForFirstSharedWorker(); | 326 scoped_refptr<WorkerData> worker_data = WaitForFirstSharedWorker(); |
| 327 OpenDevToolsWindowForSharedWorker(worker_data.get()); | 327 OpenDevToolsWindowForSharedWorker(worker_data.get()); |
| 328 RunTestFuntion(window_, test_name); | 328 RunTestFuntion(window_, test_name); |
| 329 CloseDevToolsWindow(); | 329 CloseDevToolsWindow(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 static void TerminateWorkerOnIOThread( | 332 static void TerminateWorkerOnIOThread( |
| 333 scoped_refptr<WorkerData> worker_data) { | 333 scoped_refptr<WorkerData> worker_data) { |
| 334 for (BrowserChildProcessHost::Iterator iter( | 334 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); |
| 335 ChildProcessInfo::WORKER_PROCESS); | |
| 336 !iter.Done(); ++iter) { | 335 !iter.Done(); ++iter) { |
| 337 if (iter->id() == worker_data->worker_process_id) { | 336 if (iter->id() == worker_data->worker_process_id) { |
| 338 WorkerProcessHost* host = static_cast<WorkerProcessHost*>(*iter); | 337 WorkerProcessHost* host = static_cast<WorkerProcessHost*>(*iter); |
| 339 host->TerminateWorker(worker_data->worker_route_id); | 338 host->TerminateWorker(worker_data->worker_route_id); |
| 340 WorkerService::GetInstance()->AddObserver( | 339 WorkerService::GetInstance()->AddObserver( |
| 341 new WorkerTerminationObserver(worker_data)); | 340 new WorkerTerminationObserver(worker_data)); |
| 342 return; | 341 return; |
| 343 } | 342 } |
| 344 } | 343 } |
| 345 FAIL() << "Failed to terminate worker.\n"; | 344 FAIL() << "Failed to terminate worker.\n"; |
| 346 } | 345 } |
| 347 | 346 |
| 348 static void TerminateWorker(scoped_refptr<WorkerData> worker_data) { | 347 static void TerminateWorker(scoped_refptr<WorkerData> worker_data) { |
| 349 BrowserThread::PostTask( | 348 BrowserThread::PostTask( |
| 350 BrowserThread::IO, FROM_HERE, | 349 BrowserThread::IO, FROM_HERE, |
| 351 base::Bind(&TerminateWorkerOnIOThread, worker_data)); | 350 base::Bind(&TerminateWorkerOnIOThread, worker_data)); |
| 352 ui_test_utils::RunMessageLoop(); | 351 ui_test_utils::RunMessageLoop(); |
| 353 } | 352 } |
| 354 | 353 |
| 355 static void WaitForFirstSharedWorkerOnIOThread( | 354 static void WaitForFirstSharedWorkerOnIOThread( |
| 356 scoped_refptr<WorkerData> worker_data) { | 355 scoped_refptr<WorkerData> worker_data) { |
| 357 BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); | 356 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); |
| 358 for (; !iter.Done(); ++iter) { | 357 for (; !iter.Done(); ++iter) { |
| 359 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); | 358 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
| 360 const WorkerProcessHost::Instances& instances = worker->instances(); | 359 const WorkerProcessHost::Instances& instances = worker->instances(); |
| 361 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); | 360 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); |
| 362 i != instances.end(); ++i) { | 361 i != instances.end(); ++i) { |
| 363 | 362 |
| 364 worker_data->worker_process_id = worker->id(); | 363 worker_data->worker_process_id = worker->id(); |
| 365 worker_data->worker_route_id = i->worker_route_id(); | 364 worker_data->worker_route_id = i->worker_route_id(); |
| 366 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 365 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 367 new MessageLoop::QuitTask); | 366 new MessageLoop::QuitTask); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 549 |
| 551 // Reload page to restart the worker. | 550 // Reload page to restart the worker. |
| 552 ui_test_utils::NavigateToURL(browser(), url); | 551 ui_test_utils::NavigateToURL(browser(), url); |
| 553 | 552 |
| 554 // Wait until worker script is paused on the debugger statement. | 553 // Wait until worker script is paused on the debugger statement. |
| 555 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); | 554 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); |
| 556 CloseDevToolsWindow(); | 555 CloseDevToolsWindow(); |
| 557 } | 556 } |
| 558 | 557 |
| 559 } // namespace | 558 } // namespace |
| OLD | NEW |