OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 13 matching lines...) Expand all Loading... |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ | 28 #ifndef TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ |
29 #define TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ | 29 #define TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ |
30 | 30 |
31 #include <queue> | 31 #include <queue> |
32 #include <string> | 32 #include <string> |
33 | 33 |
34 #include "talk/app/webrtc/peerconnectioninterface.h" | |
35 #include "webrtc/base/messagehandler.h" | 34 #include "webrtc/base/messagehandler.h" |
36 #include "webrtc/base/messagequeue.h" | 35 #include "webrtc/base/messagequeue.h" |
| 36 #include "webrtc/base/refcount.h" |
37 #include "webrtc/base/scoped_ptr.h" | 37 #include "webrtc/base/scoped_ptr.h" |
38 #include "webrtc/base/scoped_ref_ptr.h" | 38 #include "webrtc/base/scoped_ref_ptr.h" |
| 39 #include "webrtc/base/sslidentity.h" |
| 40 #include "webrtc/base/thread.h" |
39 | 41 |
40 namespace webrtc { | 42 namespace webrtc { |
41 class DTLSIdentityRequestObserver; | |
42 class SSLIdentity; | 43 class SSLIdentity; |
43 class Thread; | 44 class Thread; |
44 | 45 |
| 46 // Used to receive callbacks of DTLS identity requests. |
| 47 class DTLSIdentityRequestObserver : public rtc::RefCountInterface { |
| 48 public: |
| 49 virtual void OnFailure(int error) = 0; |
| 50 // TODO(jiayl): Unify the OnSuccess method once Chrome code is updated. |
| 51 virtual void OnSuccess(const std::string& der_cert, |
| 52 const std::string& der_private_key) = 0; |
| 53 // |identity| is a scoped_ptr because rtc::SSLIdentity is not copyable and the |
| 54 // client has to get the ownership of the object to make use of it. |
| 55 virtual void OnSuccessWithIdentityObj( |
| 56 rtc::scoped_ptr<rtc::SSLIdentity> identity) = 0; |
| 57 |
| 58 protected: |
| 59 virtual ~DTLSIdentityRequestObserver() {} |
| 60 }; |
| 61 |
| 62 // TODO(hbos): To replace DTLSIdentityRequestObserver. |
| 63 // Used to receive callbacks of DTLS identity requests. |
| 64 class DtlsIdentityRequestObserver : public rtc::RefCountInterface { |
| 65 public: |
| 66 virtual void OnFailure(int error) = 0; |
| 67 // TODO(hbos): Unify the OnSuccess method once Chrome code is updated. |
| 68 virtual void OnSuccess(const std::string& der_cert, |
| 69 const std::string& der_private_key) = 0; |
| 70 // |identity| is a scoped_ptr because rtc::SSLIdentity is not copyable and the |
| 71 // client has to get the ownership of the object to make use of it. |
| 72 virtual void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) = 0; |
| 73 |
| 74 protected: |
| 75 virtual ~DtlsIdentityRequestObserver() {} |
| 76 }; |
| 77 |
| 78 // TODO(hbos): To be implemented. |
| 79 // This interface defines an in-memory DTLS identity store, which generates DTLS |
| 80 // identities. |
| 81 // APIs calls must be made on the signaling thread and the callbacks are also |
| 82 // called on the signaling thread. |
| 83 class DtlsIdentityStoreInterface { |
| 84 public: |
| 85 virtual ~DtlsIdentityStoreInterface() { } |
| 86 |
| 87 virtual void RequestIdentity( |
| 88 rtc::KeyType key_type, |
| 89 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) = 0; |
| 90 }; |
| 91 |
45 // This class implements an in-memory DTLS identity store, which generates the | 92 // This class implements an in-memory DTLS identity store, which generates the |
46 // DTLS identity on the worker thread. | 93 // DTLS identity on the worker thread. |
47 // APIs calls must be made on the signaling thread and the callbacks are also | 94 // APIs calls must be made on the signaling thread and the callbacks are also |
48 // called on the signaling thread. | 95 // called on the signaling thread. |
49 class DtlsIdentityStore : public rtc::MessageHandler { | 96 class DtlsIdentityStore : public rtc::MessageHandler { |
50 public: | 97 public: |
51 static const char kIdentityName[]; | 98 static const char kIdentityName[]; |
52 | 99 |
53 DtlsIdentityStore(rtc::Thread* signaling_thread, | 100 DtlsIdentityStore(rtc::Thread* signaling_thread, |
54 rtc::Thread* worker_thread); | 101 rtc::Thread* worker_thread); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 int pending_jobs_; | 133 int pending_jobs_; |
87 rtc::scoped_ptr<rtc::SSLIdentity> free_identity_; | 134 rtc::scoped_ptr<rtc::SSLIdentity> free_identity_; |
88 typedef std::queue<rtc::scoped_refptr<webrtc::DTLSIdentityRequestObserver>> | 135 typedef std::queue<rtc::scoped_refptr<webrtc::DTLSIdentityRequestObserver>> |
89 ObserverList; | 136 ObserverList; |
90 ObserverList pending_observers_; | 137 ObserverList pending_observers_; |
91 }; | 138 }; |
92 | 139 |
93 } // namespace webrtc | 140 } // namespace webrtc |
94 | 141 |
95 #endif // TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ | 142 #endif // TALK_APP_WEBRTC_DTLSIDENTITYSTORE_H_ |
OLD | NEW |