- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / renderer / media / webrtc_logging_message_filter.h
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.
4
5 #ifndef CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
6 #define CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_
7
8 #include "base/memory/shared_memory.h"
9 #include "ipc/ipc_channel_proxy.h"
10
11 namespace base {
12 class MessageLoopProxy;
13 }
14
15 class ChromeWebRtcLogMessageDelegate;
16
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 {
22  public:
23   explicit WebRtcLoggingMessageFilter(
24       const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
25
26   void LoggingStopped();
27
28   const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
29     return io_message_loop_;
30   }
31
32  protected:
33   virtual ~WebRtcLoggingMessageFilter();
34
35  private:
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;
41
42   void CreateLoggingHandler();
43
44   void OnStartLogging(base::SharedMemoryHandle handle, uint32 length);
45   void OnStopLogging();
46   void Send(IPC::Message* message);
47
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_;
53
54   scoped_refptr<base::MessageLoopProxy> io_message_loop_;
55
56   IPC::Channel* channel_;
57
58   DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingMessageFilter);
59 };
60
61 #endif  // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_