summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/ipc_channel_proxy.h5
-rw-r--r--chrome/common/ipc_logging.cc27
-rw-r--r--chrome/common/ipc_logging.h23
3 files changed, 25 insertions, 30 deletions
diff --git a/chrome/common/ipc_channel_proxy.h b/chrome/common/ipc_channel_proxy.h
index 82b3d88..06e74ef 100644
--- a/chrome/common/ipc_channel_proxy.h
+++ b/chrome/common/ipc_channel_proxy.h
@@ -136,11 +136,6 @@ class ChannelProxy : public Message::Sender {
void AddFilter(MessageFilter* filter);
void RemoveFilter(MessageFilter* filter);
- // TODO(darin): kill this
- bool ProcessPendingMessages(uint32 max_wait_msec) {
- return false;
- }
-
protected:
Channel::Listener* listener() const { return context_->listener(); }
diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc
index 58933e4..3c7e7dc 100644
--- a/chrome/common/ipc_logging.cc
+++ b/chrome/common/ipc_logging.cc
@@ -31,6 +31,7 @@
#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"
@@ -42,15 +43,19 @@
#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),
@@ -86,24 +91,18 @@ Logging::Logging()
}
Logging::~Logging() {
+ watcher_.StopWatching();
CloseHandle(logging_event_on_);
CloseHandle(logging_event_off_);
}
Logging* Logging::current() {
- AutoLock lock(logger_lock_);
-
- if (!current_.get())
- current_ = new Logging();
-
- return current_;
+ return Singleton<Logging>::get();
}
void Logging::RegisterWaitForEvent(bool enabled) {
- MessageLoop::current()->WatchObject(
- enabled ? logging_event_off_ : logging_event_on_, NULL);
-
- MessageLoop::current()->WatchObject(
+ watcher_.StopWatching();
+ watcher_.StartWatching(
enabled ? logging_event_on_ : logging_event_off_, this);
}
diff --git a/chrome/common/ipc_logging.h b/chrome/common/ipc_logging.h
index 7fa2be4..9173cd7 100644
--- a/chrome/common/ipc_logging.h
+++ b/chrome/common/ipc_logging.h
@@ -27,15 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef CHROME_COMMON_IPC_LOGGING_H__
-#define CHROME_COMMON_IPC_LOGGING_H__
+#ifndef CHROME_COMMON_IPC_LOGGING_H_
+#define CHROME_COMMON_IPC_LOGGING_H_
#include "base/lock.h"
-#include "base/message_loop.h"
+#include "base/object_watcher.h"
+#include "base/singleton.h"
#include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
#ifdef IPC_MESSAGE_LOG_ENABLED
+class MessageLoop;
+
namespace IPC {
class Message;
@@ -43,8 +46,7 @@ class Message;
// One instance per process. Needs to be created on the main thread (the UI
// thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage
// can be called on other threads.
-class Logging : public base::RefCounted<Logging>,
- public MessageLoop::Watcher {
+class Logging : public base::ObjectWatcher::Delegate {
public:
// Implemented by consumers of log messages.
class Consumer {
@@ -85,10 +87,11 @@ class Logging : public base::RefCounted<Logging>,
static void GetMessageText(uint16 type, std::wstring* name,
const Message* message, std::wstring* params);
- // MessageLoop::Watcher
+ // ObjectWatcher::Delegate implementation
void OnObjectSignaled(HANDLE object);
private:
+ friend struct DefaultSingletonTraits<IPC::Logging>;
Logging();
std::wstring GetEventName(int browser_pid, bool enabled);
@@ -97,6 +100,8 @@ class Logging : public base::RefCounted<Logging>,
void RegisterWaitForEvent(bool enabled);
+ base::ObjectWatcher watcher_;
+
HANDLE logging_event_on_;
HANDLE logging_event_off_;
bool enabled_;
@@ -108,14 +113,10 @@ class Logging : public base::RefCounted<Logging>,
MessageLoop* main_thread_;
Consumer* consumer_;
-
- static scoped_refptr<Logging> current_;
-
- static Lock logger_lock_;
};
} // namespace IPC
#endif // IPC_MESSAGE_LOG_ENABLED
-#endif // CHROME_COMMON_IPC_LOGGING_H__
+#endif // CHROME_COMMON_IPC_LOGGING_H_