| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/ipc_logging.h" | 5 #include "chrome/common/ipc_logging.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #ifdef IPC_MESSAGE_LOG_ENABLED | 8 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 9 // This will cause render_messages.h etc to define ViewMsgLog and friends. | 9 // This will cause render_messages.h etc to define ViewMsgLog and friends. |
| 10 #define IPC_MESSAGE_MACROS_LOG_ENABLED | 10 #define IPC_MESSAGE_MACROS_LOG_ENABLED |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 event_name = GetEventName(browser_pid, false); | 89 event_name = GetEventName(browser_pid, false); |
| 90 logging_event_off_.reset(new base::WaitableEvent( | 90 logging_event_off_.reset(new base::WaitableEvent( |
| 91 CreateEvent(NULL, TRUE, FALSE, event_name.c_str()))); | 91 CreateEvent(NULL, TRUE, FALSE, event_name.c_str()))); |
| 92 | 92 |
| 93 RegisterWaitForEvent(true); | 93 RegisterWaitForEvent(true); |
| 94 #elif defined(OS_POSIX) | 94 #elif defined(OS_POSIX) |
| 95 if (getenv("CHROME_IPC_LOGGING")) | 95 if (getenv("CHROME_IPC_LOGGING")) |
| 96 enabled_ = true; | 96 enabled_ = true; |
| 97 SetLoggerFunctions(g_log_function_mapping); | 97 SetLoggerFunctions(g_log_function_mapping); |
| 98 #endif | 98 #endif |
| 99 |
| 100 MessageLoop::current()->AddDestructionObserver(this); |
| 99 } | 101 } |
| 100 | 102 |
| 101 Logging::~Logging() { | 103 Logging::~Logging() { |
| 102 watcher_.StopWatching(); | |
| 103 } | 104 } |
| 104 | 105 |
| 105 Logging* Logging::current() { | 106 Logging* Logging::current() { |
| 106 return Singleton<Logging>::get(); | 107 return Singleton<Logging>::get(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void Logging::RegisterWaitForEvent(bool enabled) { | 110 void Logging::RegisterWaitForEvent(bool enabled) { |
| 110 watcher_.StopWatching(); | 111 watcher_.StopWatching(); |
| 111 watcher_.StartWatching( | 112 watcher_.StartWatching( |
| 112 enabled ? logging_event_on_.get() : logging_event_off_.get(), this); | 113 enabled ? logging_event_on_.get() : logging_event_off_.get(), this); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void Logging::OnWaitableEventSignaled(base::WaitableEvent* event) { | 116 void Logging::OnWaitableEventSignaled(base::WaitableEvent* event) { |
| 116 enabled_ = event == logging_event_on_.get(); | 117 enabled_ = event == logging_event_on_.get(); |
| 117 RegisterWaitForEvent(!enabled_); | 118 RegisterWaitForEvent(!enabled_); |
| 118 } | 119 } |
| 119 | 120 |
| 121 void Logging::WillDestroyCurrentMessageLoop() { |
| 122 watcher_.StopWatching(); |
| 123 } |
| 124 |
| 120 void Logging::SetLoggerFunctions(LogFunction *functions) { | 125 void Logging::SetLoggerFunctions(LogFunction *functions) { |
| 121 log_function_mapping_ = functions; | 126 log_function_mapping_ = functions; |
| 122 } | 127 } |
| 123 | 128 |
| 124 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 125 std::wstring Logging::GetEventName(bool enabled) { | 130 std::wstring Logging::GetEventName(bool enabled) { |
| 126 return current()->GetEventName(GetCurrentProcessId(), enabled); | 131 return current()->GetEventName(GetCurrentProcessId(), enabled); |
| 127 } | 132 } |
| 128 #endif | 133 #endif |
| 129 | 134 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 data->receive = message.received_time(); | 304 data->receive = message.received_time(); |
| 300 data->dispatch = Time::Now().ToInternalValue(); | 305 data->dispatch = Time::Now().ToInternalValue(); |
| 301 data->params = params; | 306 data->params = params; |
| 302 data->message_name = message_name; | 307 data->message_name = message_name; |
| 303 } | 308 } |
| 304 } | 309 } |
| 305 | 310 |
| 306 } | 311 } |
| 307 | 312 |
| 308 #endif // IPC_MESSAGE_LOG_ENABLED | 313 #endif // IPC_MESSAGE_LOG_ENABLED |
| OLD | NEW |