summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_logging.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/ipc_logging.cc')
-rw-r--r--chrome/common/ipc_logging.cc27
1 files changed, 16 insertions, 11 deletions
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;