Make flow event traces disabled-by-default

Currently all flow events are in the category "toplevel.flow", they originated from "ipc" and "task" categories.

BUG=338427

Review URL: https://codereview.chromium.org/148173011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249450 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 0f73535a2ddcfdbc83b2eb3a5ec7912b59412f5c
diff --git a/base/debug/trace_event_memory.cc b/base/debug/trace_event_memory.cc
index 4b2b050..3c46827 100644
--- a/base/debug/trace_event_memory.cc
+++ b/base/debug/trace_event_memory.cc
@@ -409,9 +409,9 @@
 
     // TODO(jamescook): Report the trace category and name separately to the
     // trace viewer and allow it to decide what decorations to apply. For now
-    // just hard-code a decoration for posted tasks.
+    // just hard-code a decoration for posted tasks (toplevel).
     std::string trace_string(trace_name);
-    if (!strcmp(trace_category, "task"))
+    if (!strcmp(trace_category, "toplevel"))
       trace_string.append("->PostTask");
 
     // Some trace name strings have double quotes, convert them to single.
diff --git a/base/debug/trace_event_memory_unittest.cc b/base/debug/trace_event_memory_unittest.cc
index c0a1568..3f5cad3 100644
--- a/base/debug/trace_event_memory_unittest.cc
+++ b/base/debug/trace_event_memory_unittest.cc
@@ -164,10 +164,10 @@
       AppendHeapProfileLineAsTraceFormat(input.str().c_str(), &output));
   EXPECT_EQ(kExpectedOutput, output);
 
-  // Input with with the category "task".
+  // Input with with the category "toplevel".
   // TODO(jamescook): Eliminate this special case and move the logic to the
   // trace viewer code.
-  const char kTaskCategory[] = "task";
+  const char kTaskCategory[] = "toplevel";
   const char kTaskName[] = "TaskName";
   std::ostringstream input2;
   input2 << "   68:     4195 [  1087:    98009] @ " << &kTaskCategory << " "
diff --git a/base/message_loop/incoming_task_queue.cc b/base/message_loop/incoming_task_queue.cc
index 8e2bd46..bcc712b 100644
--- a/base/message_loop/incoming_task_queue.cc
+++ b/base/message_loop/incoming_task_queue.cc
@@ -130,7 +130,8 @@
   // delayed_run_time value) and for identifying the task in about:tracing.
   pending_task->sequence_num = next_sequence_num_++;
 
-  TRACE_EVENT_FLOW_BEGIN0("task", "MessageLoop::PostTask",
+  TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
+      "MessageLoop::PostTask",
       TRACE_ID_MANGLE(message_loop_->GetTaskTraceID(*pending_task)));
 
   bool was_empty = incoming_queue_.empty();
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 689f0d9..8f6c9d8 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -415,14 +415,14 @@
   tracked_objects::TrackedTime start_time =
       tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
 
-  TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask",
-      TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
+  TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
+      "MessageLoop::PostTask", TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
       "queue_duration",
       (start_time - pending_task.EffectiveTimePosted()).InMilliseconds());
   // When tracing memory for posted tasks it's more valuable to attribute the
   // memory allocations to the source function than generically to "RunTask".
   TRACE_EVENT_WITH_MEMORY_TAG2(
-      "task", "MessageLoop::RunTask",
+      "toplevel", "MessageLoop::RunTask",
       pending_task.posted_from.function_name(),  // Name for memory tracking.
       "src_file", pending_task.posted_from.file_name(),
       "src_func", pending_task.posted_from.function_name());
diff --git a/base/message_loop/message_pump_gtk.cc b/base/message_loop/message_pump_gtk.cc
index 93f0296..0074342 100644
--- a/base/message_loop/message_pump_gtk.cc
+++ b/base/message_loop/message_pump_gtk.cc
@@ -71,7 +71,7 @@
 }
 
 void MessagePumpGtk::DispatchEvents(GdkEvent* event) {
-  UNSHIPPED_TRACE_EVENT1("task", "MessagePumpGtk::DispatchEvents",
+  UNSHIPPED_TRACE_EVENT1("toplevel", "MessagePumpGtk::DispatchEvents",
                          "type", EventToTypeString(event));
 
   WillProcessEvent(event);
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 4fc090d..813005c 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -593,7 +593,8 @@
     // The trace_id is used for identifying the task in about:tracing.
     sequenced.trace_id = trace_id_++;
 
-    TRACE_EVENT_FLOW_BEGIN0("task", "SequencedWorkerPool::PostTask",
+    TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
+        "SequencedWorkerPool::PostTask",
         TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this))));
 
     sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber();
@@ -726,9 +727,10 @@
       GetWorkStatus status =
           GetWork(&task, &wait_time, &delete_these_outside_lock);
       if (status == GET_WORK_FOUND) {
-        TRACE_EVENT_FLOW_END0("task", "SequencedWorkerPool::PostTask",
+        TRACE_EVENT_FLOW_END0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
+            "SequencedWorkerPool::PostTask",
             TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this))));
-        TRACE_EVENT2("task", "SequencedWorkerPool::ThreadLoop",
+        TRACE_EVENT2("toplevel", "SequencedWorkerPool::ThreadLoop",
                      "src_file", task.posted_from.file_name(),
                      "src_func", task.posted_from.function_name());
         int new_thread_id = WillRunWorkerTask(task);
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index c4c523f..f00d799 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -91,7 +91,7 @@
     PendingTask pending_task = pool_->WaitForTask();
     if (pending_task.task.is_null())
       break;
-    TRACE_EVENT2("task", "WorkerThread::ThreadMain::Run",
+    TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run",
         "src_file", pending_task.posted_from.file_name(),
         "src_func", pending_task.posted_from.function_name());