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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/browser_message_filter.h"
18 class WebRTCIdentityStore
;
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
{
29 WebRTCIdentityServiceHost(int renderer_process_id
,
30 scoped_refptr
<WebRTCIdentityStore
> identity_store
);
33 virtual ~WebRTCIdentityServiceHost();
35 // content::BrowserMessageFilter override.
36 virtual bool OnMessageReceived(const IPC::Message
& message
,
37 bool* message_was_ok
) OVERRIDE
;
40 // |sequence_number| is the same as in the OnRequestIdentity call.
41 // See WebRTCIdentityStore for the meaning of the parameters.
42 void OnComplete(int sequence_number
,
44 const std::string
& certificate
,
45 const std::string
& private_key
);
47 // |sequence_number| is a renderer wide unique number for each request and
48 // will be echoed in the response to handle the possibility that the renderer
49 // cancels the request after the browser sends the response and before it's
50 // received by the renderer.
51 // See WebRTCIdentityStore for the meaning of the other parameters.
52 void OnRequestIdentity(int sequence_number
,
54 const std::string
& identity_name
,
55 const std::string
& common_name
);
57 void OnCancelRequest();
59 void SendErrorMessage(int sequence_number
, int error
);
61 int renderer_process_id_
;
62 base::Closure cancel_callback_
;
63 scoped_refptr
<WebRTCIdentityStore
> identity_store_
;
64 base::WeakPtrFactory
<WebRTCIdentityServiceHost
> weak_factory_
;
66 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost
);
69 } // namespace content
71 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_