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/pending_task.h" | 15 #include "base/pending_task.h" |
16 #include "base/power_monitor/power_monitor.h" | 16 #include "base/power_monitor/power_monitor.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/system_monitor/system_monitor.h" | 19 #include "base/system_monitor/system_monitor.h" |
20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
21 #include "content/browser/browser_thread_impl.h" | 21 #include "content/browser/browser_thread_impl.h" |
22 #include "content/browser/download/save_file_manager.h" | 22 #include "content/browser/download/save_file_manager.h" |
23 #include "content/browser/gamepad/gamepad_service.h" | 23 #include "content/browser/gamepad/gamepad_service.h" |
24 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 24 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
25 #include "content/browser/gpu/gpu_data_manager_impl.h" | 25 #include "content/browser/gpu/gpu_data_manager_impl.h" |
26 #include "content/browser/gpu/gpu_process_host.h" | 26 #include "content/browser/gpu/gpu_process_host.h" |
27 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 27 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
28 #include "content/browser/histogram_synchronizer.h" | 28 #include "content/browser/histogram_synchronizer.h" |
29 #include "content/browser/in_process_webkit/webkit_thread.h" | 29 #include "content/browser/in_process_webkit/webkit_thread.h" |
| 30 #include "content/browser/indexed_db/indexed_db_thread.h" |
30 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 31 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
31 #include "content/browser/net/browser_online_state_observer.h" | 32 #include "content/browser/net/browser_online_state_observer.h" |
32 #include "content/browser/plugin_service_impl.h" | 33 #include "content/browser/plugin_service_impl.h" |
33 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" | 34 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" |
34 #include "content/browser/renderer_host/media/media_stream_manager.h" | 35 #include "content/browser/renderer_host/media/media_stream_manager.h" |
35 #include "content/browser/speech/speech_recognition_manager_impl.h" | 36 #include "content/browser/speech/speech_recognition_manager_impl.h" |
36 #include "content/browser/tracing/trace_controller_impl.h" | 37 #include "content/browser/tracing/trace_controller_impl.h" |
37 #include "content/browser/webui/content_web_ui_controller_factory.h" | 38 #include "content/browser/webui/content_web_ui_controller_factory.h" |
38 #include "content/browser/webui/url_data_manager.h" | 39 #include "content/browser/webui/url_data_manager.h" |
39 #include "content/public/browser/browser_main_parts.h" | 40 #include "content/public/browser/browser_main_parts.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 media::AudioManager* BrowserMainLoop::GetAudioManager() { | 281 media::AudioManager* BrowserMainLoop::GetAudioManager() { |
281 return g_current_browser_main_loop->audio_manager_.get(); | 282 return g_current_browser_main_loop->audio_manager_.get(); |
282 } | 283 } |
283 | 284 |
284 // static | 285 // static |
285 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() { | 286 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() { |
286 return g_current_browser_main_loop->audio_mirroring_manager_.get(); | 287 return g_current_browser_main_loop->audio_mirroring_manager_.get(); |
287 } | 288 } |
288 | 289 |
289 // static | 290 // static |
| 291 IndexedDBThread* BrowserMainLoop::GetIndexedDBThread() { |
| 292 return g_current_browser_main_loop ? |
| 293 g_current_browser_main_loop->indexed_db_thread_.get() : NULL; |
| 294 } |
| 295 |
| 296 // static |
290 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { | 297 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { |
291 return g_current_browser_main_loop->media_stream_manager_.get(); | 298 return g_current_browser_main_loop->media_stream_manager_.get(); |
292 } | 299 } |
293 // BrowserMainLoop construction / destruction ============================= | 300 // BrowserMainLoop construction / destruction ============================= |
294 | 301 |
295 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) | 302 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) |
296 : parameters_(parameters), | 303 : parameters_(parameters), |
297 parsed_command_line_(parameters.command_line), | 304 parsed_command_line_(parameters.command_line), |
298 result_code_(RESULT_CODE_NORMAL_EXIT) { | 305 result_code_(RESULT_CODE_NORMAL_EXIT) { |
299 DCHECK(!g_current_browser_main_loop); | 306 DCHECK(!g_current_browser_main_loop); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 (*thread_to_start).reset(new BrowserProcessSubThread(id)); | 598 (*thread_to_start).reset(new BrowserProcessSubThread(id)); |
592 (*thread_to_start)->StartWithOptions(*options); | 599 (*thread_to_start)->StartWithOptions(*options); |
593 } else { | 600 } else { |
594 NOTREACHED(); | 601 NOTREACHED(); |
595 } | 602 } |
596 | 603 |
597 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); | 604 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); |
598 | 605 |
599 } | 606 } |
600 | 607 |
| 608 #if !defined(OS_IOS) |
| 609 indexed_db_thread_.reset(new IndexedDBThread()); |
| 610 #endif |
| 611 |
601 BrowserThreadsStarted(); | 612 BrowserThreadsStarted(); |
602 | 613 |
603 if (parts_) { | 614 if (parts_) { |
604 TRACE_EVENT0("startup", | 615 TRACE_EVENT0("startup", |
605 "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); | 616 "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); |
606 parts_->PreMainMessageLoopRun(); | 617 parts_->PreMainMessageLoopRun(); |
607 } | 618 } |
608 | 619 |
609 // If the UI thread blocks, the whole UI is unresponsive. | 620 // If the UI thread blocks, the whole UI is unresponsive. |
610 // Do not allow disk IO from the UI thread. | 621 // Do not allow disk IO from the UI thread. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 if (parameters_.ui_task) | 928 if (parameters_.ui_task) |
918 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 929 base::MessageLoopForUI::current()->PostTask(FROM_HERE, |
919 *parameters_.ui_task); | 930 *parameters_.ui_task); |
920 | 931 |
921 base::RunLoop run_loop; | 932 base::RunLoop run_loop; |
922 run_loop.Run(); | 933 run_loop.Run(); |
923 #endif | 934 #endif |
924 } | 935 } |
925 | 936 |
926 } // namespace content | 937 } // namespace content |
OLD | NEW |