OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 FakeRTCCertificateGenerator() : should_fail_(false) {} | 128 FakeRTCCertificateGenerator() : should_fail_(false) {} |
129 | 129 |
130 void set_should_fail(bool should_fail) { | 130 void set_should_fail(bool should_fail) { |
131 should_fail_ = should_fail; | 131 should_fail_ = should_fail; |
132 } | 132 } |
133 | 133 |
134 void use_original_key() { key_index_ = 0; } | 134 void use_original_key() { key_index_ = 0; } |
135 void use_alternate_key() { key_index_ = 1; } | 135 void use_alternate_key() { key_index_ = 1; } |
136 | 136 |
| 137 int generated_certificates() { return generated_certificates_; } |
| 138 |
137 void GenerateCertificateAsync( | 139 void GenerateCertificateAsync( |
138 const rtc::KeyParams& key_params, | 140 const rtc::KeyParams& key_params, |
139 const rtc::Optional<uint64_t>& expires_ms, | 141 const rtc::Optional<uint64_t>& expires_ms, |
140 const rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>& | 142 const rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>& |
141 callback) override { | 143 callback) override { |
142 // The certificates are created from constant PEM strings and use its coded | 144 // The certificates are created from constant PEM strings and use its coded |
143 // expiration time, we do not support modifying it. | 145 // expiration time, we do not support modifying it. |
144 RTC_DCHECK(!expires_ms); | 146 RTC_DCHECK(!expires_ms); |
145 MessageData* msg = new MessageData( | 147 MessageData* msg = new MessageData( |
146 rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>(callback)); | 148 rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>(callback)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback> callback = | 205 rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback> callback = |
204 message_data->data(); | 206 message_data->data(); |
205 rtc::scoped_refptr<rtc::RTCCertificate> certificate; | 207 rtc::scoped_refptr<rtc::RTCCertificate> certificate; |
206 switch (msg->message_id) { | 208 switch (msg->message_id) { |
207 case MSG_SUCCESS_RSA: | 209 case MSG_SUCCESS_RSA: |
208 case MSG_SUCCESS_ECDSA: { | 210 case MSG_SUCCESS_ECDSA: { |
209 rtc::KeyType key_type = | 211 rtc::KeyType key_type = |
210 msg->message_id == MSG_SUCCESS_RSA ? rtc::KT_RSA : rtc::KT_ECDSA; | 212 msg->message_id == MSG_SUCCESS_RSA ? rtc::KT_RSA : rtc::KT_ECDSA; |
211 certificate = rtc::RTCCertificate::FromPEM(get_pem(key_type)); | 213 certificate = rtc::RTCCertificate::FromPEM(get_pem(key_type)); |
212 RTC_DCHECK(certificate); | 214 RTC_DCHECK(certificate); |
| 215 ++generated_certificates_; |
213 callback->OnSuccess(certificate); | 216 callback->OnSuccess(certificate); |
214 break; | 217 break; |
215 } | 218 } |
216 case MSG_FAILURE: | 219 case MSG_FAILURE: |
217 callback->OnFailure(); | 220 callback->OnFailure(); |
218 break; | 221 break; |
219 } | 222 } |
220 delete message_data; | 223 delete message_data; |
221 } | 224 } |
222 | 225 |
223 bool should_fail_; | 226 bool should_fail_; |
224 int key_index_ = 0; | 227 int key_index_ = 0; |
| 228 int generated_certificates_ = 0; |
225 }; | 229 }; |
226 | 230 |
227 #endif // WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_ | 231 #endif // WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_ |
OLD | NEW |