Home | History | Annotate | Download | only in media
      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_CHROME_WEBRTC_LOG_MESSAGE_DELEGATE_H_
      6 #define CHROME_RENDERER_MEDIA_CHROME_WEBRTC_LOG_MESSAGE_DELEGATE_H_
      7 
      8 #include <string>
      9 
     10 #include "base/memory/shared_memory.h"
     11 #include "content/public/renderer/webrtc_log_message_delegate.h"
     12 #include "ipc/ipc_channel_proxy.h"
     13 
     14 namespace base {
     15 class MessageLoopProxy;
     16 }
     17 
     18 class PartialCircularBuffer;
     19 class WebRtcLoggingMessageFilter;
     20 
     21 // ChromeWebRtcLogMessageDelegate handles WebRTC logging. There is one object
     22 // per render process, owned by WebRtcLoggingMessageFilter. It communicates with
     23 // WebRtcLoggingHandlerHost and receives logging messages from libjingle and
     24 // writes them to a shared memory buffer.
     25 class ChromeWebRtcLogMessageDelegate
     26     : public content::WebRtcLogMessageDelegate,
     27       public base::NonThreadSafe {
     28  public:
     29   ChromeWebRtcLogMessageDelegate(
     30       const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
     31       WebRtcLoggingMessageFilter* message_filter);
     32 
     33   virtual ~ChromeWebRtcLogMessageDelegate();
     34 
     35   // content::WebRtcLogMessageDelegate implementation.
     36   virtual void InitLogging(const std::string& app_session_id,
     37                            const std::string& app_url) OVERRIDE;
     38   virtual void LogMessage(const std::string& message) OVERRIDE;
     39 
     40   void OnFilterRemoved();
     41 
     42   void OnLogOpened(base::SharedMemoryHandle handle, uint32 length);
     43   void OnOpenLogFailed();
     44 
     45  private:
     46   scoped_refptr<base::MessageLoopProxy> io_message_loop_;
     47   scoped_ptr<base::SharedMemory> shared_memory_;
     48   scoped_ptr<PartialCircularBuffer> circular_buffer_;
     49 
     50   WebRtcLoggingMessageFilter* message_filter_;
     51   bool log_initialized_;
     52 
     53   DISALLOW_COPY_AND_ASSIGN(ChromeWebRtcLogMessageDelegate);
     54 };
     55 
     56 #endif  // CHROME_RENDERER_MEDIA_CHROME_WEBRTC_LOG_MESSAGE_DELEGATE_H_
     57