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

Side by Side Diff: content/browser/browser_main_runner.cc

Issue 359473006: Store unsaved trace data on exit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build. Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/browser_shutdown_profile_dumper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/public/browser/browser_main_runner.h" 5 #include "content/public/browser/browser_main_runner.h"
6 6
7 #include "base/allocator/allocator_shim.h" 7 #include "base/allocator/allocator_shim.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 DCHECK(initialization_started_); 123 DCHECK(initialization_started_);
124 DCHECK(!is_shutdown_); 124 DCHECK(!is_shutdown_);
125 #ifdef LEAK_SANITIZER 125 #ifdef LEAK_SANITIZER
126 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. 126 // Invoke leak detection now, to avoid dealing with shutdown-only leaks.
127 // Normally this will have already happened in 127 // Normally this will have already happened in
128 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is 128 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is
129 // only for processes which do not instantiate a BrowserProcess. 129 // only for processes which do not instantiate a BrowserProcess.
130 // If leaks are found, the process will exit here. 130 // If leaks are found, the process will exit here.
131 __lsan_do_leak_check(); 131 __lsan_do_leak_check();
132 #endif 132 #endif
133 // If startup tracing has not been finished yet, replace it's dumper
134 // with special version, which would save trace file on exit (i.e.
135 // startup tracing becomes a version of shutdown tracing).
136 scoped_ptr<BrowserShutdownProfileDumper> startup_profiler;
137 if (main_loop_->is_tracing_startup()) {
138 main_loop_->StopStartupTracingTimer();
139 if (main_loop_->startup_trace_file() !=
140 base::FilePath().AppendASCII("none")) {
141 startup_profiler.reset(
142 new BrowserShutdownProfileDumper(main_loop_->startup_trace_file()));
143 }
144 }
145
133 // The shutdown tracing got enabled in AttemptUserExit earlier, but someone 146 // The shutdown tracing got enabled in AttemptUserExit earlier, but someone
134 // needs to write the result to disc. For that a dumper needs to get created 147 // needs to write the result to disc. For that a dumper needs to get created
135 // which will dump the traces to disc when it gets destroyed. 148 // which will dump the traces to disc when it gets destroyed.
136 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 149 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
137 scoped_ptr<BrowserShutdownProfileDumper> profiler; 150 scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler;
138 if (command_line.HasSwitch(switches::kTraceShutdown)) 151 if (command_line.HasSwitch(switches::kTraceShutdown)) {
139 profiler.reset(new BrowserShutdownProfileDumper()); 152 shutdown_profiler.reset(new BrowserShutdownProfileDumper(
153 BrowserShutdownProfileDumper::GetShutdownProfileFileName()));
154 }
140 155
141 { 156 {
142 // The trace event has to stay between profiler creation and destruction. 157 // The trace event has to stay between profiler creation and destruction.
143 TRACE_EVENT0("shutdown", "BrowserMainRunner"); 158 TRACE_EVENT0("shutdown", "BrowserMainRunner");
144 g_exited_main_message_loop = true; 159 g_exited_main_message_loop = true;
145 160
146 main_loop_->ShutdownThreadsAndCleanUp(); 161 main_loop_->ShutdownThreadsAndCleanUp();
147 162
148 ui::ShutdownInputMethod(); 163 ui::ShutdownInputMethod();
149 #if defined(OS_WIN) 164 #if defined(OS_WIN)
(...skipping 28 matching lines...) Expand all
178 193
179 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 194 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
180 }; 195 };
181 196
182 // static 197 // static
183 BrowserMainRunner* BrowserMainRunner::Create() { 198 BrowserMainRunner* BrowserMainRunner::Create() {
184 return new BrowserMainRunnerImpl(); 199 return new BrowserMainRunnerImpl();
185 } 200 }
186 201
187 } // namespace content 202 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/browser_shutdown_profile_dumper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698