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

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

Issue 1315463002: [Startup Tracing] Add --trace-config-file flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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).
232 scoped_ptr<BrowserShutdownProfileDumper> startup_profiler; 238 scoped_ptr<BrowserShutdownProfileDumper> startup_profiler;
233 if (main_loop_->is_tracing_startup()) { 239 if (main_loop_->is_tracing_startup_for_duration()) {
234 main_loop_->StopStartupTracingTimer(); 240 main_loop_->StopStartupTracingTimer();
235 if (main_loop_->startup_trace_file() != 241 if (main_loop_->startup_trace_file() !=
236 base::FilePath().AppendASCII("none")) { 242 base::FilePath().AppendASCII("none")) {
237 startup_profiler.reset( 243 startup_profiler.reset(
238 new BrowserShutdownProfileDumper(main_loop_->startup_trace_file())); 244 new BrowserShutdownProfileDumper(main_loop_->startup_trace_file()));
239 } 245 }
246 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled() &&
247 TracingController::GetInstance()->IsRecording()) {
248 base::FilePath result_file;
249 #if defined(OS_ANDROID)
250 TracingControllerAndroid::GenerateTracingFilePath(&result_file);
251 #else
252 result_file = tracing::TraceConfigFile::GetInstance()->GetResultFile();
253 #endif
254 startup_profiler.reset(new BrowserShutdownProfileDumper(result_file));
240 } 255 }
241 256
242 // The shutdown tracing got enabled in AttemptUserExit earlier, but someone 257 // 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 258 // 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. 259 // which will dump the traces to disc when it gets destroyed.
245 const base::CommandLine& command_line = 260 const base::CommandLine& command_line =
246 *base::CommandLine::ForCurrentProcess(); 261 *base::CommandLine::ForCurrentProcess();
247 scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler; 262 scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler;
248 if (command_line.HasSwitch(switches::kTraceShutdown)) { 263 if (command_line.HasSwitch(switches::kTraceShutdown)) {
249 shutdown_profiler.reset(new BrowserShutdownProfileDumper( 264 shutdown_profiler.reset(new BrowserShutdownProfileDumper(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 306
292 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 307 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
293 }; 308 };
294 309
295 // static 310 // static
296 BrowserMainRunner* BrowserMainRunner::Create() { 311 BrowserMainRunner* BrowserMainRunner::Create() {
297 return new BrowserMainRunnerImpl(); 312 return new BrowserMainRunnerImpl();
298 } 313 }
299 314
300 } // namespace content 315 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698