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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 private: | 276 private: |
277 virtual ~WorkerCreationObserver() {} | 277 virtual ~WorkerCreationObserver() {} |
278 | 278 |
279 virtual void WorkerCreated ( | 279 virtual void WorkerCreated ( |
280 WorkerProcessHost* process, | 280 WorkerProcessHost* process, |
281 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE { | 281 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE { |
282 worker_data_->worker_process_id = process->id(); | 282 worker_data_->worker_process_id = process->id(); |
283 worker_data_->worker_route_id = instance.worker_route_id(); | 283 worker_data_->worker_route_id = instance.worker_route_id(); |
284 WorkerService::GetInstance()->RemoveObserver(this); | 284 WorkerService::GetInstance()->RemoveObserver(this); |
285 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 285 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
286 new MessageLoop::QuitTask); | 286 MessageLoop::QuitClosure()); |
287 delete this; | 287 delete this; |
288 } | 288 } |
289 virtual void WorkerDestroyed( | 289 virtual void WorkerDestroyed( |
290 WorkerProcessHost*, | 290 WorkerProcessHost*, |
291 int worker_route_id) OVERRIDE {} | 291 int worker_route_id) OVERRIDE {} |
292 virtual void WorkerContextStarted( | 292 virtual void WorkerContextStarted( |
293 WorkerProcessHost*, | 293 WorkerProcessHost*, |
294 int worker_route_id) OVERRIDE {} | 294 int worker_route_id) OVERRIDE {} |
295 scoped_refptr<WorkerData> worker_data_; | 295 scoped_refptr<WorkerData> worker_data_; |
296 }; | 296 }; |
(...skipping 10 matching lines...) Expand all Loading... |
307 virtual void WorkerCreated ( | 307 virtual void WorkerCreated ( |
308 WorkerProcessHost* process, | 308 WorkerProcessHost* process, |
309 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE {} | 309 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE {} |
310 virtual void WorkerDestroyed( | 310 virtual void WorkerDestroyed( |
311 WorkerProcessHost* process, | 311 WorkerProcessHost* process, |
312 int worker_route_id) OVERRIDE { | 312 int worker_route_id) OVERRIDE { |
313 ASSERT_EQ(worker_data_->worker_process_id, process->id()); | 313 ASSERT_EQ(worker_data_->worker_process_id, process->id()); |
314 ASSERT_EQ(worker_data_->worker_route_id, worker_route_id); | 314 ASSERT_EQ(worker_data_->worker_route_id, worker_route_id); |
315 WorkerService::GetInstance()->RemoveObserver(this); | 315 WorkerService::GetInstance()->RemoveObserver(this); |
316 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 316 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
317 new MessageLoop::QuitTask); | 317 MessageLoop::QuitClosure()); |
318 delete this; | 318 delete this; |
319 } | 319 } |
320 virtual void WorkerContextStarted( | 320 virtual void WorkerContextStarted( |
321 WorkerProcessHost*, | 321 WorkerProcessHost*, |
322 int worker_route_id) OVERRIDE {} | 322 int worker_route_id) OVERRIDE {} |
323 scoped_refptr<WorkerData> worker_data_; | 323 scoped_refptr<WorkerData> worker_data_; |
324 }; | 324 }; |
325 | 325 |
326 void RunTest(const char* test_name, const char* test_page) { | 326 void RunTest(const char* test_name, const char* test_page) { |
327 ASSERT_TRUE(test_server()->Start()); | 327 ASSERT_TRUE(test_server()->Start()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); | 361 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); |
362 for (; !iter.Done(); ++iter) { | 362 for (; !iter.Done(); ++iter) { |
363 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); | 363 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
364 const WorkerProcessHost::Instances& instances = worker->instances(); | 364 const WorkerProcessHost::Instances& instances = worker->instances(); |
365 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); | 365 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); |
366 i != instances.end(); ++i) { | 366 i != instances.end(); ++i) { |
367 | 367 |
368 worker_data->worker_process_id = worker->id(); | 368 worker_data->worker_process_id = worker->id(); |
369 worker_data->worker_route_id = i->worker_route_id(); | 369 worker_data->worker_route_id = i->worker_route_id(); |
370 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 370 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
371 new MessageLoop::QuitTask); | 371 MessageLoop::QuitClosure()); |
372 return; | 372 return; |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 WorkerService::GetInstance()->AddObserver( | 376 WorkerService::GetInstance()->AddObserver( |
377 new WorkerCreationObserver(worker_data.get())); | 377 new WorkerCreationObserver(worker_data.get())); |
378 } | 378 } |
379 | 379 |
380 static scoped_refptr<WorkerData> WaitForFirstSharedWorker() { | 380 static scoped_refptr<WorkerData> WaitForFirstSharedWorker() { |
381 scoped_refptr<WorkerData> worker_data(new WorkerData()); | 381 scoped_refptr<WorkerData> worker_data(new WorkerData()); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 560 |
561 // Reload page to restart the worker. | 561 // Reload page to restart the worker. |
562 ui_test_utils::NavigateToURL(browser(), url); | 562 ui_test_utils::NavigateToURL(browser(), url); |
563 | 563 |
564 // Wait until worker script is paused on the debugger statement. | 564 // Wait until worker script is paused on the debugger statement. |
565 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); | 565 RunTestFuntion(window_, "testPauseInSharedWorkerInitialization"); |
566 CloseDevToolsWindow(); | 566 CloseDevToolsWindow(); |
567 } | 567 } |
568 | 568 |
569 } // namespace | 569 } // namespace |
OLD | NEW |