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

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

Issue 1309243004: Reland again [Startup Tracing] Add --trace-config-file flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test Created 5 years, 3 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/gpu/gpu_process_host.cc » ('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/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/leak_annotations.h" 9 #include "base/debug/leak_annotations.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/statistics_recorder.h" 12 #include "base/metrics/statistics_recorder.h"
13 #include "base/profiler/scoped_profile.h" 13 #include "base/profiler/scoped_profile.h"
14 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "base/tracked_objects.h" 16 #include "base/tracked_objects.h"
17 #include "components/tracing/trace_config_file.h"
17 #include "components/tracing/tracing_switches.h" 18 #include "components/tracing/tracing_switches.h"
18 #include "content/browser/browser_main_loop.h" 19 #include "content/browser/browser_main_loop.h"
19 #include "content/browser/browser_shutdown_profile_dumper.h" 20 #include "content/browser/browser_shutdown_profile_dumper.h"
20 #include "content/browser/notification_service_impl.h" 21 #include "content/browser/notification_service_impl.h"
22 #include "content/public/browser/tracing_controller.h"
21 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
22 #include "content/public/common/main_function_params.h" 24 #include "content/public/common/main_function_params.h"
23 #include "ui/base/ime/input_method_initializer.h" 25 #include "ui/base/ime/input_method_initializer.h"
24 26
27 #if defined(OS_ANDROID)
28 #include "content/browser/android/tracing_controller_android.h"
29 #endif
30
25 #if defined(OS_WIN) 31 #if defined(OS_WIN)
26 #include "base/win/win_util.h" 32 #include "base/win/win_util.h"
27 #include "base/win/windows_version.h" 33 #include "base/win/windows_version.h"
28 #include "net/cert/sha256_legacy_support_win.h" 34 #include "net/cert/sha256_legacy_support_win.h"
29 #include "sandbox/win/src/sidestep/preamble_patcher.h" 35 #include "sandbox/win/src/sidestep/preamble_patcher.h"
30 #include "ui/base/win/scoped_ole_initializer.h" 36 #include "ui/base/win/scoped_ole_initializer.h"
31 #include "ui/gfx/switches.h" 37 #include "ui/gfx/switches.h"
32 #include "ui/gfx/win/direct_write.h" 38 #include "ui/gfx/win/direct_write.h"
33 #endif 39 #endif
34 40
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. 228 // Invoke leak detection now, to avoid dealing with shutdown-only leaks.
223 // Normally this will have already happened in 229 // Normally this will have already happened in
224 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is 230 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is
225 // only for processes which do not instantiate a BrowserProcess. 231 // only for processes which do not instantiate a BrowserProcess.
226 // If leaks are found, the process will exit here. 232 // If leaks are found, the process will exit here.
227 __lsan_do_leak_check(); 233 __lsan_do_leak_check();
228 #endif 234 #endif
229 // If startup tracing has not been finished yet, replace it's dumper 235 // If startup tracing has not been finished yet, replace it's dumper
230 // with special version, which would save trace file on exit (i.e. 236 // with special version, which would save trace file on exit (i.e.
231 // startup tracing becomes a version of shutdown tracing). 237 // startup tracing becomes a version of shutdown tracing).
238 // There are two cases:
239 // 1. Startup duration is not reached.
240 // 2. Or startup duration is not specified for --trace-config-file flag.
232 scoped_ptr<BrowserShutdownProfileDumper> startup_profiler; 241 scoped_ptr<BrowserShutdownProfileDumper> startup_profiler;
233 if (main_loop_->is_tracing_startup()) { 242 if (main_loop_->is_tracing_startup_for_duration()) {
234 main_loop_->StopStartupTracingTimer(); 243 main_loop_->StopStartupTracingTimer();
235 if (main_loop_->startup_trace_file() != 244 if (main_loop_->startup_trace_file() !=
236 base::FilePath().AppendASCII("none")) { 245 base::FilePath().AppendASCII("none")) {
237 startup_profiler.reset( 246 startup_profiler.reset(
238 new BrowserShutdownProfileDumper(main_loop_->startup_trace_file())); 247 new BrowserShutdownProfileDumper(main_loop_->startup_trace_file()));
239 } 248 }
249 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled() &&
250 TracingController::GetInstance()->IsRecording()) {
251 base::FilePath result_file;
252 #if defined(OS_ANDROID)
253 TracingControllerAndroid::GenerateTracingFilePath(&result_file);
254 #else
255 result_file = tracing::TraceConfigFile::GetInstance()->GetResultFile();
256 #endif
257 startup_profiler.reset(new BrowserShutdownProfileDumper(result_file));
240 } 258 }
241 259
242 // The shutdown tracing got enabled in AttemptUserExit earlier, but someone 260 // The shutdown tracing got enabled in AttemptUserExit earlier, but someone
243 // needs to write the result to disc. For that a dumper needs to get created 261 // needs to write the result to disc. For that a dumper needs to get created
244 // which will dump the traces to disc when it gets destroyed. 262 // which will dump the traces to disc when it gets destroyed.
245 const base::CommandLine& command_line = 263 const base::CommandLine& command_line =
246 *base::CommandLine::ForCurrentProcess(); 264 *base::CommandLine::ForCurrentProcess();
247 scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler; 265 scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler;
248 if (command_line.HasSwitch(switches::kTraceShutdown)) { 266 if (command_line.HasSwitch(switches::kTraceShutdown)) {
249 shutdown_profiler.reset(new BrowserShutdownProfileDumper( 267 shutdown_profiler.reset(new BrowserShutdownProfileDumper(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 309
292 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 310 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
293 }; 311 };
294 312
295 // static 313 // static
296 BrowserMainRunner* BrowserMainRunner::Create() { 314 BrowserMainRunner* BrowserMainRunner::Create() {
297 return new BrowserMainRunnerImpl(); 315 return new BrowserMainRunnerImpl();
298 } 316 }
299 317
300 } // namespace content 318 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698