Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: content/browser/browser_main_loop.cc

Issue 311313005: Add --trace-rotate-startup-file option and store unsaved trace data on exit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows build. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698