diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-09 08:34:08 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-09 08:34:08 +0000 |
commit | 2de755222010708f16ea99af9e3dc2cfe41f96cf (patch) | |
tree | 7c2789878bf6fcfe00e8a39e43832479f5b89e11 /chrome/common/ipc_logging.cc | |
parent | 0e48e9dc55bd35d15db0476fbcf1c3529a5fa8de (diff) | |
download | chromium_src-2de755222010708f16ea99af9e3dc2cfe41f96cf.zip chromium_src-2de755222010708f16ea99af9e3dc2cfe41f96cf.tar.gz chromium_src-2de755222010708f16ea99af9e3dc2cfe41f96cf.tar.bz2 |
rollback r625 because it made things slower
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_logging.cc')
-rw-r--r-- | chrome/common/ipc_logging.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index 3c7e7dc..58933e4 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -31,7 +31,6 @@ #include "base/command_line.h" #include "base/logging.h" -#include "base/message_loop.h" #include "base/string_util.h" #include "base/thread.h" #include "base/time.h" @@ -43,19 +42,15 @@ #ifdef IPC_MESSAGE_LOG_ENABLED -// IPC::Logging is allocated as a singleton, so we don't need any kind of -// special retention program. -template <> -struct RunnableMethodTraits<IPC::Logging> { - static void RetainCallee(IPC::Logging*) {} - static void ReleaseCallee(IPC::Logging*) {} -}; - namespace IPC { const wchar_t kLoggingEventName[] = L"ChromeIPCLog.%d"; const int kLogSendDelayMs = 100; +scoped_refptr<Logging> Logging::current_; + +Lock Logging::logger_lock_; + Logging::Logging() : logging_event_on_(NULL), logging_event_off_(NULL), @@ -91,18 +86,24 @@ Logging::Logging() } Logging::~Logging() { - watcher_.StopWatching(); CloseHandle(logging_event_on_); CloseHandle(logging_event_off_); } Logging* Logging::current() { - return Singleton<Logging>::get(); + AutoLock lock(logger_lock_); + + if (!current_.get()) + current_ = new Logging(); + + return current_; } void Logging::RegisterWaitForEvent(bool enabled) { - watcher_.StopWatching(); - watcher_.StartWatching( + MessageLoop::current()->WatchObject( + enabled ? logging_event_off_ : logging_event_on_, NULL); + + MessageLoop::current()->WatchObject( enabled ? logging_event_on_ : logging_event_off_, this); } |