diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:38:55 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:38:55 +0000 |
commit | d5dfa5a8f498025031c52241bb2f2100faf30e86 (patch) | |
tree | 983ed95256f2c123bc1292f7562f10b6ae6f5580 | |
parent | 6d7b953ec6132658ec7f85c2976c98ecd0c852b2 (diff) | |
download | chromium_src-d5dfa5a8f498025031c52241bb2f2100faf30e86.zip chromium_src-d5dfa5a8f498025031c52241bb2f2100faf30e86.tar.gz chromium_src-d5dfa5a8f498025031c52241bb2f2100faf30e86.tar.bz2 |
revert my ipc change due to compile failure in debug ipc_tests
Review URL: http://codereview.chromium.org/20229
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9494 0039d316-1c4b-4281-b951-d872f2087c98
-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, 44 insertions, 32 deletions
diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc index 2042bae..e5f39d9 100644 --- a/chrome/browser/views/about_ipc_dialog.cc +++ b/chrome/browser/views/about_ipc_dialog.cc @@ -2,9 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/about_ipc_dialog.h" +// 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/browser/views/about_ipc_dialog.h" #include <set> @@ -261,7 +268,17 @@ AboutIPCDialog::AboutIPCDialog() table_(NULL), tracking_(false) { SetupControls(); - IPC::Logging::current()->SetConsumer(this); + + 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); } AboutIPCDialog::~AboutIPCDialog() { diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index 7483706..fef4734 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -2,15 +2,6 @@ // 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" @@ -25,6 +16,8 @@ #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 @@ -48,6 +41,8 @@ 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; @@ -95,6 +90,16 @@ 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); } @@ -199,8 +204,8 @@ void Logging::GetMessageText(uint16 type, std::wstring* name, const Message* message, std::wstring* params) { int message_class = type >> 12; - if (g_log_function_mapping[message_class] != NULL) { - g_log_function_mapping[message_class](type, name, message, params); + if (current()->log_function_mapping_[message_class] != NULL) { + current()->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 d2b9aab..bf49595 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -67,6 +67,12 @@ 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(); @@ -90,6 +96,8 @@ 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 59d5d35..fe39efa 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -365,17 +365,6 @@ 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) { @@ -385,14 +374,7 @@ LogFunction* g_log_function_mapping[LastMsgIndex]; 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: \ |