summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/app/android/library_loader_hooks.cc8
-rw-r--r--content/app/content_main_runner.cc10
-rw-r--r--content/browser/browser_main_loop.cc70
-rw-r--r--content/browser/browser_main_loop.h12
-rw-r--r--content/browser/browser_main_runner.cc20
-rw-r--r--content/browser/gpu/gpu_process_host.cc1
-rw-r--r--content/browser/plugin_process_host.cc1
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc3
8 files changed, 85 insertions, 40 deletions
diff --git a/content/app/android/library_loader_hooks.cc b/content/app/android/library_loader_hooks.cc
index 39ef2b0..2a1a3df 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -16,7 +16,7 @@
#include "base/strings/string_util.h"
#include "base/trace_event/trace_event.h"
#include "base/tracked_objects.h"
-#include "components/tracing/startup_tracing.h"
+#include "components/tracing/trace_config_file.h"
#include "components/tracing/tracing_switches.h"
#include "content/app/android/app_jni_registrar.h"
#include "content/browser/android/browser_jni_registrar.h"
@@ -94,7 +94,11 @@ bool LibraryLoaded(JNIEnv* env, jclass clazz) {
base::trace_event::TraceLog::GetInstance()->SetEnabled(
trace_config, base::trace_event::TraceLog::RECORDING_MODE);
} else {
- tracing::EnableStartupTracingIfConfigFileExists();
+ if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
+ base::trace_event::TraceLog::GetInstance()->SetEnabled(
+ tracing::TraceConfigFile::GetInstance()->GetTraceConfig(),
+ base::trace_event::TraceLog::RECORDING_MODE);
+ }
}
// Android's main browser loop is custom so we set the browser
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 1a5e950..f35ed29 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -28,7 +28,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h"
-#include "components/tracing/startup_tracing.h"
+#include "components/tracing/trace_config_file.h"
#include "components/tracing/tracing_switches.h"
#include "content/browser/browser_main.h"
#include "content/common/set_process_title.h"
@@ -629,9 +629,11 @@ class ContentMainRunnerImpl : public ContentMainRunner {
base::trace_event::TraceLog::RECORDING_MODE);
} else if (process_type != switches::kZygoteProcess &&
process_type != switches::kRendererProcess) {
- // There is no need to schedule stopping tracing in this case. Telemetry
- // will stop tracing on demand later.
- tracing::EnableStartupTracingIfConfigFileExists();
+ if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
+ base::trace_event::TraceLog::GetInstance()->SetEnabled(
+ tracing::TraceConfigFile::GetInstance()->GetTraceConfig(),
+ base::trace_event::TraceLog::RECORDING_MODE);
+ }
}
#if defined(OS_WIN)
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index b5159df..df19ee8 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -26,6 +26,7 @@
#include "base/timer/hi_res_timer_manager.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
+#include "components/tracing/trace_config_file.h"
#include "components/tracing/tracing_switches.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/device_sensors/device_inertial_sensor_service.h"
@@ -390,9 +391,11 @@ BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters)
result_code_(RESULT_CODE_NORMAL_EXIT),
created_threads_(false),
// ContentMainRunner should have enabled tracing of the browser process
- // when kTraceStartup is in the command line.
- is_tracing_startup_(
- parameters.command_line.HasSwitch(switches::kTraceStartup)) {
+ // when kTraceStartup or kTraceConfigFile is in the command line.
+ is_tracing_startup_for_duration_(
+ parameters.command_line.HasSwitch(switches::kTraceStartup) ||
+ (tracing::TraceConfigFile::GetInstance()->IsEnabled() &&
+ tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) {
DCHECK(!g_current_browser_main_loop);
g_current_browser_main_loop = this;
}
@@ -578,9 +581,9 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
// Start tracing to a file if needed. Only do this after starting the main
// message loop to avoid calling MessagePumpForUI::ScheduleWork() before
// MessagePumpForUI::Start() as it will crash the browser.
- if (is_tracing_startup_) {
- TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing");
- InitStartupTracing(parsed_command_line_);
+ if (is_tracing_startup_for_duration_) {
+ TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration");
+ InitStartupTracingForDuration(parsed_command_line_);
}
#endif // !defined(OS_IOS)
@@ -1316,39 +1319,52 @@ void BrowserMainLoop::MainMessageLoopRun() {
base::FilePath BrowserMainLoop::GetStartupTraceFileName(
const base::CommandLine& command_line) const {
- 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 trace_file;
-
- if (trace_file.empty()) {
+ base::FilePath trace_file;
+ if (command_line.HasSwitch(switches::kTraceStartup)) {
+ 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 trace_file;
+
+ if (trace_file.empty()) {
+#if defined(OS_ANDROID)
+ TracingControllerAndroid::GenerateTracingFilePath(&trace_file);
+#else
+ // Default to saving the startup trace into the current dir.
+ trace_file = base::FilePath().AppendASCII("chrometrace.log");
+#endif
+ }
+ } else {
#if defined(OS_ANDROID)
TracingControllerAndroid::GenerateTracingFilePath(&trace_file);
#else
- // Default to saving the startup trace into the current dir.
- trace_file = base::FilePath().AppendASCII("chrometrace.log");
+ trace_file = tracing::TraceConfigFile::GetInstance()->GetResultFile();
#endif
}
return trace_file;
}
-void BrowserMainLoop::InitStartupTracing(
+void BrowserMainLoop::InitStartupTracingForDuration(
const base::CommandLine& command_line) {
- DCHECK(is_tracing_startup_);
+ DCHECK(is_tracing_startup_for_duration_);
startup_trace_file_ = GetStartupTraceFileName(parsed_command_line_);
- 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;
+ if (command_line.HasSwitch(switches::kTraceStartup)) {
+ std::string delay_str = command_line.GetSwitchValueASCII(
+ switches::kTraceStartupDuration);
+ 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;
+ }
+ } else {
+ delay_secs = tracing::TraceConfigFile::GetInstance()->GetStartupDuration();
}
startup_trace_timer_.Start(FROM_HERE,
@@ -1358,9 +1374,9 @@ void BrowserMainLoop::InitStartupTracing(
}
void BrowserMainLoop::EndStartupTracing() {
- DCHECK(is_tracing_startup_);
+ DCHECK(is_tracing_startup_for_duration_);
- is_tracing_startup_ = false;
+ is_tracing_startup_for_duration_ = false;
TracingController::GetInstance()->DisableRecording(
TracingController::CreateFileSink(
startup_trace_file_,
diff --git a/content/browser/browser_main_loop.h b/content/browser/browser_main_loop.h
index 5f87e69..822589e7 100644
--- a/content/browser/browser_main_loop.h
+++ b/content/browser/browser_main_loop.h
@@ -116,7 +116,9 @@ class CONTENT_EXPORT BrowserMainLoop {
media::midi::MidiManager* midi_manager() const { return midi_manager_.get(); }
base::Thread* indexed_db_thread() const { return indexed_db_thread_.get(); }
- bool is_tracing_startup() const { return is_tracing_startup_; }
+ bool is_tracing_startup_for_duration() const {
+ return is_tracing_startup_for_duration_;
+ }
const base::FilePath& startup_trace_file() const {
return startup_trace_file_;
@@ -152,7 +154,7 @@ class CONTENT_EXPORT BrowserMainLoop {
base::FilePath GetStartupTraceFileName(
const base::CommandLine& command_line) const;
- void InitStartupTracing(const base::CommandLine& command_line);
+ void InitStartupTracingForDuration(const base::CommandLine& command_line);
void EndStartupTracing();
bool UsingInProcessGpu() const;
@@ -166,7 +168,7 @@ class CONTENT_EXPORT BrowserMainLoop {
// MainMessageLoopStart()
// InitializeMainThread()
// PostMainMessageLoopStart()
- // InitStartupTracing()
+ // InitStartupTracingForDuration()
// CreateStartupTasks()
// PreCreateThreads()
// CreateThreads()
@@ -177,7 +179,7 @@ class CONTENT_EXPORT BrowserMainLoop {
const base::CommandLine& parsed_command_line_;
int result_code_;
bool created_threads_; // True if the non-UI threads were created.
- bool is_tracing_startup_;
+ bool is_tracing_startup_for_duration_;
// Members initialized in |MainMessageLoopStart()| ---------------------------
scoped_ptr<base::MessageLoop> main_message_loop_;
@@ -206,7 +208,7 @@ class CONTENT_EXPORT BrowserMainLoop {
scoped_ptr<MemoryObserver> memory_observer_;
scoped_ptr<base::trace_event::TraceMemoryController> trace_memory_controller_;
- // Members initialized in |InitStartupTracing()| -----------------------------
+ // Members initialized in |InitStartupTracingForDuration()| ------------------
base::FilePath startup_trace_file_;
// This timer initiates trace file saving.
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc
index d7575f6..5b2f7f5 100644
--- a/content/browser/browser_main_runner.cc
+++ b/content/browser/browser_main_runner.cc
@@ -14,14 +14,20 @@
#include "base/profiler/scoped_tracker.h"
#include "base/trace_event/trace_event.h"
#include "base/tracked_objects.h"
+#include "components/tracing/trace_config_file.h"
#include "components/tracing/tracing_switches.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/browser_shutdown_profile_dumper.h"
#include "content/browser/notification_service_impl.h"
+#include "content/public/browser/tracing_controller.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "ui/base/ime/input_method_initializer.h"
+#if defined(OS_ANDROID)
+#include "content/browser/android/tracing_controller_android.h"
+#endif
+
#if defined(OS_WIN)
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
@@ -229,14 +235,26 @@ class BrowserMainRunnerImpl : public BrowserMainRunner {
// If startup tracing has not been finished yet, replace it's dumper
// with special version, which would save trace file on exit (i.e.
// startup tracing becomes a version of shutdown tracing).
+ // There are two cases:
+ // 1. Startup duration is not reached.
+ // 2. Or startup duration is not specified for --trace-config-file flag.
scoped_ptr<BrowserShutdownProfileDumper> startup_profiler;
- if (main_loop_->is_tracing_startup()) {
+ if (main_loop_->is_tracing_startup_for_duration()) {
main_loop_->StopStartupTracingTimer();
if (main_loop_->startup_trace_file() !=
base::FilePath().AppendASCII("none")) {
startup_profiler.reset(
new BrowserShutdownProfileDumper(main_loop_->startup_trace_file()));
}
+ } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled() &&
+ TracingController::GetInstance()->IsRecording()) {
+ base::FilePath result_file;
+#if defined(OS_ANDROID)
+ TracingControllerAndroid::GenerateTracingFilePath(&result_file);
+#else
+ result_file = tracing::TraceConfigFile::GetInstance()->GetResultFile();
+#endif
+ startup_profiler.reset(new BrowserShutdownProfileDumper(result_file));
}
// The shutdown tracing got enabled in AttemptUserExit earlier, but someone
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 4c05b63..30446d2 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -113,6 +113,7 @@ static const char* const kSwitchNames[] = {
switches::kNoSandbox,
switches::kProfilerTiming,
switches::kTestGLLib,
+ switches::kTraceConfigFile,
switches::kTraceStartup,
switches::kTraceToConsole,
switches::kV,
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc
index 61deb77..3d73d26 100644
--- a/content/browser/plugin_process_host.cc
+++ b/content/browser/plugin_process_host.cc
@@ -222,6 +222,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info) {
switches::kLogPluginMessages,
switches::kNoSandbox,
switches::kPluginStartupDialog,
+ switches::kTraceConfigFile,
switches::kTraceStartup,
switches::kUseGL,
switches::kForceDeviceScaleFactor,
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 48665d5..0a8a297 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1349,6 +1349,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kTestType,
switches::kTouchEvents,
switches::kTouchTextSelectionStrategy,
+ switches::kTraceConfigFile,
switches::kTraceToConsole,
// This flag needs to be propagated to the renderer process for
// --in-process-webgl.
@@ -1418,7 +1419,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
arraysize(kSwitchNames));
if (browser_cmd.HasSwitch(switches::kTraceStartup) &&
- BrowserMainLoop::GetInstance()->is_tracing_startup()) {
+ BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) {
// Pass kTraceStartup switch to renderer only if startup tracing has not
// finished.
renderer_cmd->AppendSwitchASCII(