summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/views/about_ipc_dialog.cc13
-rw-r--r--chrome/chrome_common.gypi4
-rw-r--r--chrome/common/DEPS4
-rw-r--r--chrome/common/all_messages.h3
-rw-r--r--chrome/common/logging_chrome.cc6
-rw-r--r--chrome/tools/ipclist/DEPS3
-rw-r--r--chrome/tools/ipclist/ipcfuzz.cc4
-rw-r--r--chrome/tools/ipclist/ipclist.cc4
-rw-r--r--content/common/all_messages.h12
-rw-r--r--content/common/content_ipc_logging.cc37
-rw-r--r--content/content_common.gypi3
-rw-r--r--content/public/common/content_ipc_logging.h30
-rw-r--r--content/shell/shell_main_delegate.cc10
-rw-r--r--ipc/ipc_message_macros.h18
-rw-r--r--ppapi/proxy/plugin_main_nacl.cc7
15 files changed, 120 insertions, 38 deletions
diff --git a/chrome/browser/ui/views/about_ipc_dialog.cc b/chrome/browser/ui/views/about_ipc_dialog.cc
index 67d56b3..cb90ca1 100644
--- a/chrome/browser/ui/views/about_ipc_dialog.cc
+++ b/chrome/browser/ui/views/about_ipc_dialog.cc
@@ -9,7 +9,10 @@
#include "ipc/ipc_message.h"
#ifdef IPC_MESSAGE_LOG_ENABLED
+#include "content/public/common/content_ipc_logging.h"
#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
+ content::RegisterIPCLogger(msg_id, logger)
// We need to do this real early to be sure IPC_MESSAGE_MACROS_LOG_ENABLED
// doesn't get undefined.
@@ -55,16 +58,6 @@ enum {
kParamsColumn,
};
-// This class registers the browser IPC logger functions with IPC::Logging.
-class RegisterLoggerFuncs {
- public:
- RegisterLoggerFuncs() {
- IPC::Logging::set_log_function_map(&g_log_function_mapping);
- }
-};
-
-RegisterLoggerFuncs g_register_logger_funcs;
-
// The singleton dialog box. This is non-NULL when a dialog is active so we
// know not to create a new one.
AboutIPCDialog* g_active_dialog = NULL;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 98b0ab6..2b92333 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -9,9 +9,7 @@
'type': 'static_library',
'variables': {
'chrome_common_target': 1,
- # TODO(thakis): Turn this on. Blocked on g_log_function_mapping in
- # ipc_message_macros.h. http://crbug.com/101600
- #'enable_wexit_time_destructors': 1,
+ 'enable_wexit_time_destructors': 1,
},
'include_dirs': [
'..',
diff --git a/chrome/common/DEPS b/chrome/common/DEPS
index ffc99a7..03adafd 100644
--- a/chrome/common/DEPS
+++ b/chrome/common/DEPS
@@ -12,10 +12,6 @@ include_rules = [
"+webkit/plugins",
"+webkit/user_agent",
- # TODO(jam): remove this once all of chrome doesn't depend on content/common.
- "-content/common",
- "+content/common/content_message_generator.h", # needed by all_messages.h
-
# TODO(jam): remove me once chrome_notifcation_types.h moves to browser
"+content/public/browser/notification_source.h",
"+content/public/browser/notification_types.h",
diff --git a/chrome/common/all_messages.h b/chrome/common/all_messages.h
index 62881ce..114bf9d 100644
--- a/chrome/common/all_messages.h
+++ b/chrome/common/all_messages.h
@@ -19,6 +19,3 @@
#include "chrome/common/automation_messages.h"
#include "chrome/common/common_message_generator.h"
#include "chrome/common/nacl_messages.h"
-#include "content/common/content_message_generator.h"
-#include "ppapi/proxy/pepper_file_messages.h"
-#include "ppapi/proxy/ppapi_messages.h"
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index 7e49e5e..f738c3f 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -16,6 +16,9 @@
// IPC_MESSAGE_MACROS_LOG_ENABLED doesn't get undefined.
#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#include "content/public/common/content_ipc_logging.h"
+#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
+ content::RegisterIPCLogger(msg_id, logger)
#include "chrome/common/all_messages.h"
#endif
@@ -258,9 +261,6 @@ void InitChromeLogging(const CommandLine& command_line,
DCHECK(!chrome_logging_initialized_) <<
"Attempted to initialize logging when it was already initialized.";
-#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
- IPC::Logging::set_log_function_map(&g_log_function_mapping);
-#endif
LoggingDestination logging_dest = DetermineLogMode(command_line);
LogLockingState log_locking_state = LOCK_LOG_FILE;
FilePath log_path;
diff --git a/chrome/tools/ipclist/DEPS b/chrome/tools/ipclist/DEPS
new file mode 100644
index 0000000..456f046
--- /dev/null
+++ b/chrome/tools/ipclist/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+content/common/all_messages.h",
+]
diff --git a/chrome/tools/ipclist/ipcfuzz.cc b/chrome/tools/ipclist/ipcfuzz.cc
index 6a58949..87fe2c2 100644
--- a/chrome/tools/ipclist/ipcfuzz.cc
+++ b/chrome/tools/ipclist/ipcfuzz.cc
@@ -20,6 +20,7 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_switches.h"
@@ -550,6 +551,7 @@ class PickleCracker : public Pickle {
// Bring them into existence.
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
// Redefine macros to generate fuzzing funtions
#include "ipc/ipc_message_null_macros.h"
@@ -635,6 +637,7 @@ class PickleCracker : public Pickle {
#define IPC_MEMBERS_OUT_5() NULL, NULL, NULL, NULL, NULL
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
typedef IPC::Message* (*FuzzFunction)(IPC::Message*, IPC::Fuzzer*);
typedef base::hash_map<uint32, FuzzFunction> FuzzFunctionMap;
@@ -647,6 +650,7 @@ typedef base::hash_map<uint32, FuzzFunction> FuzzFunctionMap;
void PopulateFuzzFunctionMap(FuzzFunctionMap *map) {
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
}
class ipcfuzz : public IPC::ChannelProxy::OutgoingMessageFilter {
diff --git a/chrome/tools/ipclist/ipclist.cc b/chrome/tools/ipclist/ipclist.cc
index 419a05b..baf6c05 100644
--- a/chrome/tools/ipclist/ipclist.cc
+++ b/chrome/tools/ipclist/ipclist.cc
@@ -9,6 +9,7 @@
// Include once to get the type definitions
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
struct msginfo {
const char* name;
@@ -29,6 +30,7 @@ struct msginfo {
static msginfo msgtable[] = {
#include "chrome/common/all_messages.h"
+#include "content/common/all_messages.h"
};
#define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
@@ -77,7 +79,7 @@ static bool check_msgtable() {
}
if (!result)
- std::cout << "Please check chrome/common/all_messages.h.\n";
+ std::cout << "Please check {chrome,content}/common/all_messages.h.\n";
return result;
}
diff --git a/content/common/all_messages.h b/content/common/all_messages.h
new file mode 100644
index 0000000..bb0b241
--- /dev/null
+++ b/content/common/all_messages.h
@@ -0,0 +1,12 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included file, hence no include guard.
+// Inclusion of all message files present in content. Keep this file
+// up-to-date when adding a new value to the IPCMessageStart enum in
+// ipc/ipc_message_start.h to ensure the corresponding message file is
+// included here.
+#include "content/common/content_message_generator.h"
+#include "ppapi/proxy/pepper_file_messages.h"
+#include "ppapi/proxy/ppapi_messages.h"
diff --git a/content/common/content_ipc_logging.cc b/content/common/content_ipc_logging.cc
new file mode 100644
index 0000000..594345d
--- /dev/null
+++ b/content/common/content_ipc_logging.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#include "content/public/common/content_ipc_logging.h"
+#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
+ content::RegisterIPCLogger(msg_id, logger)
+#include "content/common/all_messages.h"
+#endif
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+#include "base/hash_tables.h"
+#include "base/lazy_instance.h"
+
+namespace content {
+
+namespace {
+
+base::LazyInstance<base::hash_map<uint32, LogFunction> >::Leaky
+ g_log_function_mapping = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void RegisterIPCLogger(uint32 msg_id, LogFunction logger) {
+ if (g_log_function_mapping == NULL)
+ IPC::Logging::set_log_function_map(g_log_function_mapping.Pointer());
+ g_log_function_mapping.Get()[msg_id] = logger;
+}
+
+} // content
+
+#endif
diff --git a/content/content_common.gypi b/content/content_common.gypi
index a4a6791..f0dd962 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -29,6 +29,7 @@
'public/common/content_constants.cc',
'public/common/content_constants.h',
'public/common/content_descriptors.h',
+ 'public/common/content_ipc_logging.h',
'public/common/content_paths.h',
'public/common/content_restriction.h',
'public/common/content_switches.cc',
@@ -96,6 +97,7 @@
'common/accessibility_messages.h',
'common/accessibility_node_data.cc',
'common/accessibility_node_data.h',
+ 'common/all_messages.h',
'common/android/address_parser.cc',
'common/android/address_parser.h',
'common/android/address_parser_internal.cc',
@@ -144,6 +146,7 @@
'common/content_constants_internal.cc',
'common/content_constants_internal.h',
'common/content_export.h',
+ 'common/content_ipc_logging.cc',
'common/content_message_generator.cc',
'common/content_message_generator.h',
'common/content_param_traits.cc',
diff --git a/content/public/common/content_ipc_logging.h b/content/public/common/content_ipc_logging.h
new file mode 100644
index 0000000..83fe898
--- /dev/null
+++ b/content/public/common/content_ipc_logging.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_CONTENT_IPC_LOGGING_H_
+#define CONTENT_PUBLIC_COMMON_CONTENT_IPC_LOGGING_H_
+
+#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
+
+#include "content/common/content_export.h"
+#include "ipc/ipc_logging.h"
+
+namespace content {
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+// Register a logger for the given IPC message. Use
+//
+// #define IPC_MESSAGE_MACROS_LOG_ENABLED
+// #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger)
+// content::RegisterIPCLogger(msg_id, logger)
+//
+// to register IPC messages with the logging system.
+CONTENT_EXPORT void RegisterIPCLogger(uint32 msg_id, LogFunction logger);
+
+#endif
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_COMMON_CONTENT_IPC_LOGGING_H_
diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc
index 3a2532d..8baa832 100644
--- a/content/shell/shell_main_delegate.cc
+++ b/content/shell/shell_main_delegate.cc
@@ -21,6 +21,16 @@
#include "ui/base/ui_base_paths.h"
#include "ui/gl/gl_switches.h"
+#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#include "content/public/common/content_ipc_logging.h"
+#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
+ content::RegisterIPCLogger(msg_id, logger)
+#include "content/shell/shell_messages.h"
+#endif
+
#if defined(OS_ANDROID)
#include "base/global_descriptors_posix.h"
#include "content/shell/android/shell_descriptors.h"
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index f77abb2..2993014 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -800,19 +800,9 @@
#elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED)
-#ifndef IPC_LOG_TABLE_CREATED
-#define IPC_LOG_TABLE_CREATED
-
-#include "base/hash_tables.h"
-
-typedef void (*LogFunction)(std::string* name,
- const IPC::Message* msg,
- std::string* params);
-
-typedef base::hash_map<uint32, LogFunction > LogFunctionMap;
-LogFunctionMap g_log_function_mapping;
-
-#endif // IPC_LOG_TABLE_CREATED
+#ifndef IPC_LOG_TABLE_ADD_ENTRY
+#error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger)
+#endif
// "Log table" inclusion produces extra logging registration code.
#define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \
@@ -821,7 +811,7 @@ LogFunctionMap g_log_function_mapping;
public: \
LoggerRegisterHelper##msg_class() { \
const uint32 msg_id = static_cast<uint32>(msg_class::ID); \
- g_log_function_mapping[msg_id] = msg_class::Log; \
+ IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_class::Log); \
} \
}; \
LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class;
diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_nacl.cc
index cc44ef7..7304e56 100644
--- a/ppapi/proxy/plugin_main_nacl.cc
+++ b/ppapi/proxy/plugin_main_nacl.cc
@@ -28,7 +28,14 @@
#include "ppapi/shared_impl/ppb_audio_shared.h"
#if defined(IPC_MESSAGE_LOG_ENABLED)
+#include "base/hash_tables.h"
+
+LogFunctionMap g_log_function_mapping;
+
#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
+ g_log_function_mapping[msg_id] = logger
+
#endif
#include "ppapi/proxy/ppapi_messages.h"