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_MEDIA_WEBRTC_IDENTITY_STORE_H_ | |
| 6 #define CONTENT_BROWSER_MEDIA_WEBRTC_IDENTITY_STORE_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 | |
| 10 class GURL; | |
| 11 | |
| 12 namespace base { | |
| 13 class TaskRunner; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 class WebRTCIdentityRequest; | |
| 19 class WebRTCIdentityRequestHandle; | |
| 20 class WebRTCIdentityStoreTest; | |
| 21 | |
| 22 // A class for creating and fetching DTLS identities, i.e. the private key and | |
| 23 // the self-signed certificate. | |
| 24 class WebRTCIdentityStore { | |
| 25 public: | |
| 26 typedef base::Callback<void(int error, | |
| 27 const std::string& certificate, | |
| 28 const std::string& private_key)> | |
| 29 CompletionCallback; | |
| 30 | |
| 31 WebRTCIdentityStore(); | |
| 32 ~WebRTCIdentityStore(); | |
| 33 | |
| 34 // Retrieve the cached DTLS private key and certificate, i.e. identity, for | |
| 35 // the |origin| and |identity_name| pair, or generate a new identity using | |
| 36 // |common_name| if such an identity does not exist. | |
| 37 // If the given |common_name| is different from the common name in the cached | |
| 38 // identity that has the same origin and identity_name, a new private key and | |
| 39 // a new certificate will be generated, overwriting the old one. | |
| 40 // TODO(jiayl): implement identity caching through a persistent storage. | |
| 41 // | |
| 42 // |origin| is the origin of the DTLS connection; | |
| 43 // |identity_name| is used to identify an identity within an origin; it is | |
| 44 // opaque to WebRTCIdentityStore and remains private to the caller, i.e. not | |
| 45 // present in the certificate; | |
| 46 // |common_name| is the common name used to generate the certificate and will | |
| 47 // be shared with the peer of the DTLS connection. Identities created for | |
| 48 // different origins or different identity names may have the same common | |
| 49 // name. | |
| 50 // |callback| is the callback to return the result. | |
| 51 // |cancel_callback| will be set to the Closure used to cancel the request | |
| 52 // if the request is accepted. The Closure can only be called before the | |
| 53 // request completes. | |
| 54 // | |
| 55 // Returns true if the request is accepted. | |
| 56 bool RequestIdentity(const GURL& origin, | |
| 57 const std::string& identity_name, | |
| 58 const std::string& common_name, | |
| 59 const CompletionCallback& callback, | |
| 60 base::Closure* cancel_callback); | |
| 61 | |
| 62 private: | |
| 63 friend class WebRTCIdentityRequestHandle; | |
| 64 friend class WebRTCIdentityStoreTest; | |
| 65 | |
| 66 explicit WebRTCIdentityStore( | |
|
Ami GONE FROM CHROMIUM
2013/06/27 20:05:18
Is this ctor only used for testing? If so, might
jiayl
2013/06/27 21:08:37
Done.
| |
| 67 const scoped_refptr<base::TaskRunner>& task_runner); | |
| 68 | |
| 69 void CancelRequestInternal(WebRTCIdentityRequest* request); | |
| 70 | |
| 71 // The TaskRunner for doing work on a worker thread. | |
| 72 scoped_refptr<base::TaskRunner> task_runner_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityStore); | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_IDENTITY_STORE_H_ | |
| OLD | NEW |