| 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/save_file_manager.h" | 19 #include "content/browser/download/save_file_manager.h" |
| 20 #include "content/browser/gamepad/gamepad_service.h" | 20 #include "content/browser/gamepad/gamepad_service.h" |
| 21 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 21 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 22 #include "content/browser/gpu/gpu_data_manager_impl.h" | 22 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 23 #include "content/browser/gpu/gpu_process_host.h" | 23 #include "content/browser/gpu/gpu_process_host.h" |
| 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 25 #include "content/browser/histogram_synchronizer.h" | 25 #include "content/browser/histogram_synchronizer.h" |
| 26 #include "content/browser/in_process_webkit/webkit_thread.h" | 26 #include "content/browser/in_process_webkit/webkit_thread.h" |
| 27 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 27 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 28 #include "content/browser/net/browser_online_state_observer.h" | 28 #include "content/browser/net/browser_online_state_observer.h" |
| 29 #include "content/browser/plugin_service_impl.h" | 29 #include "content/browser/plugin_service_impl.h" |
| 30 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" |
| 30 #include "content/browser/renderer_host/media/media_stream_manager.h" | 31 #include "content/browser/renderer_host/media/media_stream_manager.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/compositor_util.h" | 36 #include "content/public/browser/compositor_util.h" |
| 36 #include "content/public/browser/content_browser_client.h" | 37 #include "content/public/browser/content_browser_client.h" |
| 37 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
| 38 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
| 39 #include "content/public/common/main_function_params.h" | 40 #include "content/public/common/main_function_params.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void ImmediateShutdownAndExitProcess() { | 221 void ImmediateShutdownAndExitProcess() { |
| 221 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); | 222 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); |
| 222 } | 223 } |
| 223 | 224 |
| 224 // static | 225 // static |
| 225 media::AudioManager* BrowserMainLoop::GetAudioManager() { | 226 media::AudioManager* BrowserMainLoop::GetAudioManager() { |
| 226 return g_current_browser_main_loop->audio_manager_.get(); | 227 return g_current_browser_main_loop->audio_manager_.get(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 // static | 230 // static |
| 231 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() { |
| 232 return g_current_browser_main_loop->audio_mirroring_manager_.get(); |
| 233 } |
| 234 |
| 235 // static |
| 230 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { | 236 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { |
| 231 return g_current_browser_main_loop->media_stream_manager_.get(); | 237 return g_current_browser_main_loop->media_stream_manager_.get(); |
| 232 } | 238 } |
| 233 // BrowserMainLoop construction / destruction ============================= | 239 // BrowserMainLoop construction / destruction ============================= |
| 234 | 240 |
| 235 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) | 241 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) |
| 236 : parameters_(parameters), | 242 : parameters_(parameters), |
| 237 parsed_command_line_(parameters.command_line), | 243 parsed_command_line_(parameters.command_line), |
| 238 result_code_(RESULT_CODE_NORMAL_EXIT) { | 244 result_code_(RESULT_CODE_NORMAL_EXIT) { |
| 239 DCHECK(!g_current_browser_main_loop); | 245 DCHECK(!g_current_browser_main_loop); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // Create a MessageLoop if one does not already exist for the current thread. | 342 // Create a MessageLoop if one does not already exist for the current thread. |
| 337 if (!MessageLoop::current()) | 343 if (!MessageLoop::current()) |
| 338 main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); | 344 main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); |
| 339 | 345 |
| 340 InitializeMainThread(); | 346 InitializeMainThread(); |
| 341 | 347 |
| 342 system_monitor_.reset(new base::SystemMonitor); | 348 system_monitor_.reset(new base::SystemMonitor); |
| 343 hi_res_timer_manager_.reset(new HighResolutionTimerManager); | 349 hi_res_timer_manager_.reset(new HighResolutionTimerManager); |
| 344 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 350 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 345 audio_manager_.reset(media::AudioManager::Create()); | 351 audio_manager_.reset(media::AudioManager::Create()); |
| 352 audio_mirroring_manager_.reset(new AudioMirroringManager()); |
| 346 | 353 |
| 347 #if !defined(OS_IOS) | 354 #if !defined(OS_IOS) |
| 348 // Start tracing to a file if needed. | 355 // Start tracing to a file if needed. |
| 349 if (base::debug::TraceLog::GetInstance()->IsEnabled()) { | 356 if (base::debug::TraceLog::GetInstance()->IsEnabled()) { |
| 350 TraceControllerImpl::GetInstance()->InitStartupTracing( | 357 TraceControllerImpl::GetInstance()->InitStartupTracing( |
| 351 parsed_command_line_); | 358 parsed_command_line_); |
| 352 } | 359 } |
| 353 | 360 |
| 354 online_state_observer_.reset(new BrowserOnlineStateObserver); | 361 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 355 #endif // !defined(OS_IOS) | 362 #endif // !defined(OS_IOS) |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 754 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 748 if (parameters_.ui_task) | 755 if (parameters_.ui_task) |
| 749 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 756 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
| 750 | 757 |
| 751 base::RunLoop run_loop; | 758 base::RunLoop run_loop; |
| 752 run_loop.Run(); | 759 run_loop.Run(); |
| 753 #endif | 760 #endif |
| 754 } | 761 } |
| 755 | 762 |
| 756 } // namespace content | 763 } // namespace content |
| OLD | NEW |