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_DTLS_IDENTITY_STORE_H_ | |
6 #define CONTENT_BROWSER_MEDIA_DTLS_IDENTITY_STORE_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/threading/non_thread_safe.h" | |
11 | |
12 class GURL; | |
13 | |
14 namespace base { | |
15 class TaskRunner; | |
16 } // namespace base | |
17 | |
18 namespace content { | |
19 | |
20 class DTLSIdentityRequest; | |
21 | |
22 class DTLSIdentityStore { | |
jam
2013/06/14 23:33:13
nit: comment this class
jiayl
2013/06/17 17:54:49
Done.
| |
23 public: | |
24 typedef base::Callback<void(int error, | |
25 const std::string& certificate, | |
26 const std::string& private_key)> | |
27 CompletionCallback; | |
28 | |
29 class RequestHandle { | |
jam
2013/06/14 23:33:13
do you really need to expose this in the header? w
jiayl
2013/06/17 17:54:49
Done. Now the caller get a Callback returned to ca
| |
30 public: | |
31 RequestHandle(); | |
32 virtual ~RequestHandle(); | |
33 | |
34 // Cancel the request. Does nothing if the request finished or was already | |
35 // cancelled. | |
36 void Cancel(); | |
37 | |
38 private: | |
39 friend DTLSIdentityStore; | |
40 | |
41 void RequestStarted(DTLSIdentityStore* store, | |
42 DTLSIdentityRequest* request, | |
43 const CompletionCallback& callback); | |
44 | |
45 void OnRequestComplete(int error, | |
46 const std::string& certificate, | |
47 const std::string& private_key); | |
48 | |
49 DTLSIdentityStore* store_; | |
50 DTLSIdentityRequest* request_; | |
51 CompletionCallback callback_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(RequestHandle); | |
54 }; | |
55 | |
56 DTLSIdentityStore(); | |
57 virtual ~DTLSIdentityStore(); | |
58 | |
59 // Retrieve the DTLS identity for the given origin, or generate a new one | |
60 // if not existent. Asynchronous. | |
61 // |origin| is the origin of the PeerConnection requesting the identity; | |
62 // |identity_name| is used to identify an identity within an origin; | |
63 // |common_name| is the common name used to generate the certificate; | |
64 // |callback| is the callback to return the result. | |
65 void RequestIdentity(const GURL& origin, | |
66 const std::string& identity_name, | |
67 const std::string& common_name, | |
68 const CompletionCallback& callback, | |
69 RequestHandle* out_request); | |
70 | |
71 protected: | |
72 explicit DTLSIdentityStore( | |
73 const scoped_refptr<base::TaskRunner>& task_runner); | |
74 | |
75 private: | |
76 friend class base::RefCounted<DTLSIdentityStore>; | |
jam
2013/06/14 23:33:13
nit: not needed
jiayl
2013/06/17 17:54:49
Done.
| |
77 | |
78 void CancelRequest(DTLSIdentityRequest* request); | |
79 | |
80 // The TaskRunner for doing work on a worker thread. | |
81 scoped_refptr<base::TaskRunner> task_runner_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(DTLSIdentityStore); | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_BROWSER_MEDIA_DTLS_IDENTITY_STORE_H_ | |
OLD | NEW |