Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 <map> | |
| 9 #include <queue> | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/time.h" | |
| 14 #include "content/browser/media/webrtc_identity_store.h" | |
| 15 #include "content/public/browser/browser_message_filter.h" | |
| 16 | |
| 17 class GURL; | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 // This class is the host for WebRTCIdentityService in the browser process. | |
| 22 // It converts the IPC messages for requesting a WebRTC DTLS identity and | |
| 23 // cancelling a pending request into calls of WebRTCIdentityStore. It also sends | |
| 24 // the request result back to the renderer through IPC. | |
| 25 class WebRTCIdentityServiceHost : public BrowserMessageFilter { | |
| 26 public: | |
| 27 explicit WebRTCIdentityServiceHost(WebRTCIdentityStore* identity_store); | |
| 28 | |
| 29 // The max number of requests accepted per second. If more requests are made, | |
| 30 // the requests will be rejected and an IPC containing error | |
| 31 // ERR_INSUFFICIENT_RESOURCES will be sent back to the renderer. | |
| 32 static const int MAX_REQUESTS_PER_SECOND; | |
|
Ryan Sleevi
2013/06/27 00:14:55
This is going to have issues compiling across diff
| |
| 33 | |
| 34 protected: | |
| 35 virtual ~WebRTCIdentityServiceHost(); | |
| 36 | |
| 37 // content::BrowserMessageFilter override. | |
| 38 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 39 bool* message_was_ok) OVERRIDE; | |
| 40 | |
| 41 virtual void OnComplete(int request_id, | |
| 42 int error, | |
| 43 const std::string& certificate, | |
| 44 const std::string& private_key); | |
| 45 | |
| 46 private: | |
| 47 // Requests a DTLS identity from the DTLS identity store for the given | |
| 48 // |origin| and |identity_name|. If no such identity exists, a new one will be | |
| 49 // generated using the given |common_name|. | |
| 50 // |request_id| is a unique id chosen by the client and used to cancel a | |
| 51 // pending request. | |
| 52 void OnRequestIdentity(int request_id, | |
| 53 const GURL& origin, | |
| 54 const std::string& identity_name, | |
| 55 const std::string& common_name); | |
| 56 // Cancels a pending request by its id. If there is no pending request having | |
| 57 // the same id, the call is ignored. | |
| 58 void OnCancelRequest(int request_id); | |
| 59 | |
| 60 bool IsRequestAllowed(); | |
| 61 void UpdateRequestTime(); | |
| 62 | |
| 63 typedef std::map<int, base::Closure> RequestCancelCallbackMap; | |
| 64 RequestCancelCallbackMap pending_request_cancel_callback_map_; | |
| 65 WebRTCIdentityStore* identity_store_; | |
| 66 std::queue<base::Time> recent_request_time_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityServiceHost); | |
| 69 }; | |
| 70 | |
| 71 } // namespace content | |
| 72 | |
| 73 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_WEBRTC_IDENTITY_SERVICE_HOST_H_ | |
| OLD | NEW |