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-11 05:38:41 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 05:38:41 +0000
commit3335d879a364867309a93749cc9e4805bd92d114 (patch)
treec974aab1fd40e1d4f91e9eb768697a8286ea0dc8 /chrome/common/ipc_logging.cc
parentb0a604b351995345bcf9f17ae403495e30fe4cdc (diff)
downloadchromium_src-3335d879a364867309a93749cc9e4805bd92d114.zip
chromium_src-3335d879a364867309a93749cc9e4805bd92d114.tar.gz
chromium_src-3335d879a364867309a93749cc9e4805bd92d114.tar.bz2
Redo my IPC change, undoing the linker dependency.
Review URL: http://codereview.chromium.org/21225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_logging.cc')
-rw-r--r--chrome/common/ipc_logging.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc
index fef4734..c9874b7 100644
--- a/chrome/common/ipc_logging.cc
+++ b/chrome/common/ipc_logging.cc
@@ -33,6 +33,10 @@ namespace IPC {
const wchar_t kLoggingEventName[] = L"ChromeIPCLog.%d";
const int kLogSendDelayMs = 100;
+// 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_;
+
Logging::Logging()
: logging_event_on_(NULL),
logging_event_off_(NULL),
@@ -41,8 +45,6 @@ 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;
@@ -90,14 +92,8 @@ 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;
+void Logging::SetLoggerFunctions(LogFunction *functions) {
+ log_function_mapping_ = functions;
}
std::wstring Logging::GetEventName(bool enabled) {
@@ -203,9 +199,12 @@ void Logging::OnPostDispatchMessage(const Message& message,
void Logging::GetMessageText(uint16 type, std::wstring* name,
const Message* message,
std::wstring* params) {
+ if (!log_function_mapping_)
+ return;
+
int message_class = type >> 12;
- if (current()->log_function_mapping_[message_class] != NULL) {
- current()->log_function_mapping_[message_class](type, name, message, params);
+ if (log_function_mapping_[message_class] != NULL) {
+ log_function_mapping_[message_class](type, name, message, params);
} else {
DLOG(INFO) << "No logger function associated with message class " <<
message_class;