diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:14:33 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:14:33 +0000 |
commit | 08658a41d004daaf4183537fe2314eb2532881ee (patch) | |
tree | 118bbbd7944c714098d1aa289ed1dd4cb7d5d42b /chrome/common/ipc_logging.cc | |
parent | 0a14d3db1762fb2e309e5f0e07279f91ed2bb128 (diff) | |
download | chromium_src-08658a41d004daaf4183537fe2314eb2532881ee.zip chromium_src-08658a41d004daaf4183537fe2314eb2532881ee.tar.gz chromium_src-08658a41d004daaf4183537fe2314eb2532881ee.tar.bz2 |
Fix ipc logging for non browser processes. I broke this in my last refactoring, since the logger functions only got registered in the browser. This fix registers them using a global object for each message type (that's only compiled when debugging is enabled). One less thing to take care of when creating new message types.
Review URL: http://codereview.chromium.org/20213
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_logging.cc')
-rw-r--r-- | chrome/common/ipc_logging.cc | 27 |
1 files changed, 11 insertions, 16 deletions
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; |