| OLD | NEW |
| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 DtlsIdentityStoreImpl* store_; // Only touched on |signaling_thread_|. | 101 DtlsIdentityStoreImpl* store_; // Only touched on |signaling_thread_|. |
| 102 const rtc::KeyType key_type_; | 102 const rtc::KeyType key_type_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 DtlsIdentityStoreImpl::DtlsIdentityStoreImpl(rtc::Thread* signaling_thread, | 105 DtlsIdentityStoreImpl::DtlsIdentityStoreImpl(rtc::Thread* signaling_thread, |
| 106 rtc::Thread* worker_thread) | 106 rtc::Thread* worker_thread) |
| 107 : signaling_thread_(signaling_thread), | 107 : signaling_thread_(signaling_thread), |
| 108 worker_thread_(worker_thread), | 108 worker_thread_(worker_thread), |
| 109 request_info_() { | 109 request_info_() { |
| 110 RTC_DCHECK(signaling_thread_->IsCurrent()); | 110 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 111 // Preemptively generate identities unless the worker thread and signaling | |
| 112 // thread are the same (only do preemptive work in the background). | |
| 113 if (worker_thread_ != signaling_thread_) { | |
| 114 // Only necessary for RSA. | |
| 115 GenerateIdentity(rtc::KT_RSA, nullptr); | |
| 116 } | |
| 117 } | 111 } |
| 118 | 112 |
| 119 DtlsIdentityStoreImpl::~DtlsIdentityStoreImpl() { | 113 DtlsIdentityStoreImpl::~DtlsIdentityStoreImpl() { |
| 120 RTC_DCHECK(signaling_thread_->IsCurrent()); | 114 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 121 SignalDestroyed(); | 115 SignalDestroyed(); |
| 122 } | 116 } |
| 123 | 117 |
| 124 void DtlsIdentityStoreImpl::RequestIdentity( | 118 void DtlsIdentityStoreImpl::RequestIdentity( |
| 125 const rtc::KeyParams& key_params, | 119 const rtc::KeyParams& key_params, |
| 126 const rtc::Optional<uint64_t>& expires_ms, | 120 const rtc::Optional<uint64_t>& expires_ms, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 observer->OnSuccess(std::move(identity)); | 213 observer->OnSuccess(std::move(identity)); |
| 220 } else { | 214 } else { |
| 221 LOG(LS_WARNING) << "Failed to generate DTLS identity."; | 215 LOG(LS_WARNING) << "Failed to generate DTLS identity."; |
| 222 observer->OnFailure(0); | 216 observer->OnFailure(0); |
| 223 } | 217 } |
| 224 | 218 |
| 225 // Preemptively generate another identity of the same type? | 219 // Preemptively generate another identity of the same type? |
| 226 if (worker_thread_ != signaling_thread_ && // Only do in background thread. | 220 if (worker_thread_ != signaling_thread_ && // Only do in background thread. |
| 227 key_type == rtc::KT_RSA && // Only necessary for RSA. | 221 key_type == rtc::KT_RSA && // Only necessary for RSA. |
| 228 !request_info_[key_type].free_identity_.get() && | 222 !request_info_[key_type].free_identity_.get() && |
| 229 request_info_[key_type].request_observers_.size() <= | 223 request_info_[key_type].request_observers_.size() == |
| 230 request_info_[key_type].gen_in_progress_counts_) { | 224 request_info_[key_type].gen_in_progress_counts_) { |
| 231 GenerateIdentity(key_type, nullptr); | 225 GenerateIdentity(key_type, nullptr); |
| 232 } | 226 } |
| 233 } | 227 } |
| 234 } | 228 } |
| 235 | 229 |
| 236 } // namespace webrtc | 230 } // namespace webrtc |
| OLD | NEW |