diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-30 05:24:07 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-30 05:24:07 +0000 |
commit | 4f68ed70ed3e039661b8e492805982e63e80b15b (patch) | |
tree | c1a183a80140c214f9e4d5cdc6c6bd18cd5e5ffd /content | |
parent | c3cbe3536b4885fdc2a7ece5863e273a47c42964 (diff) | |
download | chromium_src-4f68ed70ed3e039661b8e492805982e63e80b15b.zip chromium_src-4f68ed70ed3e039661b8e492805982e63e80b15b.tar.gz chromium_src-4f68ed70ed3e039661b8e492805982e63e80b15b.tar.bz2 |
Split IPC logging between content and chrome.
I add a new content API to register IPC message loggers, and modify the IPC
message macros to not directly create the g_log_function_mapping. That allows
for multiple files generating IPC loggers. Also, it gets rid of the ctor/dtor
for the g_log_function_mapping.
BUG=101600,111316,155765
Review URL: https://codereview.chromium.org/11347012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/all_messages.h | 12 | ||||
-rw-r--r-- | content/common/content_ipc_logging.cc | 37 | ||||
-rw-r--r-- | content/content_common.gypi | 3 | ||||
-rw-r--r-- | content/public/common/content_ipc_logging.h | 30 | ||||
-rw-r--r-- | content/shell/shell_main_delegate.cc | 10 |
5 files changed, 92 insertions, 0 deletions
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" |