Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: webrtc/api/dtlsidentitystore.h

Issue 2028033002: Remove DtlsIdentityStoreImpl and RTCCertificateGeneratorStoreWrapper. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 virtual ~DtlsIdentityStoreInterface() { } 57 virtual ~DtlsIdentityStoreInterface() { }
58 58
59 // The |observer| will be called when the requested identity is ready, or when 59 // The |observer| will be called when the requested identity is ready, or when
60 // identity generation fails. 60 // identity generation fails.
61 virtual void RequestIdentity( 61 virtual void RequestIdentity(
62 const rtc::KeyParams& key_params, 62 const rtc::KeyParams& key_params,
63 const rtc::Optional<uint64_t>& expires_ms, 63 const rtc::Optional<uint64_t>& expires_ms,
64 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) = 0; 64 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) = 0;
65 }; 65 };
66 66
67 // The WebRTC default implementation of DtlsIdentityStoreInterface.
68 // Identity generation is performed on the worker thread.
69 class DtlsIdentityStoreImpl : public DtlsIdentityStoreInterface,
70 public rtc::MessageHandler {
71 public:
72 // This will start to preemptively generating an RSA identity in the
73 // background if the worker thread is not the same as the signaling thread.
74 DtlsIdentityStoreImpl(rtc::Thread* signaling_thread,
75 rtc::Thread* worker_thread);
76 ~DtlsIdentityStoreImpl() override;
77
78 // DtlsIdentityStoreInterface override;
79 void RequestIdentity(
80 const rtc::KeyParams& key_params,
81 const rtc::Optional<uint64_t>& expires_ms,
82 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) override;
83
84 // rtc::MessageHandler override;
85 void OnMessage(rtc::Message* msg) override;
86
87 // Returns true if there is a free RSA identity, used for unit tests.
88 bool HasFreeIdentityForTesting(rtc::KeyType key_type) const;
89
90 private:
91 void GenerateIdentity(
92 rtc::KeyType key_type,
93 const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer);
94 void OnIdentityGenerated(rtc::KeyType key_type,
95 std::unique_ptr<rtc::SSLIdentity> identity);
96
97 class WorkerTask;
98 typedef rtc::ScopedMessageData<DtlsIdentityStoreImpl::WorkerTask>
99 WorkerTaskMessageData;
100
101 // A key type-identity pair.
102 struct IdentityResult {
103 IdentityResult(rtc::KeyType key_type,
104 std::unique_ptr<rtc::SSLIdentity> identity)
105 : key_type_(key_type), identity_(std::move(identity)) {}
106
107 rtc::KeyType key_type_;
108 std::unique_ptr<rtc::SSLIdentity> identity_;
109 };
110
111 typedef rtc::ScopedMessageData<IdentityResult> IdentityResultMessageData;
112
113 sigslot::signal0<> SignalDestroyed;
114
115 rtc::Thread* const signaling_thread_;
116 // TODO(hbos): RSA generation is slow and would be VERY slow if we switch over
117 // to 2048, DtlsIdentityStore should use a new thread and not the "general
118 // purpose" worker thread.
119 rtc::Thread* const worker_thread_;
120
121 struct RequestInfo {
122 RequestInfo()
123 : request_observers_(), gen_in_progress_counts_(0), free_identity_() {}
124
125 std::queue<rtc::scoped_refptr<DtlsIdentityRequestObserver>>
126 request_observers_;
127 size_t gen_in_progress_counts_;
128 std::unique_ptr<rtc::SSLIdentity> free_identity_;
129 };
130
131 // One RequestInfo per KeyType. Only touch on the |signaling_thread_|.
132 RequestInfo request_info_[rtc::KT_LAST];
133 };
134
135 // Implements the |RTCCertificateGeneratorInterface| using the old |SSLIdentity|
136 // generator API, |DtlsIdentityStoreInterface|. This will be used while
137 // transitioning from store to generator, see bugs.webrtc.org/5707,
138 // bugs.webrtc.org/5708. Once those bugs have been fixed, this will be removed.
139 class RTCCertificateGeneratorStoreWrapper
140 : public rtc::RTCCertificateGeneratorInterface {
141 public:
142 RTCCertificateGeneratorStoreWrapper(
143 std::unique_ptr<DtlsIdentityStoreInterface> store);
144
145 // |RTCCertificateGeneratorInterface| overrides.
146 void GenerateCertificateAsync(
147 const rtc::KeyParams& key_params,
148 const rtc::Optional<uint64_t>& expires_ms,
149 const rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>& callback)
150 override;
151
152 private:
153 const std::unique_ptr<DtlsIdentityStoreInterface> store_;
154 };
155
156 } // namespace webrtc 67 } // namespace webrtc
157 68
158 #endif // WEBRTC_API_DTLSIDENTITYSTORE_H_ 69 #endif // WEBRTC_API_DTLSIDENTITYSTORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698