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

Unified Diff: content/browser/browser_main_runner.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: 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
Index: content/browser/browser_main_runner.cc
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc
index 16309dec8460af490e891e47ace869c483d258c5..7b98d4ac38b85f946e42c44ee9c53adae0fce6d9 100644
--- a/content/browser/browser_main_runner.cc
+++ b/content/browser/browser_main_runner.cc
@@ -130,13 +130,23 @@ class BrowserMainRunnerImpl : public BrowserMainRunner {
// If leaks are found, the process will exit here.
__lsan_do_leak_check();
#endif
+ // If startup tracing has not been finished yet, replace it's dumper.
+ scoped_ptr<BrowserShutdownProfileDumper> startup_profiler;
+ if (main_loop_->is_tracing_startup()) {
+ startup_profiler.reset(
+ new BrowserShutdownProfileDumper(main_loop_->startup_trace_file()));
+ main_loop_->StopStartupTracingTimer();
+ }
+
// The shutdown tracing got enabled in AttemptUserExit earlier, but someone
// needs to write the result to disc. For that a dumper needs to get created
// which will dump the traces to disc when it gets destroyed.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- scoped_ptr<BrowserShutdownProfileDumper> profiler;
- if (command_line.HasSwitch(switches::kTraceShutdown))
- profiler.reset(new BrowserShutdownProfileDumper());
+ scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler;
+ if (command_line.HasSwitch(switches::kTraceShutdown)) {
+ shutdown_profiler.reset(
+ new BrowserShutdownProfileDumper(GetShutdownProfileFileName()));
+ }
{
// The trace event has to stay between profiler creation and destruction.
@@ -159,6 +169,19 @@ class BrowserMainRunnerImpl : public BrowserMainRunner {
}
protected:
+ // Returns the file name where we should save the shutdown trace dump to.
+ static base::FilePath GetShutdownProfileFileName() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ base::FilePath trace_file =
+ command_line.GetSwitchValuePath(switches::kTraceShutdownFile);
+
+ if (!trace_file.empty())
+ return trace_file;
+
+ // Default to saving the startup trace into the current dir.
+ return base::FilePath().AppendASCII("chrometrace.log");
+ }
+
// True if we have started to initialize the runner.
bool initialization_started_;

Powered by Google App Engine
This is Rietveld 408576698