webrtc_logging_message_filter.h revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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 11namespace base { 12class MessageLoopProxy; 13} 14 15class 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. 20class WebRtcLoggingMessageFilter 21 : public IPC::ChannelProxy::MessageFilter { 22 public: 23 explicit WebRtcLoggingMessageFilter( 24 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); 25 26 virtual void InitLogging(const std::string& app_session_id, 27 const std::string& app_url); 28 29 const scoped_refptr<base::MessageLoopProxy>& io_message_loop() { 30 return io_message_loop_; 31 } 32 33 protected: 34 virtual ~WebRtcLoggingMessageFilter(); 35 36 private: 37 // IPC::ChannelProxy::MessageFilter implementation. 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 39 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 40 virtual void OnFilterRemoved() OVERRIDE; 41 virtual void OnChannelClosing() OVERRIDE; 42 43 void CreateLoggingHandler(); 44 45 void OnLogOpened(base::SharedMemoryHandle handle, uint32 length); 46 void OnOpenLogFailed(); 47 48 void Send(IPC::Message* message); 49 50 // Owned by this class. The only other pointer to it is in libjingle's logging 51 // file. That's a global pointer used on different threads, so we will leak 52 // this object when we go away to ensure that it outlives any log messages 53 // coming from libjingle. 54 ChromeWebRtcLogMessageDelegate* log_message_delegate_; 55 56 scoped_refptr<base::MessageLoopProxy> io_message_loop_; 57 58 IPC::Channel* channel_; 59 60 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingMessageFilter); 61}; 62 63#endif // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_ 64