1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
6 #define CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
8 #include "base/memory/shared_memory.h"
9 #include "ipc/ipc_channel_proxy.h"
12 class MessageLoopProxy;
15 class ChromeWebRtcLogMessageDelegate;
17 // Filter for WebRTC logging messages. Sits between
18 // ChromeWebRtcLogMessageDelegate (renderer process) and
19 // WebRtcLoggingHandlerHost (browser process). Must be called on the IO thread.
20 class WebRtcLoggingMessageFilter
21 : public IPC::ChannelProxy::MessageFilter {
23 explicit WebRtcLoggingMessageFilter(
24 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
26 void LoggingStopped();
28 const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
29 return io_message_loop_;
33 virtual ~WebRtcLoggingMessageFilter();
36 // IPC::ChannelProxy::MessageFilter implementation.
37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
38 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
39 virtual void OnFilterRemoved() OVERRIDE;
40 virtual void OnChannelClosing() OVERRIDE;
42 void CreateLoggingHandler();
44 void OnStartLogging(base::SharedMemoryHandle handle, uint32 length);
46 void Send(IPC::Message* message);
48 // Owned by this class. The only other pointer to it is in libjingle's logging
49 // file. That's a global pointer used on different threads, so we will leak
50 // this object when we go away to ensure that it outlives any log messages
51 // coming from libjingle.
52 ChromeWebRtcLogMessageDelegate* log_message_delegate_;
54 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
56 IPC::Channel* channel_;
58 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingMessageFilter);
61 #endif // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_