Revert "Remove kLogPluginMessages flag as part of flag cleanup."

This reverts commit da22c3c95242b05675da6b5e452c5dad8c5db1ee.

[email protected]
BUG=364781

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268268 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc
index 1071867..077f512 100644
--- a/content/browser/plugin_process_host.cc
+++ b/content/browser/plugin_process_host.cc
@@ -195,6 +195,7 @@
     switches::kEnableStatsTable,
     switches::kFullMemoryCrashReport,
     switches::kLoggingLevel,
+    switches::kLogPluginMessages,
     switches::kNoSandbox,
     switches::kPluginStartupDialog,
     switches::kTestSandbox,
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index 3f123e17..75a18e92 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -12,6 +12,7 @@
 #include <vector>
 
 #include "base/bind.h"
+#include "base/command_line.h"
 #include "base/debug/trace_event.h"
 #include "base/message_loop/message_loop_proxy.h"
 #include "base/strings/string_util.h"
@@ -20,6 +21,7 @@
 #include "content/common/gpu/gpu_channel_manager.h"
 #include "content/common/gpu/gpu_messages.h"
 #include "content/common/gpu/sync_point_manager.h"
+#include "content/public/common/content_switches.h"
 #include "gpu/command_buffer/common/mailbox.h"
 #include "gpu/command_buffer/service/gpu_scheduler.h"
 #include "gpu/command_buffer/service/image_manager.h"
@@ -405,6 +407,8 @@
   DCHECK(client_id);
 
   channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
+  const CommandLine* command_line = CommandLine::ForCurrentProcess();
+  log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
 }
 
 
@@ -449,6 +453,11 @@
 #endif  // defined(OS_POSIX)
 
 bool GpuChannel::OnMessageReceived(const IPC::Message& message) {
+  if (log_messages_) {
+    DVLOG(1) << "received message @" << &message << " on channel @" << this
+             << " with type " << message.type();
+  }
+
   if (message.type() == GpuCommandBufferMsg_WaitForTokenInRange::ID ||
       message.type() == GpuCommandBufferMsg_WaitForGetOffsetInRange::ID) {
     // Move Wait commands to the head of the queue, so the renderer
@@ -471,6 +480,10 @@
   // The GPU process must never send a synchronous IPC message to the renderer
   // process. This could result in deadlock.
   DCHECK(!message->is_sync());
+  if (log_messages_) {
+    DVLOG(1) << "sending message @" << message << " on channel @" << this
+             << " with type " << message->type();
+  }
 
   if (!channel_) {
     delete message;
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index f8a597b..3903135 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -218,6 +218,7 @@
   typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap;
   StubMap stubs_;
 
+  bool log_messages_;  // True if we should log sent and received messages.
   gpu::gles2::DisallowedFeatures disallowed_features_;
   GpuWatchdog* watchdog_;
   bool software_;
diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc
index 10cd6757..9a566d5 100644
--- a/content/plugin/plugin_channel.cc
+++ b/content/plugin/plugin_channel.cc
@@ -245,6 +245,8 @@
       filter_(new MessageFilter()),
       npp_(new struct _NPP) {
   set_send_unblocking_only_during_unblock_dispatch();
+  const CommandLine* command_line = CommandLine::ForCurrentProcess();
+  log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
 
   // Register |npp_| as the default owner for any object we receive via IPC,
   // and register it with WebBindings as a valid owner.
diff --git a/content/plugin/plugin_channel.h b/content/plugin/plugin_channel.h
index 1d9b045..7535944 100644
--- a/content/plugin/plugin_channel.h
+++ b/content/plugin/plugin_channel.h
@@ -92,6 +92,7 @@
   int renderer_id_;
 
   int in_send_;  // Tracks if we're in a Send call.
+  bool log_messages_;  // True if we should log sent and received messages.
   bool incognito_; // True if the renderer is in incognito mode.
   scoped_refptr<MessageFilter> filter_;  // Handles the modal dialog events.
 
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 30b50e6a..7bfbf039 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -667,6 +667,9 @@
 // Enables saving net log events to a file and sets the file name to use.
 const char kLogNetLog[]                     = "log-net-log";
 
+// Make plugin processes log their sent and received messages to VLOG(1).
+const char kLogPluginMessages[]             = "log-plugin-messages";
+
 // Sets the width and height above which a composited layer will get tiled.
 const char kMaxUntiledLayerHeight[]         = "max-untiled-layer-height";
 const char kMaxUntiledLayerWidth[]          = "max-untiled-layer-width";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index e2ba283..f1e1a36 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -192,6 +192,7 @@
 CONTENT_EXPORT extern const char kLogGpuControlListDecisions[];
 CONTENT_EXPORT extern const char kLoggingLevel[];
 CONTENT_EXPORT extern const char kLogNetLog[];
+extern const char kLogPluginMessages[];
 extern const char kMaxUntiledLayerHeight[];
 extern const char kMaxUntiledLayerWidth[];
 extern const char kMemoryMetrics[];