Index: content/browser/browser_main_loop.cc |
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc |
index 6aef2203bc85693c3124773b35134905b5bf99c7..5dc67c26aedf73d6d5047ea0ac712c222b7aa418 100644 |
--- a/content/browser/browser_main_loop.cc |
+++ b/content/browser/browser_main_loop.cc |
@@ -43,6 +43,7 @@ |
#include "content/browser/speech/speech_recognition_manager_impl.h" |
#include "content/browser/startup_task_runner.h" |
#include "content/browser/time_zone_monitor.h" |
+#include "content/browser/tracing/add_new_file_index.h" |
#include "content/browser/webui/content_web_ui_controller_factory.h" |
#include "content/browser/webui/url_data_manager.h" |
#include "content/public/browser/browser_main_parts.h" |
@@ -339,6 +340,9 @@ void BrowserMainLoop::EarlyInitialization() { |
SetupSandbox(parsed_command_line_); |
#endif |
+ if (is_tracing_startup_) |
+ startup_trace_file_ = GetStartupTraceFileName(parsed_command_line_); |
+ |
#if defined(USE_X11) |
if (parsed_command_line_.HasSwitch(switches::kSingleProcess) || |
parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { |
@@ -901,6 +905,10 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { |
} |
} |
+void BrowserMainLoop::StopStartupTracingTimer() { |
+ startup_trace_timer_.Stop(); |
+} |
+ |
void BrowserMainLoop::InitializeMainThread() { |
TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); |
const char* kThreadName = "CrBrowserMain"; |
@@ -1101,16 +1109,15 @@ void BrowserMainLoop::MainMessageLoopRun() { |
#endif |
} |
-void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) { |
- DCHECK(is_tracing_startup_); |
- |
+base::FilePath BrowserMainLoop::GetStartupTraceFileName( |
+ const base::CommandLine& command_line) const { |
base::FilePath trace_file = command_line.GetSwitchValuePath( |
switches::kTraceStartupFile); |
// trace_file = "none" means that startup events will show up for the next |
// begin/end tracing (via about:tracing or AutomationProxy::BeginTracing/ |
// EndTracing, for example). |
if (trace_file == base::FilePath().AppendASCII("none")) |
- return; |
+ return trace_file; |
if (trace_file.empty()) { |
#if defined(OS_ANDROID) |
@@ -1121,6 +1128,15 @@ void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) { |
#endif |
} |
+ if (command_line.HasSwitch(switches::kTraceRotateStartupFile)) |
+ trace_file = AddNewLogFileIndex(trace_file); |
+ |
+ return trace_file; |
+} |
+ |
+void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) { |
+ DCHECK(is_tracing_startup_); |
+ |
std::string delay_str = command_line.GetSwitchValueASCII( |
switches::kTraceStartupDuration); |
int delay_secs = 5; |
@@ -1130,17 +1146,16 @@ void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) { |
delay_secs = 5; |
} |
- BrowserThread::PostDelayedTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&BrowserMainLoop::EndStartupTracing, |
- base::Unretained(this), trace_file), |
- base::TimeDelta::FromSeconds(delay_secs)); |
+ startup_trace_timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromSeconds(delay_secs), |
+ this, |
+ &BrowserMainLoop::EndStartupTracing); |
} |
-void BrowserMainLoop::EndStartupTracing(const base::FilePath& trace_file) { |
+void BrowserMainLoop::EndStartupTracing() { |
is_tracing_startup_ = false; |
TracingController::GetInstance()->DisableRecording( |
- trace_file, base::Bind(&OnStoppedStartupTracing)); |
+ startup_trace_file_, base::Bind(&OnStoppedStartupTracing)); |
} |
} // namespace content |