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/hi_res_timer_manager.h" | 10 #include "base/hi_res_timer_manager.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "content/browser/browser_thread_impl.h" | 18 #include "content/browser/browser_thread_impl.h" |
19 #include "content/browser/download/download_file_manager.h" | 19 #include "content/browser/download/download_file_manager.h" |
20 #include "content/browser/download/save_file_manager.h" | 20 #include "content/browser/download/save_file_manager.h" |
21 #include "content/browser/gamepad/gamepad_service.h" | 21 #include "content/browser/gamepad/gamepad_service.h" |
22 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 22 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 23 #include "content/browser/gpu/gpu_data_manager_impl.h" |
23 #include "content/browser/gpu/gpu_process_host.h" | 24 #include "content/browser/gpu/gpu_process_host.h" |
24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 25 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
25 #include "content/browser/histogram_synchronizer.h" | 26 #include "content/browser/histogram_synchronizer.h" |
26 #include "content/browser/in_process_webkit/webkit_thread.h" | 27 #include "content/browser/in_process_webkit/webkit_thread.h" |
27 #include "content/browser/net/browser_online_state_observer.h" | 28 #include "content/browser/net/browser_online_state_observer.h" |
28 #include "content/browser/plugin_service_impl.h" | 29 #include "content/browser/plugin_service_impl.h" |
29 #include "content/browser/renderer_host/media/media_stream_manager.h" | 30 #include "content/browser/renderer_host/media/media_stream_manager.h" |
30 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 31 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
31 #include "content/browser/speech/speech_recognition_manager_impl.h" | 32 #include "content/browser/speech/speech_recognition_manager_impl.h" |
32 #include "content/browser/trace_controller_impl.h" | 33 #include "content/browser/trace_controller_impl.h" |
33 #include "content/public/browser/browser_main_parts.h" | 34 #include "content/public/browser/browser_main_parts.h" |
34 #include "content/public/browser/browser_shutdown.h" | 35 #include "content/public/browser/browser_shutdown.h" |
35 #include "content/public/browser/content_browser_client.h" | 36 #include "content/public/browser/content_browser_client.h" |
36 #include "content/public/browser/gpu_data_manager.h" | |
37 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
39 #include "content/public/common/main_function_params.h" | 39 #include "content/public/common/main_function_params.h" |
40 #include "content/public/common/result_codes.h" | 40 #include "content/public/common/result_codes.h" |
41 #include "crypto/nss_util.h" | 41 #include "crypto/nss_util.h" |
42 #include "media/audio/audio_manager.h" | 42 #include "media/audio/audio_manager.h" |
43 #include "net/base/network_change_notifier.h" | 43 #include "net/base/network_change_notifier.h" |
44 #include "net/base/ssl_config_service.h" | 44 #include "net/base/ssl_config_service.h" |
45 #include "net/socket/client_socket_factory.h" | 45 #include "net/socket/client_socket_factory.h" |
46 #include "net/socket/tcp_client_socket.h" | 46 #include "net/socket/tcp_client_socket.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 442 |
443 BrowserThreadsStarted(); | 443 BrowserThreadsStarted(); |
444 | 444 |
445 if (parts_.get()) | 445 if (parts_.get()) |
446 parts_->PreMainMessageLoopRun(); | 446 parts_->PreMainMessageLoopRun(); |
447 | 447 |
448 #if !defined(OS_IOS) | 448 #if !defined(OS_IOS) |
449 // When running the GPU thread in-process, avoid optimistically starting it | 449 // When running the GPU thread in-process, avoid optimistically starting it |
450 // since creating the GPU thread races against creation of the one-and-only | 450 // since creating the GPU thread races against creation of the one-and-only |
451 // ChildProcess instance which is created by the renderer thread. | 451 // ChildProcess instance which is created by the renderer thread. |
452 GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance(); | 452 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed() && |
453 if (gpu_data_manager->GpuAccessAllowed() && | |
454 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && | 453 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && |
455 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && | 454 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && |
456 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { | 455 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { |
457 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); | 456 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); |
458 BrowserThread::PostTask( | 457 BrowserThread::PostTask( |
459 BrowserThread::IO, FROM_HERE, base::Bind( | 458 BrowserThread::IO, FROM_HERE, base::Bind( |
460 base::IgnoreResult(&GpuProcessHost::Get), | 459 base::IgnoreResult(&GpuProcessHost::Get), |
461 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 460 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
462 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | 461 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
463 } | 462 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 644 |
646 #if defined(OS_LINUX) | 645 #if defined(OS_LINUX) |
647 device_monitor_linux_.reset(new DeviceMonitorLinux()); | 646 device_monitor_linux_.reset(new DeviceMonitorLinux()); |
648 #elif defined(OS_MACOSX) | 647 #elif defined(OS_MACOSX) |
649 device_monitor_mac_.reset(new DeviceMonitorMac()); | 648 device_monitor_mac_.reset(new DeviceMonitorMac()); |
650 #endif | 649 #endif |
651 | 650 |
652 // RDH needs the IO thread to be created. | 651 // RDH needs the IO thread to be created. |
653 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 652 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
654 | 653 |
655 // Start the GpuDataManager before we set up the MessageLoops because | 654 // Initialize the GpuDataManager before we set up the MessageLoops because |
656 // otherwise we'll trigger the assertion about doing IO on the UI thread. | 655 // otherwise we'll trigger the assertion about doing IO on the UI thread. |
657 content::GpuDataManager::GetInstance(); | 656 GpuDataManagerImpl::GetInstance()->Initialize(); |
658 #endif // !OS_IOS | 657 #endif // !OS_IOS |
659 | 658 |
660 #if defined(ENABLE_INPUT_SPEECH) | 659 #if defined(ENABLE_INPUT_SPEECH) |
661 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | 660 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); |
662 #endif | 661 #endif |
663 | 662 |
664 // Alert the clipboard class to which threads are allowed to access the | 663 // Alert the clipboard class to which threads are allowed to access the |
665 // clipboard: | 664 // clipboard: |
666 std::vector<base::PlatformThreadId> allowed_clipboard_threads; | 665 std::vector<base::PlatformThreadId> allowed_clipboard_threads; |
667 // The current thread is the UI thread. | 666 // The current thread is the UI thread. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 721 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
723 if (parameters_.ui_task) | 722 if (parameters_.ui_task) |
724 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 723 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
725 | 724 |
726 base::RunLoop run_loop; | 725 base::RunLoop run_loop; |
727 run_loop.Run(); | 726 run_loop.Run(); |
728 #endif | 727 #endif |
729 } | 728 } |
730 | 729 |
731 } // namespace content | 730 } // namespace content |
OLD | NEW |