OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_BASE_RTCCERTIFICATEGENERATOR_H_ | |
12 #define WEBRTC_BASE_RTCCERTIFICATEGENERATOR_H_ | |
13 | |
14 #include "webrtc/base/optional.h" | |
15 #include "webrtc/base/refcount.h" | |
16 #include "webrtc/base/rtccertificate.h" | |
17 #include "webrtc/base/scoped_ref_ptr.h" | |
18 #include "webrtc/base/sslidentity.h" | |
19 #include "webrtc/base/thread.h" | |
20 | |
21 namespace rtc { | |
22 | |
23 class RTCCertificateGeneratorCallback : public RefCountInterface { | |
24 public: | |
25 virtual void OnSuccess( | |
26 const scoped_refptr<RTCCertificate>& certificate) = 0; | |
27 virtual void OnFailure() = 0; | |
28 | |
29 protected: | |
30 ~RTCCertificateGeneratorCallback() override {} | |
31 }; | |
32 | |
33 // Generates |RTCCertificate|s. | |
34 // The static function |GenerateCertificate| generates a certificate on the | |
35 // current thread. The |RTCCertificateGenerator| instance generates certificates | |
36 // asynchronously on the worker thread with |GenerateCertificateAsync|. | |
37 class RTCCertificateGenerator { | |
38 public: | |
39 // Generates a certificate on the current thread. Returns null on failure. | |
40 // If |expires_ms| is specified, the certificate will expire in approximately | |
41 // that many milliseconds from now. |expires_ms| is limited to a year, a | |
42 // larger value than that is clamped down to a year. | |
43 static scoped_refptr<RTCCertificate> GenerateCertificate( | |
44 const KeyParams& key_params, | |
45 const Optional<uint64_t>& expires_ms); | |
torbjorng (webrtc)
2016/04/15 12:17:48
Please document what happens if this argument is n
hbos
2016/04/15 13:24:14
Done.
| |
46 | |
47 RTCCertificateGenerator(Thread* signaling_thread, Thread* worker_thread); | |
48 | |
49 // Generates a certificate asynchronously on the worker thread. | |
50 // Must be called on the signaling thread. The |callback| is invoked with the | |
51 // result on the signaling thread. If |expires_ms| is specified, the | |
52 // certificate will expire in approximately that many milliseconds from now. | |
53 // |expires_ms| is limited to a year, a larger value than that is clamped down | |
54 // to a year. | |
55 void GenerateCertificateAsync( | |
56 const KeyParams& key_params, | |
57 const Optional<uint64_t>& expires_ms, | |
58 const scoped_refptr<RTCCertificateGeneratorCallback>& callback); | |
59 | |
60 private: | |
61 Thread* const signaling_thread_; | |
62 Thread* const worker_thread_; | |
63 }; | |
64 | |
65 } // namespace rtc | |
66 | |
67 #endif // WEBRTC_BASE_RTCCERTIFICATEGENERATOR_H_ | |
OLD | NEW |