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

Unified Diff: content/browser/browser_main_loop.cc

Issue 65343006: Use TracingController for startup tracing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/renderer_host/render_process_host_impl.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 89f30216577e6f55b4510735afc68e62a368f71d..b6db2c7fef962e3f0547a03aa3cac3ed062a3c07 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -41,13 +41,13 @@
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/speech/speech_recognition_manager_impl.h"
#include "content/browser/startup_task_runner.h"
-#include "content/browser/tracing/trace_controller_impl.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"
#include "content/public/browser/browser_shutdown.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/tracing_controller.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/result_codes.h"
@@ -318,7 +318,10 @@ BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters)
: parameters_(parameters),
parsed_command_line_(parameters.command_line),
result_code_(RESULT_CODE_NORMAL_EXIT),
- created_threads_(false) {
+ created_threads_(false),
+ // ContentMainRunner should have enabled tracing of the browser process
+ // when kTraceStartup is in the command line.
+ is_tracing_startup_(base::debug::TraceLog::GetInstance()->IsEnabled()) {
DCHECK(!g_current_browser_main_loop);
g_current_browser_main_loop = this;
}
@@ -474,10 +477,9 @@ void BrowserMainLoop::MainMessageLoopStart() {
}
// Start tracing to a file if needed.
- if (base::debug::TraceLog::GetInstance()->IsEnabled()) {
+ if (is_tracing_startup_) {
TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing")
- TraceControllerImpl::GetInstance()->InitStartupTracing(
- parsed_command_line_);
+ InitStartupTracing(parsed_command_line_);
}
{
@@ -1074,4 +1076,42 @@ void BrowserMainLoop::MainMessageLoopRun() {
#endif
}
+void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) {
+ DCHECK(is_tracing_startup_);
+
+ 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;
+
+ if (trace_file.empty()) {
+ // Default to saving the startup trace into the current dir.
+ trace_file = base::FilePath().AppendASCII("chrometrace.log");
+ }
+
+ std::string delay_str = command_line.GetSwitchValueASCII(
+ switches::kTraceStartupDuration);
+ int delay_secs = 5;
+ if (!delay_str.empty() && !base::StringToInt(delay_str, &delay_secs)) {
+ DLOG(WARNING) << "Could not parse --" << switches::kTraceStartupDuration
+ << "=" << delay_str << " defaulting to 5 (secs)";
+ delay_secs = 5;
+ }
+
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&BrowserMainLoop::EndStartupTracing,
+ base::Unretained(this), trace_file),
+ base::TimeDelta::FromSeconds(delay_secs));
+}
+
+void BrowserMainLoop::EndStartupTracing(const base::FilePath& trace_file) {
+ is_tracing_startup_ = false;
+ TracingController::GetInstance()->DisableRecording(
+ trace_file, TracingController::TracingFileResultCallback());
+}
+
} // namespace content
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698