Tracing: startup flags

The GPU process is launched from the IO thread; so, it cannot
access BrowserMainLoop (should be accessed from the UI thread) to
get the status of startup tracing (crbug.com/828993).

This CL simplifies dealing with startup tracing flags by centralizing
the logic in TraceStartupConfig. Then, we can get information about
startup tracing through TraceStartupConfig, only.

Bug: 828993
Change-Id: Ia868fed264b534526ad054414ae2a1e12f5c0ac5
Reviewed-on: https://chromium-review.googlesource.com/1015647
Commit-Queue: Ehsan Chiniforooshan <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: oysteine <[email protected]>
Cr-Commit-Position: refs/heads/master@{#552955}
diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc
index 4ef5e1f..84cf744 100644
--- a/content/browser/browser_child_process_host_impl.cc
+++ b/content/browser/browser_child_process_host_impl.cc
@@ -25,7 +25,7 @@
 #include "base/synchronization/waitable_event.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "build/build_config.h"
-#include "components/tracing/common/trace_config_file.h"
+#include "components/tracing/common/trace_startup_config.h"
 #include "components/tracing/common/tracing_switches.h"
 #include "content/browser/bad_message.h"
 #include "content/browser/browser_main_loop.h"
@@ -213,24 +213,9 @@
 // static
 void BrowserChildProcessHostImpl::CopyTraceStartupFlags(
     base::CommandLine* cmd_line) {
-  const base::CommandLine& browser_cmd_line =
-      *base::CommandLine::ForCurrentProcess();
-
-  if (browser_cmd_line.HasSwitch(switches::kTraceStartup) &&
-      BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) {
-    // Pass kTraceStartup switch to renderer only if startup tracing has not
-    // finished.
-    cmd_line->AppendSwitchASCII(
-        switches::kTraceStartup,
-        browser_cmd_line.GetSwitchValueASCII(switches::kTraceStartup));
-    if (browser_cmd_line.HasSwitch(switches::kTraceStartupRecordMode)) {
-      cmd_line->AppendSwitchASCII(switches::kTraceStartupRecordMode,
-                                  browser_cmd_line.GetSwitchValueASCII(
-                                      switches::kTraceStartupRecordMode));
-    }
-  } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
+  if (tracing::TraceStartupConfig::GetInstance()->IsEnabled()) {
     const auto trace_config =
-        tracing::TraceConfigFile::GetInstance()->GetTraceConfig();
+        tracing::TraceStartupConfig::GetInstance()->GetTraceConfig();
     if (!trace_config.IsArgumentFilterEnabled()) {
       // The only trace option that we can pass through switches is the record
       // mode. Other trace options should have the default value.