OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
6 | 6 |
7 #include <openssl/aead.h> | 7 #include <openssl/aead.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 CertVerifierJob* job_; | 222 CertVerifierJob* job_; |
223 }; | 223 }; |
224 | 224 |
225 CertVerifierJob(const QuicServerId& server_id, | 225 CertVerifierJob(const QuicServerId& server_id, |
226 int cert_verify_flags, | 226 int cert_verify_flags, |
227 const BoundNetLog& net_log) | 227 const BoundNetLog& net_log) |
228 : server_id_(server_id), | 228 : server_id_(server_id), |
229 verify_callback_(nullptr), | 229 verify_callback_(nullptr), |
230 verify_context_(base::WrapUnique( | 230 verify_context_(base::WrapUnique( |
231 new ProofVerifyContextChromium(cert_verify_flags, net_log))), | 231 new ProofVerifyContextChromium(cert_verify_flags, net_log))), |
| 232 start_time_(base::TimeTicks::Now()), |
232 net_log_(net_log), | 233 net_log_(net_log), |
233 weak_factory_(this) {} | 234 weak_factory_(this) {} |
234 | 235 |
235 ~CertVerifierJob() { | 236 ~CertVerifierJob() { |
236 if (verify_callback_) | 237 if (verify_callback_) |
237 verify_callback_->Cancel(); | 238 verify_callback_->Cancel(); |
238 } | 239 } |
239 | 240 |
240 // Starts verification of certs cached in the |crypto_config|. | 241 // Starts verification of certs cached in the |crypto_config|. |
241 QuicAsyncStatus Run(QuicCryptoClientConfig* crypto_config, | 242 QuicAsyncStatus Run(QuicCryptoClientConfig* crypto_config, |
242 const CompletionCallback& callback) { | 243 const CompletionCallback& callback) { |
243 QuicCryptoClientConfig::CachedState* cached = | 244 QuicCryptoClientConfig::CachedState* cached = |
244 crypto_config->LookupOrCreate(server_id_); | 245 crypto_config->LookupOrCreate(server_id_); |
245 ProofVerifierCallbackImpl* verify_callback = | 246 ProofVerifierCallbackImpl* verify_callback = |
246 new ProofVerifierCallbackImpl(this); | 247 new ProofVerifierCallbackImpl(this); |
247 QuicAsyncStatus status = crypto_config->proof_verifier()->VerifyCertChain( | 248 QuicAsyncStatus status = crypto_config->proof_verifier()->VerifyCertChain( |
248 server_id_.host(), cached->certs(), verify_context_.get(), | 249 server_id_.host(), cached->certs(), verify_context_.get(), |
249 &verify_error_details_, &verify_details_, | 250 &verify_error_details_, &verify_details_, |
250 std::unique_ptr<ProofVerifierCallback>(verify_callback)); | 251 std::unique_ptr<ProofVerifierCallback>(verify_callback)); |
251 if (status == QUIC_PENDING) { | 252 if (status == QUIC_PENDING) { |
252 verify_callback_ = verify_callback; | 253 verify_callback_ = verify_callback; |
253 callback_ = callback; | 254 callback_ = callback; |
254 } | 255 } |
255 return status; | 256 return status; |
256 } | 257 } |
257 | 258 |
258 void OnComplete() { | 259 void OnComplete() { |
| 260 UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime", |
| 261 base::TimeTicks::Now() - start_time_); |
259 if (!callback_.is_null()) | 262 if (!callback_.is_null()) |
260 callback_.Run(OK); | 263 callback_.Run(OK); |
261 } | 264 } |
262 | 265 |
263 const QuicServerId& server_id() const { return server_id_; } | 266 const QuicServerId& server_id() const { return server_id_; } |
264 | 267 |
265 private: | 268 private: |
266 QuicServerId server_id_; | 269 QuicServerId server_id_; |
267 ProofVerifierCallbackImpl* verify_callback_; | 270 ProofVerifierCallbackImpl* verify_callback_; |
268 std::unique_ptr<ProofVerifyContext> verify_context_; | 271 std::unique_ptr<ProofVerifyContext> verify_context_; |
269 std::unique_ptr<ProofVerifyDetails> verify_details_; | 272 std::unique_ptr<ProofVerifyDetails> verify_details_; |
270 std::string verify_error_details_; | 273 std::string verify_error_details_; |
| 274 base::TimeTicks start_time_; |
271 const BoundNetLog net_log_; | 275 const BoundNetLog net_log_; |
272 CompletionCallback callback_; | 276 CompletionCallback callback_; |
273 base::WeakPtrFactory<CertVerifierJob> weak_factory_; | 277 base::WeakPtrFactory<CertVerifierJob> weak_factory_; |
274 | 278 |
275 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob); | 279 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob); |
276 }; | 280 }; |
277 | 281 |
278 // Responsible for creating a new QUIC session to the specified server, and | 282 // Responsible for creating a new QUIC session to the specified server, and |
279 // for notifying any associated requests when complete. | 283 // for notifying any associated requests when complete. |
280 class QuicStreamFactory::Job { | 284 class QuicStreamFactory::Job { |
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 // Since the session was active, there's no longer an | 2042 // Since the session was active, there's no longer an |
2039 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 2043 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
2040 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 2044 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
2041 // it as recently broken, which means that 0-RTT will be disabled but we'll | 2045 // it as recently broken, which means that 0-RTT will be disabled but we'll |
2042 // still race. | 2046 // still race. |
2043 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 2047 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
2044 alternative_service); | 2048 alternative_service); |
2045 } | 2049 } |
2046 | 2050 |
2047 } // namespace net | 2051 } // namespace net |
OLD | NEW |