Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 void OnComplete() { | 279 void OnComplete() { |
| 280 UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime", | 280 UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime", |
| 281 base::TimeTicks::Now() - start_time_); | 281 base::TimeTicks::Now() - start_time_); |
| 282 if (!callback_.is_null()) | 282 if (!callback_.is_null()) |
| 283 base::ResetAndReturn(&callback_).Run(OK); | 283 base::ResetAndReturn(&callback_).Run(OK); |
| 284 } | 284 } |
| 285 | 285 |
| 286 const QuicServerId& server_id() const { return server_id_; } | 286 const QuicServerId& server_id() const { return server_id_; } |
| 287 | 287 |
| 288 private: | 288 private: |
| 289 QuicServerId server_id_; | 289 const QuicServerId server_id_; |
| 290 ProofVerifierCallbackImpl* verify_callback_; | 290 ProofVerifierCallbackImpl* verify_callback_; |
| 291 std::unique_ptr<ProofVerifyContext> verify_context_; | 291 std::unique_ptr<ProofVerifyContext> verify_context_; |
| 292 std::unique_ptr<ProofVerifyDetails> verify_details_; | 292 std::unique_ptr<ProofVerifyDetails> verify_details_; |
| 293 std::string verify_error_details_; | 293 std::string verify_error_details_; |
| 294 base::TimeTicks start_time_; | 294 const base::TimeTicks start_time_; |
| 295 const NetLogWithSource net_log_; | 295 const NetLogWithSource net_log_; |
| 296 CompletionCallback callback_; | 296 CompletionCallback callback_; |
| 297 base::WeakPtrFactory<CertVerifierJob> weak_factory_; | 297 base::WeakPtrFactory<CertVerifierJob> weak_factory_; |
| 298 | 298 |
| 299 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob); | 299 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob); |
| 300 }; | 300 }; |
| 301 | 301 |
| 302 // Responsible for creating a new QUIC session to the specified server, and | 302 // Responsible for creating a new QUIC session to the specified server, and |
| 303 // for notifying any associated requests when complete. | 303 // for notifying any associated requests when complete. |
| 304 class QuicStreamFactory::Job { | 304 class QuicStreamFactory::Job { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 STATE_LOAD_SERVER_INFO_COMPLETE, | 352 STATE_LOAD_SERVER_INFO_COMPLETE, |
| 353 STATE_CONNECT, | 353 STATE_CONNECT, |
| 354 STATE_RESUME_CONNECT, | 354 STATE_RESUME_CONNECT, |
| 355 STATE_CONNECT_COMPLETE, | 355 STATE_CONNECT_COMPLETE, |
| 356 }; | 356 }; |
| 357 IoState io_state_; | 357 IoState io_state_; |
| 358 | 358 |
| 359 QuicStreamFactory* factory_; | 359 QuicStreamFactory* factory_; |
| 360 HostResolver* host_resolver_; | 360 HostResolver* host_resolver_; |
| 361 std::unique_ptr<HostResolver::Request> request_; | 361 std::unique_ptr<HostResolver::Request> request_; |
| 362 QuicSessionKey key_; | 362 const QuicSessionKey key_; |
| 363 int cert_verify_flags_; | 363 const int cert_verify_flags_; |
| 364 bool was_alternative_service_recently_broken_; | 364 const bool was_alternative_service_recently_broken_; |
| 365 std::unique_ptr<QuicServerInfo> server_info_; | 365 std::unique_ptr<QuicServerInfo> server_info_; |
| 366 bool started_another_job_; | 366 bool started_another_job_; |
| 367 const NetLogWithSource net_log_; | 367 const NetLogWithSource net_log_; |
| 368 int num_sent_client_hellos_; | 368 int num_sent_client_hellos_; |
| 369 QuicChromiumClientSession* session_; | 369 QuicChromiumClientSession* session_; |
| 370 CompletionCallback callback_; | 370 CompletionCallback callback_; |
| 371 AddressList address_list_; | 371 AddressList address_list_; |
| 372 base::TimeTicks dns_resolution_start_time_; | 372 base::TimeTicks dns_resolution_start_time_; |
| 373 base::TimeTicks dns_resolution_end_time_; | 373 base::TimeTicks dns_resolution_end_time_; |
| 374 base::WeakPtrFactory<Job> weak_factory_; | 374 base::WeakPtrFactory<Job> weak_factory_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 389 cert_verify_flags_(cert_verify_flags), | 389 cert_verify_flags_(cert_verify_flags), |
| 390 was_alternative_service_recently_broken_( | 390 was_alternative_service_recently_broken_( |
| 391 was_alternative_service_recently_broken), | 391 was_alternative_service_recently_broken), |
| 392 server_info_(std::move(server_info)), | 392 server_info_(std::move(server_info)), |
| 393 started_another_job_(false), | 393 started_another_job_(false), |
| 394 net_log_(net_log), | 394 net_log_(net_log), |
| 395 num_sent_client_hellos_(0), | 395 num_sent_client_hellos_(0), |
| 396 session_(nullptr), | 396 session_(nullptr), |
| 397 weak_factory_(this) {} | 397 weak_factory_(this) {} |
| 398 | 398 |
| 399 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, | |
| 400 HostResolver* host_resolver, | |
| 401 QuicChromiumClientSession* session, | |
| 402 const QuicSessionKey& key) | |
| 403 : io_state_(STATE_RESUME_CONNECT), | |
| 404 factory_(factory), | |
| 405 host_resolver_(host_resolver), // unused | |
| 406 key_(key), | |
| 407 cert_verify_flags_(0), // unused | |
| 408 was_alternative_service_recently_broken_(false), // unused | |
| 409 started_another_job_(false), // unused | |
| 410 net_log_(session->net_log()), // unused | |
| 411 num_sent_client_hellos_(0), | |
| 412 session_(session), | |
| 413 weak_factory_(this) {} | |
|
Zhongyi Shi
2017/04/05 00:00:29
Tracing the history of this code, this Job was use
Ryan Hamilton
2017/04/05 00:10:10
Nice catch, both of you. I agree with this suggest
xunjieli
2017/04/05 15:07:29
Done. Good catch! The tests added in that CL are a
| |
| 414 | |
| 415 QuicStreamFactory::Job::~Job() { | 399 QuicStreamFactory::Job::~Job() { |
| 416 DCHECK(callback_.is_null()); | 400 DCHECK(callback_.is_null()); |
| 417 | 401 |
| 418 // If disk cache has a pending WaitForDataReadyCallback, cancel that callback. | 402 // If disk cache has a pending WaitForDataReadyCallback, cancel that callback. |
| 419 if (server_info_) | 403 if (server_info_) |
| 420 server_info_->ResetWaitForDataReadyCallback(); | 404 server_info_->ResetWaitForDataReadyCallback(); |
| 421 } | 405 } |
| 422 | 406 |
| 423 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { | 407 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { |
| 424 int rv = DoLoop(OK); | 408 int rv = DoLoop(OK); |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1989 void QuicStreamFactory::OpenFactory() { | 1973 void QuicStreamFactory::OpenFactory() { |
| 1990 status_ = OPEN; | 1974 status_ = OPEN; |
| 1991 } | 1975 } |
| 1992 | 1976 |
| 1993 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 1977 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
| 1994 if (status_ == OPEN) | 1978 if (status_ == OPEN) |
| 1995 consecutive_disabled_count_ = 0; | 1979 consecutive_disabled_count_ = 0; |
| 1996 } | 1980 } |
| 1997 | 1981 |
| 1998 } // namespace net | 1982 } // namespace net |
| OLD | NEW |