Add async trace events to trace progress of IPC messages

BUG=79942

Review URL: https://chromiumcodereview.appspot.com/10919023

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


CrOS-Libchrome-Original-Commit: 2a2e3d67d14de8e39d97273b57b1a079f25f83fd
diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h
index 4603f09..1a2a45c 100644
--- a/ipc/ipc_message.h
+++ b/ipc/ipc_message.h
@@ -8,6 +8,7 @@
 #include <string>
 
 #include "base/basictypes.h"
+#include "base/debug/trace_event.h"
 #include "base/pickle.h"
 #include "ipc/ipc_export.h"
 
@@ -49,14 +50,16 @@
   };
 
   // Bit values used in the flags field.
+  // Upper 24 bits of flags store a reference number, so this enum is limited to
+  // 8 bits.
   enum {
-    PRIORITY_MASK     = 0x0003,  // Low 2 bits of store the priority value.
-    SYNC_BIT          = 0x0004,
-    REPLY_BIT         = 0x0008,
-    REPLY_ERROR_BIT   = 0x0010,
-    UNBLOCK_BIT       = 0x0020,
-    PUMPING_MSGS_BIT  = 0x0040,
-    HAS_SENT_TIME_BIT = 0x0080,
+    PRIORITY_MASK     = 0x03,  // Low 2 bits of store the priority value.
+    SYNC_BIT          = 0x04,
+    REPLY_BIT         = 0x08,
+    REPLY_ERROR_BIT   = 0x10,
+    UNBLOCK_BIT       = 0x20,
+    PUMPING_MSGS_BIT  = 0x40,
+    HAS_SENT_TIME_BIT = 0x80,
   };
 
   virtual ~Message();
@@ -221,6 +224,11 @@
   bool dont_log() const { return dont_log_; }
 #endif
 
+  // Called at various points between send and receive to track message.
+  void TraceMessageStep() {
+    TRACE_EVENT_ASYNC_BEGIN_STEP0("ipc", "IPC", header()->flags, NULL);
+  }
+
  protected:
   friend class Channel;
   friend class MessageReplyDeserializer;