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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "content/common/content_export.h"
     12 #include "content/public/browser/browser_message_filter.h"
     13 
     14 class GURL;
     15 
     16 namespace content {
     17 
     18 class WebRTCIdentityStore;
     19 
     20 // This class is the host for WebRTCIdentityService in the browser process.
     21 // It converts the IPC messages for requesting a WebRTC DTLS identity and
     22 // cancelling a pending request into calls of WebRTCIdentityStore. It also sends
     23 // the request result back to the renderer through IPC.
     24 // Only one outstanding request is allowed per renderer at a time. If a second
     25 // request is made before the first one completes, an IPC with error
     26 // ERR_INSUFFICIENT_RESOURCES will be sent back to the renderer.
     27 class CONTENT_EXPORT WebRTCIdentityServiceHost : public BrowserMessageFilter {
     28  public:
     29   explicit WebRTCIdentityServiceHost(int renderer_process_id,
     30                                      WebRTCIdentityStore* identity_store);
     31 
     32  protected:
     33   virtual ~WebRTCIdentityServiceHost();
     34 
     35   // content::BrowserMessageFilter override.
     36   virtual bool OnMessageReceived(const IPC::Message& message,
     37                                  bool* message_was_ok) OVERRIDE;
     38 
     39  private:
     40   // See WebRTCIdentityStore for the meaning of the parameters.
     41   void OnComplete(int status,
     42                   const std::string& certificate,
     43                   const std::string& private_key);
     44 
     45   // See WebRTCIdentityStore for the meaning of the parameters.
     46   void OnRequestIdentity(const GURL& origin,
     47                          const std::string& identity_name,
     48                          const std::string& common_name);
     49 
     50   void OnCancelRequest();
     51 
     52   void SendErrorMessage(int error);
     53 
     54   int renderer_process_id_;
     55   base::Closure cancel_callback_;
     56   WebRTCIdentityStore* identity_store_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost);
     59 };
     60 
     61 }  // namespace content
     62 
     63 #endif  // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_
     64