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_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
      6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/memory/shared_memory.h"
     10 #include "content/public/browser/browser_message_filter.h"
     11 
     12 namespace net {
     13 class URLRequestContextGetter;
     14 }  // namespace net
     15 
     16 class RenderProcessHost;
     17 
     18 // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging:
     19 // - Opens a shared memory buffer that the handler in the render process
     20 //   writes to.
     21 // - Detects when channel, i.e. renderer, is going away and triggers uploading
     22 //   the log.
     23 class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
     24  public:
     25   WebRtcLoggingHandlerHost();
     26 
     27  private:
     28   friend class content::BrowserThread;
     29   friend class base::DeleteHelper<WebRtcLoggingHandlerHost>;
     30 
     31   virtual ~WebRtcLoggingHandlerHost();
     32 
     33   // BrowserMessageFilter implementation.
     34   virtual void OnChannelClosing() OVERRIDE;
     35   virtual void OnDestruct() const OVERRIDE;
     36   virtual bool OnMessageReceived(const IPC::Message& message,
     37                                  bool* message_was_ok) OVERRIDE;
     38 
     39   void OnOpenLog(const std::string& app_session_id, const std::string& app_url);
     40 
     41   void OpenLogIfAllowed();
     42   void DoOpenLog();
     43   void LogMachineInfo();
     44   void NotifyLogOpened();
     45 
     46   void UploadLog();
     47 
     48   scoped_refptr<net::URLRequestContextGetter> system_request_context_;
     49   scoped_ptr<base::SharedMemory> shared_memory_;
     50   std::string app_session_id_;
     51   std::string app_url_;
     52 
     53   // This is the handle to be passed to the render process. It's stored so that
     54   // it doesn't have to be passed on when posting messages between threads.
     55   // It's only accessed on the IO thread.
     56   base::SharedMemoryHandle foreign_memory_handle_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
     59 };
     60 
     61 #endif  // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
     62