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"
16 struct WebRTCIdentityMsg_RequestIdentity_Params
;
20 class ResourceContext
;
21 class WebRTCIdentityStore
;
23 // This class is the host for WebRTCIdentityService in the browser process.
24 // It converts the IPC messages for requesting a WebRTC DTLS identity and
25 // cancelling a pending request into calls of WebRTCIdentityStore. It also sends
26 // the request result back to the renderer through IPC.
27 // Only one outstanding request is allowed per renderer at a time. If a second
28 // request is made before the first one completes, an IPC with error
29 // ERR_INSUFFICIENT_RESOURCES will be sent back to the renderer.
30 class CONTENT_EXPORT WebRTCIdentityServiceHost
: public BrowserMessageFilter
{
32 WebRTCIdentityServiceHost(int renderer_process_id
,
33 scoped_refptr
<WebRTCIdentityStore
> identity_store
,
34 ResourceContext
* resource_context
);
37 ~WebRTCIdentityServiceHost() override
;
39 // content::BrowserMessageFilter override.
40 bool OnMessageReceived(const IPC::Message
& message
) override
;
43 // |request_id| is the same as in the OnRequestIdentity call.
44 // See WebRTCIdentityStore for the meaning of the parameters.
45 void OnComplete(int request_id
,
47 const std::string
& certificate
,
48 const std::string
& private_key
);
50 // |request_id| is a renderer wide unique number for each request and
51 // will be echoed in the response to handle the possibility that the renderer
52 // cancels the request after the browser sends the response and before it's
53 // received by the renderer.
54 // See WebRTCIdentityStore for the meaning of the other parameters.
55 void OnRequestIdentity(
56 const WebRTCIdentityMsg_RequestIdentity_Params
& params
);
58 void OnCancelRequest();
60 void SendErrorMessage(int request_id
, int error
);
62 int renderer_process_id_
;
63 base::Closure cancel_callback_
;
64 scoped_refptr
<WebRTCIdentityStore
> identity_store_
;
65 ResourceContext
* resource_context_
;
67 base::WeakPtrFactory
<WebRTCIdentityServiceHost
> weak_factory_
;
69 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost
);
72 } // namespace content
74 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_