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 "chrome/common/media/webrtc_logging_message_data.h"
9 #include "ipc/message_filter.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 : public IPC::MessageFilter {
22 explicit WebRtcLoggingMessageFilter(
23 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
25 virtual void AddLogMessages(
26 const std::vector<WebRtcLoggingMessageData>& messages);
27 virtual void LoggingStopped();
29 const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
30 return io_message_loop_;
34 ~WebRtcLoggingMessageFilter() override;
36 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
38 // Owned by this class. The only other pointer to it is in libjingle's logging
39 // file. That's a global pointer used on different threads, so we will leak
40 // this object when we go away to ensure that it outlives any log messages
41 // coming from libjingle.
42 // This is protected for unit test purposes.
43 // TODO(vrk): Remove ChromeWebRtcLogMessageDelegate's pointer to
44 // WebRtcLoggingMessageFilter so that we can write a unit test that doesn't
45 // need this accessor.
46 ChromeWebRtcLogMessageDelegate* log_message_delegate_;
49 // IPC::MessageFilter implementation.
50 bool OnMessageReceived(const IPC::Message& message) override;
51 void OnFilterAdded(IPC::Sender* sender) override;
52 void OnFilterRemoved() override;
53 void OnChannelClosing() override;
55 void CreateLoggingHandler();
57 void OnStartLogging();
59 void Send(IPC::Message* message);
63 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingMessageFilter);
66 #endif // CHROME_RENDERER_MEDIA_WEBRTC_LOGGING_MESSAGE_FILTER_H_