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 ~WebRTCIdentityServiceHost() override
;
35 // content::BrowserMessageFilter override.
36 bool OnMessageReceived(const IPC::Message
& message
) override
;
39 // |sequence_number| is the same as in the OnRequestIdentity call.
40 // See WebRTCIdentityStore for the meaning of the parameters.
41 void OnComplete(int sequence_number
,
43 const std::string
& certificate
,
44 const std::string
& private_key
);
46 // |sequence_number| is a renderer wide unique number for each request and
47 // will be echoed in the response to handle the possibility that the renderer
48 // cancels the request after the browser sends the response and before it's
49 // received by the renderer.
50 // See WebRTCIdentityStore for the meaning of the other parameters.
51 void OnRequestIdentity(int sequence_number
,
53 const std::string
& identity_name
,
54 const std::string
& common_name
);
56 void OnCancelRequest();
58 void SendErrorMessage(int sequence_number
, int error
);
60 int renderer_process_id_
;
61 base::Closure cancel_callback_
;
62 scoped_refptr
<WebRTCIdentityStore
> identity_store_
;
63 base::WeakPtrFactory
<WebRTCIdentityServiceHost
> weak_factory_
;
65 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost
);
68 } // namespace content
70 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_