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());
 
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index 193b62c..3a0cf30 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -230,10 +230,10 @@
   Logging* logger = Logging::GetInstance();
   std::string name;
   logger->GetMessageText(message.type(), &name, &message, NULL);
-  TRACE_EVENT1("task", "ChannelProxy::Context::OnDispatchMessage",
+  TRACE_EVENT1("toplevel", "ChannelProxy::Context::OnDispatchMessage",
                "name", name);
 #else
-  TRACE_EVENT2("task", "ChannelProxy::Context::OnDispatchMessage",
+  TRACE_EVENT2("toplevel", "ChannelProxy::Context::OnDispatchMessage",
                "class", IPC_MESSAGE_ID_CLASS(message.type()),
                "line", IPC_MESSAGE_ID_LINE(message.type()));
 #endif
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc
index 2ee7449..8b638a9 100644
--- a/ipc/ipc_channel_reader.cc
+++ b/ipc/ipc_channel_reader.cc
@@ -83,9 +83,10 @@
       Logging* logger = Logging::GetInstance();
       std::string name;
       logger->GetMessageText(m.type(), &name, &m, NULL);
-      TRACE_EVENT1("ipc", "ChannelReader::DispatchInputData", "name", name);
+      TRACE_EVENT1("toplevel", "ChannelReader::DispatchInputData",
+                   "name", name);
 #else
-      TRACE_EVENT2("ipc", "ChannelReader::DispatchInputData",
+      TRACE_EVENT2("toplevel", "ChannelReader::DispatchInputData",
                    "class", IPC_MESSAGE_ID_CLASS(m.type()),
                    "line", IPC_MESSAGE_ID_LINE(m.type()));
 #endif
diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h
index 4209016..17cbd24 100644
--- a/ipc/ipc_message.h
+++ b/ipc/ipc_message.h
@@ -217,11 +217,13 @@
 
   // Called to trace when message is sent.
   void TraceMessageBegin() {
-    TRACE_EVENT_FLOW_BEGIN0("ipc", "IPC", header()->flags);
+    TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), "IPC",
+        header()->flags);
   }
   // Called to trace when message is received.
   void TraceMessageEnd() {
-    TRACE_EVENT_FLOW_END0("ipc", "IPC", header()->flags);
+    TRACE_EVENT_FLOW_END0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), "IPC",
+        header()->flags);
   }
 
  protected:
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc
index 491b72d..4b706e2 100644
--- a/ipc/ipc_sync_channel.cc
+++ b/ipc/ipc_sync_channel.cc
@@ -442,10 +442,10 @@
   Logging* logger = Logging::GetInstance();
   std::string name;
   logger->GetMessageText(message->type(), &name, message, NULL);
-  TRACE_EVENT1("task", "SyncChannel::SendWithTimeout",
+  TRACE_EVENT1("toplevel", "SyncChannel::SendWithTimeout",
                "name", name);
 #else
-  TRACE_EVENT2("task", "SyncChannel::SendWithTimeout",
+  TRACE_EVENT2("toplevel", "SyncChannel::SendWithTimeout",
                "class", IPC_MESSAGE_ID_CLASS(message->type()),
                "line", IPC_MESSAGE_ID_LINE(message->type()));
 #endif