blob: e46030338ca1c34b50f815df0c2dd961f017907e [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/shared_memory.h"
#include "ipc/ipc_channel_proxy.h"
namespace base {
class MessageLoopProxy;
class ChromeWebRtcLogMessageDelegate;
// Filter for WebRTC logging messages. Sits between
// ChromeWebRtcLogMessageDelegate (renderer process) and
// WebRtcLoggingHandlerHost (browser process). Must be called on the IO thread.
class WebRtcLoggingMessageFilter
: public IPC::ChannelProxy::MessageFilter {
explicit WebRtcLoggingMessageFilter(
const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
void LoggingStopped();
const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
return io_message_loop_;
virtual ~WebRtcLoggingMessageFilter();
// IPC::ChannelProxy::MessageFilter implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
virtual void OnFilterRemoved() OVERRIDE;
virtual void OnChannelClosing() OVERRIDE;
void CreateLoggingHandler();
void OnStartLogging(base::SharedMemoryHandle handle, uint32 length);
void OnStopLogging();
void Send(IPC::Message* message);
// Owned by this class. The only other pointer to it is in libjingle's logging
// file. That's a global pointer used on different threads, so we will leak
// this object when we go away to ensure that it outlives any log messages
// coming from libjingle.
ChromeWebRtcLogMessageDelegate* log_message_delegate_;
scoped_refptr<base::MessageLoopProxy> io_message_loop_;
IPC::Channel* channel_;