summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_logging.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 03:15:58 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 03:15:58 +0000
commit39b7b06790a776ee2247f391b1b2e3af1a335503 (patch)
tree8813c8831c92e6f00e8e72bbeaa95693e695c683 /chrome/common/ipc_logging.cc
parentd718a62d075bdd6f45a128bd5d82358d73799300 (diff)
downloadchromium_src-39b7b06790a776ee2247f391b1b2e3af1a335503.zip
chromium_src-39b7b06790a776ee2247f391b1b2e3af1a335503.tar.gz
chromium_src-39b7b06790a776ee2247f391b1b2e3af1a335503.tar.bz2
Make it easier/less work/less error-prone to create new IPC channel types (i.e. renderer/plugin).Instead of having each message file include the internal one several times with different ifdefs, move that logic to ipc_message_macros.h. Also make the message class starting IDs come from an enum to ensure we don't use a value twice. I simplified the logging code a bit so we don't need X_messages.cc files.Clean up places that we were doing manual packing/unpacking. Most of this was in the automation code. I added a few new template functions to make it convenient to read the parameters from a message, and updated the code to use them.I also removed unnecessary includes of render/plugin_messages.h from headers to speed up compiling.I moved the traits of IPC structs beside the struct definition to make it more apparent what's going on, so we avoid people modifying the struct and forgetting to update the traits.Amit: please look at chrome/test/automation/tab_proxy.ccMarc-Antoine: chrome/browser/printing/*Matt: the rest
Review URL: http://codereview.chromium.org/20015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_logging.cc')
-rw-r--r--chrome/common/ipc_logging.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc
index ec2fe82..2946093 100644
--- a/chrome/common/ipc_logging.cc
+++ b/chrome/common/ipc_logging.cc
@@ -41,6 +41,8 @@ Logging::Logging()
consumer_(NULL),
queue_invoke_later_pending_(false),
main_thread_(MessageLoop::current()) {
+ memset(log_function_mapping_, sizeof(log_function_mapping_), 0);
+
// 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;
@@ -88,8 +90,18 @@ 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 Logging::current()->GetEventName(GetCurrentProcessId(), enabled);
+ return current()->GetEventName(GetCurrentProcessId(), enabled);
}
std::wstring Logging::GetEventName(int browser_pid, bool enabled) {
@@ -188,24 +200,12 @@ void Logging::OnPostDispatchMessage(const Message& message,
}
}
-// static
-LogFunction* g_log_function_mapping[16];
-void RegisterMessageLogger(int msg_start, LogFunction* func) {
- int msg_class = msg_start >> 12;
- if (msg_class > arraysize(g_log_function_mapping)) {
- NOTREACHED();
- return;
- }
-
- g_log_function_mapping[msg_class] = func;
-}
-
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;