diff options
-rw-r--r-- | chrome/browser/views/about_ipc_dialog.cc | 21 | ||||
-rw-r--r-- | chrome/common/ipc_logging.cc | 27 | ||||
-rw-r--r-- | chrome/common/ipc_logging.h | 8 | ||||
-rw-r--r-- | chrome/common/ipc_message_macros.h | 20 |
4 files changed, 32 insertions, 44 deletions
diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc index e5f39d9..2042bae 100644 --- a/chrome/browser/views/about_ipc_dialog.cc +++ b/chrome/browser/views/about_ipc_dialog.cc @@ -2,16 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Need to include this before any other file because it defines -// IPC_MESSAGE_LOG_ENABLED. We need to use it to define -// IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the -// ViewMsgLog et al. functions. -#include "chrome/common/ipc_message.h" +#include "chrome/browser/views/about_ipc_dialog.h" #ifdef IPC_MESSAGE_LOG_ENABLED -#define IPC_MESSAGE_MACROS_LOG_ENABLED - -#include "chrome/browser/views/about_ipc_dialog.h" #include <set> @@ -268,17 +261,7 @@ AboutIPCDialog::AboutIPCDialog() table_(NULL), tracking_(false) { SetupControls(); - - IPC::Logging* log = IPC::Logging::current();
- log->RegisterMessageLogger(ViewStart, ViewMsgLog);
- log->RegisterMessageLogger(ViewHostStart, ViewHostMsgLog);
- log->RegisterMessageLogger(PluginProcessStart, PluginProcessMsgLog);
- log->RegisterMessageLogger(PluginProcessHostStart, PluginProcessHostMsgLog);
- log->RegisterMessageLogger(PluginStart, PluginMsgLog);
- log->RegisterMessageLogger(PluginHostStart, PluginHostMsgLog);
- log->RegisterMessageLogger(NPObjectStart, NPObjectMsgLog);
-
- log->SetConsumer(this); + IPC::Logging::current()->SetConsumer(this); } AboutIPCDialog::~AboutIPCDialog() { diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index fef4734..7483706 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -2,6 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Need to include this before any other file because it defines +// IPC_MESSAGE_LOG_ENABLED. We need to use it to define +// IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the +// ViewMsgLog et al. functions. +#include "chrome/common/ipc_message.h" + +#ifdef IPC_MESSAGE_LOG_ENABLED +#define IPC_MESSAGE_MACROS_LOG_ENABLED + #include "chrome/common/ipc_logging.h" #include "base/command_line.h" @@ -16,8 +25,6 @@ #include "chrome/common/render_messages.h" #include "chrome/common/plugin_messages.h" -#ifdef IPC_MESSAGE_LOG_ENABLED - using base::Time; // IPC::Logging is allocated as a singleton, so we don't need any kind of @@ -41,8 +48,6 @@ Logging::Logging() consumer_(NULL), queue_invoke_later_pending_(false), main_thread_(MessageLoop::current()) { - memset(log_function_mapping_, 0, sizeof(log_function_mapping_)); - // Create an event for this browser instance that's set when logging is // enabled, so child processes can know when logging is enabled. int browser_pid; @@ -90,16 +95,6 @@ void Logging::OnObjectSignaled(HANDLE object) { RegisterWaitForEvent(!enabled_); } -void Logging::RegisterMessageLogger(int msg_start, LogFunction* func) { - int msg_class = msg_start >> 12; - if (msg_class > arraysize(log_function_mapping_)) { - NOTREACHED(); - return; - } - - log_function_mapping_[msg_class] = func; -} - std::wstring Logging::GetEventName(bool enabled) { return current()->GetEventName(GetCurrentProcessId(), enabled); } @@ -204,8 +199,8 @@ void Logging::GetMessageText(uint16 type, std::wstring* name, const Message* message, std::wstring* params) { int message_class = type >> 12; - if (current()->log_function_mapping_[message_class] != NULL) { - current()->log_function_mapping_[message_class](type, name, message, params); + if (g_log_function_mapping[message_class] != NULL) { + g_log_function_mapping[message_class](type, name, message, params); } else { DLOG(INFO) << "No logger function associated with message class " << message_class; diff --git a/chrome/common/ipc_logging.h b/chrome/common/ipc_logging.h index bf49595..d2b9aab 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -67,12 +67,6 @@ class Logging : public base::ObjectWatcher::Delegate { // ObjectWatcher::Delegate implementation void OnObjectSignaled(HANDLE object); - typedef void (LogFunction)(uint16 type, - std::wstring* name, - const Message* msg, - std::wstring* params); - void RegisterMessageLogger(int msg_start, LogFunction* func); - private: friend struct DefaultSingletonTraits<Logging>; Logging(); @@ -96,8 +90,6 @@ class Logging : public base::ObjectWatcher::Delegate { MessageLoop* main_thread_; Consumer* consumer_; - - LogFunction* log_function_mapping_[LastMsgIndex]; }; } // namespace IPC diff --git a/chrome/common/ipc_message_macros.h b/chrome/common/ipc_message_macros.h index fe39efa..59d5d35 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -365,6 +365,17 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ #elif defined(IPC_MESSAGE_MACROS_LOG) #undef IPC_MESSAGE_MACROS_LOG +#ifndef IPC_LOG_TABLE_CREATED +#define IPC_LOG_TABLE_CREATED +typedef void (LogFunction)(uint16 type, + std::wstring* name, + const IPC::Message* msg, + std::wstring* params); + +LogFunction* g_log_function_mapping[LastMsgIndex]; +#endif + + #define IPC_BEGIN_MESSAGES(label) \ void label##MsgLog(uint16 type, std::wstring* name, const IPC::Message* msg, std::wstring* params) { \ switch (type) { @@ -374,7 +385,14 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ if (name) \ *name = L"[UNKNOWN " L ## #label L" MSG"; \ } \ - } + } \ + class LoggerRegisterHelper##label { \ + public: \ + LoggerRegisterHelper##label() { \ + g_log_function_mapping[label##MsgStart] = label##MsgLog; \ + } \ + }; \ + LoggerRegisterHelper##label g_LoggerRegisterHelper##label; #define IPC_MESSAGE_LOG(msg_class) \ case msg_class##__ID: \ |