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/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
16 #include "content/browser/browser_thread_impl.h" | 16 #include "content/browser/browser_thread_impl.h" |
17 #include "content/browser/download/download_file_manager.h" | 17 #include "content/browser/download/download_file_manager.h" |
18 #include "content/browser/download/save_file_manager.h" | 18 #include "content/browser/download/save_file_manager.h" |
19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
20 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
22 #include "content/browser/in_process_webkit/webkit_thread.h" | 22 #include "content/browser/in_process_webkit/webkit_thread.h" |
23 #include "content/browser/net/browser_online_state_observer.h" | 23 #include "content/browser/net/browser_online_state_observer.h" |
24 #include "content/browser/plugin_service_impl.h" | 24 #include "content/browser/plugin_service_impl.h" |
25 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 25 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
26 #include "content/browser/speech/speech_recognition_manager_impl.h" | |
26 #include "content/browser/trace_controller_impl.h" | 27 #include "content/browser/trace_controller_impl.h" |
27 #include "content/common/hi_res_timer_manager.h" | 28 #include "content/common/hi_res_timer_manager.h" |
28 #include "content/public/browser/browser_main_parts.h" | 29 #include "content/public/browser/browser_main_parts.h" |
29 #include "content/public/browser/browser_shutdown.h" | 30 #include "content/public/browser/browser_shutdown.h" |
30 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
31 #include "content/public/browser/gpu_data_manager.h" | 32 #include "content/public/browser/gpu_data_manager.h" |
32 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
33 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
34 #include "content/public/common/main_function_params.h" | 35 #include "content/public/common/main_function_params.h" |
35 #include "content/public/common/result_codes.h" | 36 #include "content/public/common/result_codes.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 474 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
474 // delete related objects on the GPU thread. This must be done before | 475 // delete related objects on the GPU thread. This must be done before |
475 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 476 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
476 // processes so this has to happen before stopping the IO thread. | 477 // processes so this has to happen before stopping the IO thread. |
477 GpuProcessHostUIShim::DestroyAll(); | 478 GpuProcessHostUIShim::DestroyAll(); |
478 | 479 |
479 // Cancel pending requests and prevent new requests. | 480 // Cancel pending requests and prevent new requests. |
480 if (resource_dispatcher_host_.get()) | 481 if (resource_dispatcher_host_.get()) |
481 resource_dispatcher_host_.get()->Shutdown(); | 482 resource_dispatcher_host_.get()->Shutdown(); |
482 | 483 |
484 // Cleanup the speech recognition manager. | |
jam
2012/05/15 16:38:31
nit: this comment and the one below are just descr
Primiano Tucci (use gerrit)
2012/05/15 17:17:12
Done.
| |
485 speech_recognition_manager_.reset(); | |
486 | |
483 #if defined(USE_AURA) | 487 #if defined(USE_AURA) |
484 ImageTransportFactory::Terminate(); | 488 ImageTransportFactory::Terminate(); |
485 #endif | 489 #endif |
486 BrowserGpuChannelHostFactory::Terminate(); | 490 BrowserGpuChannelHostFactory::Terminate(); |
487 | 491 |
488 // Must be size_t so we can subtract from it. | 492 // Must be size_t so we can subtract from it. |
489 for (size_t thread_id = BrowserThread::ID_COUNT - 1; | 493 for (size_t thread_id = BrowserThread::ID_COUNT - 1; |
490 thread_id >= (BrowserThread::UI + 1); | 494 thread_id >= (BrowserThread::UI + 1); |
491 --thread_id) { | 495 --thread_id) { |
492 // Find the thread object we want to stop. Looping over all valid | 496 // Find the thread object we want to stop. Looping over all valid |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 // Register the main thread by instantiating it, but don't call any methods. | 590 // Register the main thread by instantiating it, but don't call any methods. |
587 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 591 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
588 MessageLoop::current())); | 592 MessageLoop::current())); |
589 } | 593 } |
590 | 594 |
591 | 595 |
592 void BrowserMainLoop::BrowserThreadsStarted() { | 596 void BrowserMainLoop::BrowserThreadsStarted() { |
593 // RDH needs the IO thread to be created. | 597 // RDH needs the IO thread to be created. |
594 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 598 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
595 | 599 |
600 // Initialize the speech recognition manager. | |
601 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | |
602 | |
596 // Start the GpuDataManager before we set up the MessageLoops because | 603 // Start the GpuDataManager before we set up the MessageLoops because |
597 // otherwise we'll trigger the assertion about doing IO on the UI thread. | 604 // otherwise we'll trigger the assertion about doing IO on the UI thread. |
598 content::GpuDataManager::GetInstance(); | 605 content::GpuDataManager::GetInstance(); |
599 } | 606 } |
600 | 607 |
601 void BrowserMainLoop::InitializeToolkit() { | 608 void BrowserMainLoop::InitializeToolkit() { |
602 // TODO(evan): this function is rather subtle, due to the variety | 609 // TODO(evan): this function is rather subtle, due to the variety |
603 // of intersecting ifdefs we have. To keep it easy to follow, there | 610 // of intersecting ifdefs we have. To keep it easy to follow, there |
604 // are no #else branches on any #ifs. | 611 // are no #else branches on any #ifs. |
605 // TODO(stevenjb): Move platform specific code into platform specific Parts | 612 // TODO(stevenjb): Move platform specific code into platform specific Parts |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 MessageLoopForUI::current()->Run(); | 653 MessageLoopForUI::current()->Run(); |
647 #elif defined(OS_ANDROID) | 654 #elif defined(OS_ANDROID) |
648 // Android's main message loop is the Java message loop. | 655 // Android's main message loop is the Java message loop. |
649 NOTREACHED(); | 656 NOTREACHED(); |
650 #else | 657 #else |
651 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 658 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
652 #endif | 659 #endif |
653 } | 660 } |
654 | 661 |
655 } // namespace content | 662 } // namespace content |
OLD | NEW |