Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: ipc/ipc_logging.cc

Issue 5526008: Simplify the magic required to create IPC message headers a bit. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_logging.h ('k') | ipc/ipc_message.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_logging.cc
===================================================================
--- ipc/ipc_logging.cc (revision 68536)
+++ ipc/ipc_logging.cc (working copy)
@@ -5,7 +5,6 @@
#include "ipc/ipc_logging.h"
#ifdef IPC_MESSAGE_LOG_ENABLED
-// This will cause render_messages.h etc to define ViewMsgLog and friends.
#define IPC_MESSAGE_MACROS_LOG_ENABLED
#endif
@@ -13,6 +12,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/process_util.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "base/time.h"
@@ -38,7 +38,7 @@
// We use a pointer to the function table to avoid any linker dependencies on
// all the traits used as IPC message parameters.
-Logging::LogFunction *Logging::log_function_mapping_;
+LogFunctionMap* Logging::log_function_map_;
Logging::Logging()
: enabled_(false),
@@ -70,10 +70,6 @@
return Singleton<Logging>::get();
}
-void Logging::SetLoggerFunctions(LogFunction *functions) {
- log_function_mapping_ = functions;
-}
-
void Logging::SetConsumer(Consumer* consumer) {
consumer_ = consumer;
}
@@ -164,16 +160,20 @@
void Logging::GetMessageText(uint32 type, std::string* name,
const Message* message,
std::string* params) {
- if (!log_function_mapping_)
+ if (!log_function_map_)
return;
- int message_class = type >> 16;
- if (log_function_mapping_[message_class] != NULL) {
- log_function_mapping_[message_class](type, name, message, params);
- } else {
- DVLOG(1) << "No logger function associated with message class "
- << message_class;
+ LogFunctionMap::iterator it = log_function_map_->find(type);
+ if (it == log_function_map_->end()) {
+ if (name) {
+ *name = "[UNKNOWN MSG ";
+ *name += base::IntToString(type);
+ *name += " ]";
+ }
+ return;
}
+
+ (*it->second)(name, message, params);
}
void Logging::Log(const LogData& data) {
« no previous file with comments | « ipc/ipc_logging.h ('k') | ipc/ipc_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698