OLD | NEW |
| (Empty) |
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/macros.h" | |
11 #include "content/common/content_export.h" | |
12 #include "content/public/browser/browser_message_filter.h" | |
13 | |
14 class GURL; | |
15 | |
16 struct WebRTCIdentityMsg_RequestIdentity_Params; | |
17 | |
18 namespace content { | |
19 | |
20 class ResourceContext; | |
21 class WebRTCIdentityStore; | |
22 | |
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 { | |
31 public: | |
32 WebRTCIdentityServiceHost(int renderer_process_id, | |
33 scoped_refptr<WebRTCIdentityStore> identity_store, | |
34 ResourceContext* resource_context); | |
35 | |
36 protected: | |
37 ~WebRTCIdentityServiceHost() override; | |
38 | |
39 // content::BrowserMessageFilter override. | |
40 bool OnMessageReceived(const IPC::Message& message) override; | |
41 | |
42 private: | |
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, | |
46 int status, | |
47 const std::string& certificate, | |
48 const std::string& private_key); | |
49 | |
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); | |
57 | |
58 void OnCancelRequest(); | |
59 | |
60 void SendErrorMessage(int request_id, int error); | |
61 | |
62 int renderer_process_id_; | |
63 base::Closure cancel_callback_; | |
64 scoped_refptr<WebRTCIdentityStore> identity_store_; | |
65 ResourceContext* resource_context_; | |
66 | |
67 base::WeakPtrFactory<WebRTCIdentityServiceHost> weak_factory_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost); | |
70 }; | |
71 | |
72 } // namespace content | |
73 | |
74 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_ | |
OLD | NEW |