OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 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_API_DTLSIDENTITYSTORE_H_ | |
12 #define WEBRTC_API_DTLSIDENTITYSTORE_H_ | |
13 | |
14 #include <memory> | |
15 #include <queue> | |
16 #include <string> | |
17 #include <utility> | |
18 | |
19 #include "webrtc/base/messagehandler.h" | |
20 #include "webrtc/base/messagequeue.h" | |
21 #include "webrtc/base/optional.h" | |
22 #include "webrtc/base/refcount.h" | |
23 #include "webrtc/base/rtccertificategenerator.h" | |
24 #include "webrtc/base/scoped_ref_ptr.h" | |
25 #include "webrtc/base/sslidentity.h" | |
26 #include "webrtc/base/thread.h" | |
27 | |
28 namespace webrtc { | |
29 | |
30 class SSLIdentity; | |
31 class Thread; | |
32 | |
33 // Used to receive callbacks of DTLS identity requests. | |
34 class DtlsIdentityRequestObserver : public rtc::RefCountInterface { | |
35 public: | |
36 virtual void OnFailure(int error) = 0; | |
37 // TODO(hbos): Unify the OnSuccess method once Chrome code is updated. | |
38 virtual void OnSuccess(const std::string& der_cert, | |
39 const std::string& der_private_key) = 0; | |
40 // |identity| is a unique_ptr because rtc::SSLIdentity is not copyable and the | |
41 // client has to get the ownership of the object to make use of it. | |
42 virtual void OnSuccess(std::unique_ptr<rtc::SSLIdentity> identity) = 0; | |
43 | |
44 protected: | |
45 virtual ~DtlsIdentityRequestObserver() {} | |
46 }; | |
47 | |
48 // This interface defines an in-memory DTLS identity store, which generates DTLS | |
49 // identities. | |
50 // APIs calls must be made on the signaling thread and the callbacks are also | |
51 // called on the signaling thread. | |
52 class DtlsIdentityStoreInterface { | |
53 public: | |
54 virtual ~DtlsIdentityStoreInterface() { } | |
55 | |
56 // The |observer| will be called when the requested identity is ready, or when | |
57 // identity generation fails. | |
58 virtual void RequestIdentity( | |
59 const rtc::KeyParams& key_params, | |
60 const rtc::Optional<uint64_t>& expires_ms, | |
61 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) = 0; | |
62 }; | |
63 | |
64 } // namespace webrtc | |
65 | |
66 #endif // WEBRTC_API_DTLSIDENTITYSTORE_H_ | |
OLD | NEW |