| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "content/browser/histogram_synchronizer.h" | 36 #include "content/browser/histogram_synchronizer.h" |
| 37 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 37 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 38 #include "content/browser/media/capture/audio_mirroring_manager.h" | 38 #include "content/browser/media/capture/audio_mirroring_manager.h" |
| 39 #include "content/browser/media/media_internals.h" | 39 #include "content/browser/media/media_internals.h" |
| 40 #include "content/browser/net/browser_online_state_observer.h" | 40 #include "content/browser/net/browser_online_state_observer.h" |
| 41 #include "content/browser/plugin_service_impl.h" | 41 #include "content/browser/plugin_service_impl.h" |
| 42 #include "content/browser/renderer_host/media/media_stream_manager.h" | 42 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 43 #include "content/browser/speech/speech_recognition_manager_impl.h" | 43 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 44 #include "content/browser/startup_task_runner.h" | 44 #include "content/browser/startup_task_runner.h" |
| 45 #include "content/browser/time_zone_monitor.h" | 45 #include "content/browser/time_zone_monitor.h" |
| 46 #include "content/browser/tracing/add_new_file_index.h" |
| 46 #include "content/browser/webui/content_web_ui_controller_factory.h" | 47 #include "content/browser/webui/content_web_ui_controller_factory.h" |
| 47 #include "content/browser/webui/url_data_manager.h" | 48 #include "content/browser/webui/url_data_manager.h" |
| 48 #include "content/public/browser/browser_main_parts.h" | 49 #include "content/public/browser/browser_main_parts.h" |
| 49 #include "content/public/browser/browser_shutdown.h" | 50 #include "content/public/browser/browser_shutdown.h" |
| 50 #include "content/public/browser/content_browser_client.h" | 51 #include "content/public/browser/content_browser_client.h" |
| 51 #include "content/public/browser/render_process_host.h" | 52 #include "content/public/browser/render_process_host.h" |
| 52 #include "content/public/browser/tracing_controller.h" | 53 #include "content/public/browser/tracing_controller.h" |
| 53 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
| 54 #include "content/public/common/main_function_params.h" | 55 #include "content/public/common/main_function_params.h" |
| 55 #include "content/public/common/result_codes.h" | 56 #include "content/public/common/result_codes.h" |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 URLDataManager::DeleteDataSources(); | 895 URLDataManager::DeleteDataSources(); |
| 895 } | 896 } |
| 896 #endif // !defined(OS_IOS) | 897 #endif // !defined(OS_IOS) |
| 897 | 898 |
| 898 if (parts_) { | 899 if (parts_) { |
| 899 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); | 900 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); |
| 900 parts_->PostDestroyThreads(); | 901 parts_->PostDestroyThreads(); |
| 901 } | 902 } |
| 902 } | 903 } |
| 903 | 904 |
| 905 void BrowserMainLoop::StopStartupTracingTimer() { |
| 906 startup_trace_timer_.Stop(); |
| 907 } |
| 908 |
| 904 void BrowserMainLoop::InitializeMainThread() { | 909 void BrowserMainLoop::InitializeMainThread() { |
| 905 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); | 910 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); |
| 906 const char* kThreadName = "CrBrowserMain"; | 911 const char* kThreadName = "CrBrowserMain"; |
| 907 base::PlatformThread::SetName(kThreadName); | 912 base::PlatformThread::SetName(kThreadName); |
| 908 if (main_message_loop_) | 913 if (main_message_loop_) |
| 909 main_message_loop_->set_thread_name(kThreadName); | 914 main_message_loop_->set_thread_name(kThreadName); |
| 910 | 915 |
| 911 // Register the main thread by instantiating it, but don't call any methods. | 916 // Register the main thread by instantiating it, but don't call any methods. |
| 912 main_thread_.reset( | 917 main_thread_.reset( |
| 913 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); | 918 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1119 |
| 1115 if (trace_file.empty()) { | 1120 if (trace_file.empty()) { |
| 1116 #if defined(OS_ANDROID) | 1121 #if defined(OS_ANDROID) |
| 1117 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); | 1122 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); |
| 1118 #else | 1123 #else |
| 1119 // Default to saving the startup trace into the current dir. | 1124 // Default to saving the startup trace into the current dir. |
| 1120 trace_file = base::FilePath().AppendASCII("chrometrace.log"); | 1125 trace_file = base::FilePath().AppendASCII("chrometrace.log"); |
| 1121 #endif | 1126 #endif |
| 1122 } | 1127 } |
| 1123 | 1128 |
| 1129 if (command_line.HasSwitch(switches::kTraceRotateStartupFile)) |
| 1130 trace_file = AddNewLogFileIndex(trace_file); |
| 1131 |
| 1132 startup_trace_file_ = trace_file; |
| 1133 |
| 1124 std::string delay_str = command_line.GetSwitchValueASCII( | 1134 std::string delay_str = command_line.GetSwitchValueASCII( |
| 1125 switches::kTraceStartupDuration); | 1135 switches::kTraceStartupDuration); |
| 1126 int delay_secs = 5; | 1136 int delay_secs = 5; |
| 1127 if (!delay_str.empty() && !base::StringToInt(delay_str, &delay_secs)) { | 1137 if (!delay_str.empty() && !base::StringToInt(delay_str, &delay_secs)) { |
| 1128 DLOG(WARNING) << "Could not parse --" << switches::kTraceStartupDuration | 1138 DLOG(WARNING) << "Could not parse --" << switches::kTraceStartupDuration |
| 1129 << "=" << delay_str << " defaulting to 5 (secs)"; | 1139 << "=" << delay_str << " defaulting to 5 (secs)"; |
| 1130 delay_secs = 5; | 1140 delay_secs = 5; |
| 1131 } | 1141 } |
| 1132 | 1142 |
| 1133 BrowserThread::PostDelayedTask( | 1143 startup_trace_timer_.Start(FROM_HERE, |
| 1134 BrowserThread::UI, FROM_HERE, | 1144 base::TimeDelta::FromSeconds(delay_secs), |
| 1135 base::Bind(&BrowserMainLoop::EndStartupTracing, | 1145 this, |
| 1136 base::Unretained(this), trace_file), | 1146 &BrowserMainLoop::EndStartupTracing); |
| 1137 base::TimeDelta::FromSeconds(delay_secs)); | |
| 1138 } | 1147 } |
| 1139 | 1148 |
| 1140 void BrowserMainLoop::EndStartupTracing(const base::FilePath& trace_file) { | 1149 void BrowserMainLoop::EndStartupTracing() { |
| 1141 is_tracing_startup_ = false; | 1150 is_tracing_startup_ = false; |
| 1142 TracingController::GetInstance()->DisableRecording( | 1151 TracingController::GetInstance()->DisableRecording( |
| 1143 trace_file, base::Bind(&OnStoppedStartupTracing)); | 1152 startup_trace_file_, base::Bind(&OnStoppedStartupTracing)); |
| 1144 } | 1153 } |
| 1145 | 1154 |
| 1146 } // namespace content | 1155 } // namespace content |
| OLD | NEW |