| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 | 114 |
| 115 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationSuccessCallback( | 115 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationSuccessCallback( |
| 116 QuicConnectionId connection_id, | 116 QuicConnectionId connection_id, |
| 117 NetLogCaptureMode capture_mode) { | 117 NetLogCaptureMode capture_mode) { |
| 118 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 118 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 119 dict->SetString("connection_id", base::Uint64ToString(connection_id)); | 119 dict->SetString("connection_id", base::Uint64ToString(connection_id)); |
| 120 return std::move(dict); | 120 return std::move(dict); |
| 121 } | 121 } |
| 122 | 122 |
| 123 std::unique_ptr<base::Value> NetLogQuicSessionCurrentStatusCallback( |
| 124 QuicServerId server_id, |
| 125 bool received_go_away, |
| 126 bool received_read_error, |
| 127 bool connection_closed, |
| 128 bool notified_session_going_away, |
| 129 bool notified_session_closed_later, |
| 130 bool notified_session_closed, |
| 131 NetLogCaptureMode capture_mode) { |
| 132 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 133 dict->SetString("server_id", server_id.ToString()); |
| 134 dict->SetBoolean("received_go_away", received_go_away); |
| 135 dict->SetBoolean("received_read_error", received_read_error); |
| 136 dict->SetBoolean("connection_closed", connection_closed); |
| 137 dict->SetBoolean("notified_session_going_away", notified_session_going_away); |
| 138 dict->SetBoolean("notified_session_closed_later", notified_session_closed_late
r); |
| 139 dict->SetBoolean("notified_session_closed", notified_session_closed); |
| 140 return std::move(dict); |
| 141 } |
| 142 |
| 123 // Helper class that is used to log a connection migration event. | 143 // Helper class that is used to log a connection migration event. |
| 124 class ScopedConnectionMigrationEventLog { | 144 class ScopedConnectionMigrationEventLog { |
| 125 public: | 145 public: |
| 126 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger) | 146 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger) |
| 127 : net_log_(NetLogWithSource::Make( | 147 : net_log_(NetLogWithSource::Make( |
| 128 net_log, | 148 net_log, |
| 129 NetLogSourceType::QUIC_CONNECTION_MIGRATION)) { | 149 NetLogSourceType::QUIC_CONNECTION_MIGRATION)) { |
| 130 net_log_.BeginEvent( | 150 net_log_.BeginEvent( |
| 131 NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED, | 151 NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED, |
| 132 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger)); | 152 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger)); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 void RunAuxilaryJob(); | 355 void RunAuxilaryJob(); |
| 336 | 356 |
| 337 void Cancel(); | 357 void Cancel(); |
| 338 | 358 |
| 339 void CancelWaitForDataReadyCallback(); | 359 void CancelWaitForDataReadyCallback(); |
| 340 | 360 |
| 341 const QuicSessionKey& key() const { return key_; } | 361 const QuicSessionKey& key() const { return key_; } |
| 342 | 362 |
| 343 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | 363 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } |
| 344 | 364 |
| 365 const NetLogWithSource net_log() { return job_net_log_; } |
| 366 |
| 367 // Log this Job's current state into NetLog. |
| 368 void LogCurrentStatus(); |
| 369 |
| 345 private: | 370 private: |
| 346 enum IoState { | 371 enum IoState { |
| 347 STATE_NONE, | 372 STATE_NONE, |
| 348 STATE_RESOLVE_HOST, | 373 STATE_RESOLVE_HOST, |
| 349 STATE_RESOLVE_HOST_COMPLETE, | 374 STATE_RESOLVE_HOST_COMPLETE, |
| 350 STATE_LOAD_SERVER_INFO, | 375 STATE_LOAD_SERVER_INFO, |
| 351 STATE_LOAD_SERVER_INFO_COMPLETE, | 376 STATE_LOAD_SERVER_INFO_COMPLETE, |
| 352 STATE_CONNECT, | 377 STATE_CONNECT, |
| 353 STATE_RESUME_CONNECT, | 378 STATE_RESUME_CONNECT, |
| 354 STATE_CONNECT_COMPLETE, | 379 STATE_CONNECT_COMPLETE, |
| 355 }; | 380 }; |
| 381 |
| 382 bool session_was_active_; |
| 383 bool crypto_connect_io_pending_; |
| 384 |
| 356 IoState io_state_; | 385 IoState io_state_; |
| 357 | 386 |
| 358 QuicStreamFactory* factory_; | 387 QuicStreamFactory* factory_; |
| 359 HostResolver* host_resolver_; | 388 HostResolver* host_resolver_; |
| 360 std::unique_ptr<HostResolver::Request> request_; | 389 std::unique_ptr<HostResolver::Request> request_; |
| 361 QuicSessionKey key_; | 390 QuicSessionKey key_; |
| 362 int cert_verify_flags_; | 391 int cert_verify_flags_; |
| 363 bool was_alternative_service_recently_broken_; | 392 bool was_alternative_service_recently_broken_; |
| 364 std::unique_ptr<QuicServerInfo> server_info_; | 393 std::unique_ptr<QuicServerInfo> server_info_; |
| 365 bool started_another_job_; | 394 bool started_another_job_; |
| 366 const NetLogWithSource net_log_; | 395 const NetLogWithSource net_log_; |
| 396 const NetLogWithSource job_net_log_; |
| 367 int num_sent_client_hellos_; | 397 int num_sent_client_hellos_; |
| 368 QuicChromiumClientSession* session_; | 398 QuicChromiumClientSession* session_; |
| 369 CompletionCallback callback_; | 399 CompletionCallback callback_; |
| 370 AddressList address_list_; | 400 AddressList address_list_; |
| 371 base::TimeTicks dns_resolution_start_time_; | 401 base::TimeTicks dns_resolution_start_time_; |
| 372 base::TimeTicks dns_resolution_end_time_; | 402 base::TimeTicks dns_resolution_end_time_; |
| 373 base::WeakPtrFactory<Job> weak_factory_; | 403 base::WeakPtrFactory<Job> weak_factory_; |
| 374 DISALLOW_COPY_AND_ASSIGN(Job); | 404 DISALLOW_COPY_AND_ASSIGN(Job); |
| 375 }; | 405 }; |
| 376 | 406 |
| 377 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, | 407 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, |
| 378 HostResolver* host_resolver, | 408 HostResolver* host_resolver, |
| 379 const QuicSessionKey& key, | 409 const QuicSessionKey& key, |
| 380 bool was_alternative_service_recently_broken, | 410 bool was_alternative_service_recently_broken, |
| 381 int cert_verify_flags, | 411 int cert_verify_flags, |
| 382 std::unique_ptr<QuicServerInfo> server_info, | 412 std::unique_ptr<QuicServerInfo> server_info, |
| 383 const NetLogWithSource& net_log) | 413 const NetLogWithSource& net_log) |
| 384 : io_state_(STATE_RESOLVE_HOST), | 414 : session_was_active_(false), |
| 415 crypto_connect_io_pending_(false), |
| 416 io_state_(STATE_RESOLVE_HOST), |
| 385 factory_(factory), | 417 factory_(factory), |
| 386 host_resolver_(host_resolver), | 418 host_resolver_(host_resolver), |
| 387 key_(key), | 419 key_(key), |
| 388 cert_verify_flags_(cert_verify_flags), | 420 cert_verify_flags_(cert_verify_flags), |
| 389 was_alternative_service_recently_broken_( | 421 was_alternative_service_recently_broken_( |
| 390 was_alternative_service_recently_broken), | 422 was_alternative_service_recently_broken), |
| 391 server_info_(std::move(server_info)), | 423 server_info_(std::move(server_info)), |
| 392 started_another_job_(false), | 424 started_another_job_(false), |
| 393 net_log_(net_log), | 425 net_log_(net_log), |
| 426 job_net_log_( |
| 427 NetLogWithSource::Make(net_log.net_log(), |
| 428 NetLogSourceType::QUIC_STREAM_FACTORY_JOB)), |
| 394 num_sent_client_hellos_(0), | 429 num_sent_client_hellos_(0), |
| 395 session_(nullptr), | 430 session_(nullptr), |
| 396 weak_factory_(this) {} | 431 weak_factory_(this) { |
| 432 job_net_log_.BeginEvent( |
| 433 NetLogEventType::QUIC_STREAM_FACTORY_JOB, |
| 434 NetLog::BoolCallback("resume_exisiting_session", false)); |
| 435 net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND, |
| 436 job_net_log_.source().ToEventParametersCallback()); |
| 437 |
| 438 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND, |
| 439 net_log_.source().ToEventParametersCallback()); |
| 440 } |
| 397 | 441 |
| 398 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, | 442 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, |
| 399 HostResolver* host_resolver, | 443 HostResolver* host_resolver, |
| 400 QuicChromiumClientSession* session, | 444 QuicChromiumClientSession* session, |
| 401 const QuicSessionKey& key) | 445 const QuicSessionKey& key) |
| 402 : io_state_(STATE_RESUME_CONNECT), | 446 : session_was_active_(false), |
| 447 crypto_connect_io_pending_(false), |
| 448 io_state_(STATE_RESUME_CONNECT), |
| 403 factory_(factory), | 449 factory_(factory), |
| 404 host_resolver_(host_resolver), // unused | 450 host_resolver_(host_resolver), // unused |
| 405 key_(key), | 451 key_(key), |
| 406 cert_verify_flags_(0), // unused | 452 cert_verify_flags_(0), // unused |
| 407 was_alternative_service_recently_broken_(false), // unused | 453 was_alternative_service_recently_broken_(false), // unused |
| 408 started_another_job_(false), // unused | 454 started_another_job_(false), // unused |
| 409 net_log_(session->net_log()), // unused | 455 net_log_(session->net_log()), // unused |
| 456 job_net_log_( |
| 457 NetLogWithSource::Make(session->net_log().net_log(), |
| 458 NetLogSourceType::QUIC_STREAM_FACTORY_JOB)), |
| 410 num_sent_client_hellos_(0), | 459 num_sent_client_hellos_(0), |
| 411 session_(session), | 460 session_(session), |
| 412 weak_factory_(this) {} | 461 weak_factory_(this) { |
| 462 job_net_log_.BeginEvent( |
| 463 NetLogEventType::QUIC_STREAM_FACTORY_JOB, |
| 464 NetLog::BoolCallback("resume_exisiting_session", true)); |
| 465 } |
| 413 | 466 |
| 414 QuicStreamFactory::Job::~Job() { | 467 QuicStreamFactory::Job::~Job() { |
| 468 job_net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB); |
| 415 // If disk cache has a pending WaitForDataReadyCallback, cancel that callback. | 469 // If disk cache has a pending WaitForDataReadyCallback, cancel that callback. |
| 416 if (server_info_) | 470 if (server_info_) |
| 417 server_info_->ResetWaitForDataReadyCallback(); | 471 server_info_->ResetWaitForDataReadyCallback(); |
| 418 } | 472 } |
| 419 | 473 |
| 420 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { | 474 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { |
| 421 int rv = DoLoop(OK); | 475 int rv = DoLoop(OK); |
| 422 if (rv == ERR_IO_PENDING) | 476 if (rv == ERR_IO_PENDING) |
| 423 callback_ = callback; | 477 callback_ = callback; |
| 424 | 478 |
| 425 return rv > 0 ? OK : rv; | 479 return rv > 0 ? OK : rv; |
| 426 } | 480 } |
| 427 | 481 |
| 482 void QuicStreamFactory::Job::LogCurrentStatus() { |
| 483 switch (io_state_) { |
| 484 case STATE_RESOLVE_HOST: |
| 485 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_RESOLVE_HOS
T, |
| 486 NetLog::BoolCallback("is_next", true)); |
| 487 break; |
| 488 case STATE_RESOLVE_HOST_COMPLETE: |
| 489 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_RESOLVE_HOS
T, |
| 490 NetLog::BoolCallback("is_current", true)); |
| 491 break; |
| 492 case STATE_LOAD_SERVER_INFO: |
| 493 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER
_INFO, |
| 494 NetLog::BoolCallback("is_next", true)); |
| 495 break; |
| 496 case STATE_LOAD_SERVER_INFO_COMPLETE: |
| 497 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER
_INFO, |
| 498 NetLog::BoolCallback("is_current", true)); |
| 499 break; |
| 500 case STATE_CONNECT: |
| 501 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 502 NetLog::BoolCallback("is_next_normal", true)); |
| 503 break; |
| 504 case STATE_RESUME_CONNECT: |
| 505 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 506 NetLog::BoolCallback("is_next_resume", true)); |
| 507 break; |
| 508 case STATE_CONNECT_COMPLETE: |
| 509 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 510 NetLog::BoolCallback("is_current", true)); |
| 511 break; |
| 512 case STATE_NONE: |
| 513 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 514 NetLog::BoolCallback("is_current", true)); |
| 515 break; |
| 516 default: |
| 517 break; |
| 518 } |
| 519 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOG, |
| 520 NetLog::BoolCallback("was_session_active", session_was_a
ctive_)); |
| 521 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOG, |
| 522 NetLog::BoolCallback("session_not_null", session_ != nul
lptr)); |
| 523 // Log the crypto status IF ANY. |
| 524 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOG, |
| 525 NetLog::BoolCallback("crypto_connect_io_pending", |
| 526 crypto_connect_io_pending_)); |
| 527 if (session_) { |
| 528 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOG, |
| 529 NetLog::BoolCallback("session_callback_not_run", |
| 530 session_->callback_not_null())); |
| 531 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOG, |
| 532 base::Bind(&NetLogQuicSessionCurrentStatusCallback, |
| 533 session_->server_id(), |
| 534 session_->received_go_away_, |
| 535 session_->received_read_error_, |
| 536 session_->connection_closed_, |
| 537 session_->notified_session_going_away_, |
| 538 session_->notified_session_closed_later_, |
| 539 session_->notified_session_closed_)); |
| 540 } |
| 541 } |
| 542 |
| 543 |
| 428 int QuicStreamFactory::Job::DoLoop(int rv) { | 544 int QuicStreamFactory::Job::DoLoop(int rv) { |
| 429 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::Job::DoLoop"); | 545 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::Job::DoLoop"); |
| 430 do { | 546 do { |
| 431 IoState state = io_state_; | 547 IoState state = io_state_; |
| 432 io_state_ = STATE_NONE; | 548 io_state_ = STATE_NONE; |
| 433 switch (state) { | 549 switch (state) { |
| 434 case STATE_RESOLVE_HOST: | 550 case STATE_RESOLVE_HOST: |
| 435 CHECK_EQ(OK, rv); | 551 CHECK_EQ(OK, rv); |
| 436 rv = DoResolveHost(); | 552 rv = DoResolveHost(); |
| 437 break; | 553 break; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 } | 588 } |
| 473 | 589 |
| 474 void QuicStreamFactory::Job::RunAuxilaryJob() { | 590 void QuicStreamFactory::Job::RunAuxilaryJob() { |
| 475 int rv = Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 591 int rv = Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
| 476 base::Unretained(factory_), this)); | 592 base::Unretained(factory_), this)); |
| 477 if (rv != ERR_IO_PENDING) | 593 if (rv != ERR_IO_PENDING) |
| 478 factory_->OnJobComplete(this, rv); | 594 factory_->OnJobComplete(this, rv); |
| 479 } | 595 } |
| 480 | 596 |
| 481 void QuicStreamFactory::Job::Cancel() { | 597 void QuicStreamFactory::Job::Cancel() { |
| 598 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CANCELLED); |
| 482 callback_.Reset(); | 599 callback_.Reset(); |
| 483 if (session_) | 600 if (session_) |
| 484 session_->connection()->CloseConnection( | 601 session_->connection()->CloseConnection( |
| 485 QUIC_CONNECTION_CANCELLED, "New job canceled.", | 602 QUIC_CONNECTION_CANCELLED, "New job canceled.", |
| 486 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 603 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 487 } | 604 } |
| 488 | 605 |
| 489 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { | 606 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { |
| 490 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. | 607 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. |
| 491 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) | 608 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) |
| 492 return; | 609 return; |
| 493 server_info_->CancelWaitForDataReadyCallback(); | 610 server_info_->CancelWaitForDataReadyCallback(); |
| 494 OnIOComplete(OK); | 611 OnIOComplete(OK); |
| 495 } | 612 } |
| 496 | 613 |
| 497 int QuicStreamFactory::Job::DoResolveHost() { | 614 int QuicStreamFactory::Job::DoResolveHost() { |
| 615 job_net_log_.BeginEvent( |
| 616 NetLogEventType::QUIC_STREAM_FACTORY_JOB_RESOLVE_HOST, |
| 617 NetLog::BoolCallback("load_server_info", server_info_.get() != nullptr)); |
| 498 dns_resolution_start_time_ = base::TimeTicks::Now(); | 618 dns_resolution_start_time_ = base::TimeTicks::Now(); |
| 499 // Start loading the data now, and wait for it after we resolve the host. | 619 // Start loading the data now, and wait for it after we resolve the host. |
| 500 if (server_info_) | 620 if (server_info_) |
| 501 server_info_->Start(); | 621 server_info_->Start(); |
| 502 | 622 |
| 503 io_state_ = STATE_RESOLVE_HOST_COMPLETE; | 623 io_state_ = STATE_RESOLVE_HOST_COMPLETE; |
| 504 return host_resolver_->Resolve( | 624 return host_resolver_->Resolve( |
| 505 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, | 625 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, |
| 506 &address_list_, | 626 &address_list_, |
| 507 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), | 627 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), |
| 508 &request_, net_log_); | 628 &request_, job_net_log_); |
| 509 } | 629 } |
| 510 | 630 |
| 511 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { | 631 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { |
| 632 job_net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_RESOLVE_HOST); |
| 633 |
| 512 dns_resolution_end_time_ = base::TimeTicks::Now(); | 634 dns_resolution_end_time_ = base::TimeTicks::Now(); |
| 513 if (rv != OK) | 635 if (rv != OK) |
| 514 return rv; | 636 return rv; |
| 515 | 637 |
| 516 DCHECK(!factory_->HasActiveSession(key_.server_id())); | 638 DCHECK(!factory_->HasActiveSession(key_.server_id())); |
| 517 | 639 |
| 518 // Inform the factory of this resolution, which will set up | 640 // Inform the factory of this resolution, which will set up |
| 519 // a session alias, if possible. | 641 // a session alias, if possible. |
| 520 if (factory_->OnResolution(key_, address_list_)) | 642 if (factory_->OnResolution(key_, address_list_)) { |
| 643 session_was_active_ = true; |
| 521 return OK; | 644 return OK; |
| 645 } |
| 522 | 646 |
| 523 if (server_info_) | 647 if (server_info_) |
| 524 io_state_ = STATE_LOAD_SERVER_INFO; | 648 io_state_ = STATE_LOAD_SERVER_INFO; |
| 525 else | 649 else |
| 526 io_state_ = STATE_CONNECT; | 650 io_state_ = STATE_CONNECT; |
| 527 return OK; | 651 return OK; |
| 528 } | 652 } |
| 529 | 653 |
| 530 int QuicStreamFactory::Job::DoLoadServerInfo() { | 654 int QuicStreamFactory::Job::DoLoadServerInfo() { |
| 531 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE; | 655 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE; |
| 532 | 656 |
| 533 DCHECK(server_info_); | 657 DCHECK(server_info_); |
| 534 | 658 |
| 535 // To mitigate the effects of disk cache taking too long to load QUIC server | 659 // To mitigate the effects of disk cache taking too long to load QUIC server |
| 536 // information, set up a timer to cancel WaitForDataReady's callback. | 660 // information, set up a timer to cancel WaitForDataReady's callback. |
| 661 |
| 662 int64_t load_server_info_timeout_ms = 0; |
| 537 if (factory_->load_server_info_timeout_srtt_multiplier_ > 0) { | 663 if (factory_->load_server_info_timeout_srtt_multiplier_ > 0) { |
| 538 const int kMaxLoadServerInfoTimeoutMs = 50; | 664 const int kMaxLoadServerInfoTimeoutMs = 50; |
| 539 // Wait for DiskCache a maximum of 50ms. | 665 // Wait for DiskCache a maximum of 50ms. |
| 540 int64_t load_server_info_timeout_ms = | 666 load_server_info_timeout_ms = |
| 541 std::min(static_cast<int>( | 667 std::min(static_cast<int>( |
| 542 (factory_->load_server_info_timeout_srtt_multiplier_ * | 668 (factory_->load_server_info_timeout_srtt_multiplier_ * |
| 543 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds( | 669 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds( |
| 544 key_.server_id())) / | 670 key_.server_id())) / |
| 545 1000), | 671 1000), |
| 546 kMaxLoadServerInfoTimeoutMs); | 672 kMaxLoadServerInfoTimeoutMs); |
| 547 if (load_server_info_timeout_ms > 0) { | 673 if (load_server_info_timeout_ms > 0) { |
| 548 factory_->task_runner_->PostDelayedTask( | 674 factory_->task_runner_->PostDelayedTask( |
| 549 FROM_HERE, | 675 FROM_HERE, |
| 550 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, | 676 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, |
| 551 GetWeakPtr()), | 677 GetWeakPtr()), |
| 552 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); | 678 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); |
| 553 } | 679 } |
| 554 } | 680 } |
| 555 | 681 |
| 682 job_net_log_.BeginEvent( |
| 683 NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER_INFO, |
| 684 NetLog::Int64Callback("load_server_info_timeout_ms", |
| 685 load_server_info_timeout_ms)); |
| 686 |
| 556 int rv = server_info_->WaitForDataReady( | 687 int rv = server_info_->WaitForDataReady( |
| 557 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); | 688 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); |
| 558 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) { | 689 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) { |
| 559 // If we are waiting to load server config from the disk cache, then start | 690 // If we are waiting to load server config from the disk cache, then start |
| 560 // another job. | 691 // another job. |
| 561 started_another_job_ = true; | 692 started_another_job_ = true; |
| 693 job_net_log_.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_START_AUX_JOB); |
| 562 factory_->CreateAuxilaryJob(key_, cert_verify_flags_, net_log_); | 694 factory_->CreateAuxilaryJob(key_, cert_verify_flags_, net_log_); |
| 563 } | 695 } |
| 696 |
| 564 return rv; | 697 return rv; |
| 565 } | 698 } |
| 566 | 699 |
| 567 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) { | 700 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) { |
| 568 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime", | 701 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime", |
| 569 base::TimeTicks::Now() - dns_resolution_end_time_); | 702 base::TimeTicks::Now() - dns_resolution_end_time_); |
| 570 | 703 |
| 704 job_net_log_.EndEvent( |
| 705 NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER_INFO); |
| 706 |
| 571 if (rv != OK) | 707 if (rv != OK) |
| 572 server_info_.reset(); | 708 server_info_.reset(); |
| 573 | 709 |
| 574 if (started_another_job_ && | 710 if (started_another_job_ && |
| 575 (!server_info_ || server_info_->state().server_config.empty() || | 711 (!server_info_ || server_info_->state().server_config.empty() || |
| 576 !factory_->CryptoConfigCacheIsEmpty(key_.server_id()))) { | 712 !factory_->CryptoConfigCacheIsEmpty(key_.server_id()))) { |
| 577 // If we have started another job and if we didn't load the server config | 713 // If we have started another job and if we didn't load the server config |
| 578 // from the disk cache or if we have received a new server config from the | 714 // from the disk cache or if we have received a new server config from the |
| 579 // server, then cancel the current job. | 715 // server, then cancel the current job. |
| 580 io_state_ = STATE_NONE; | 716 io_state_ = STATE_NONE; |
| 581 return ERR_CONNECTION_CLOSED; | 717 return ERR_CONNECTION_CLOSED; |
| 582 } | 718 } |
| 583 | 719 |
| 584 io_state_ = STATE_CONNECT; | 720 io_state_ = STATE_CONNECT; |
| 585 return OK; | 721 return OK; |
| 586 } | 722 } |
| 587 | 723 |
| 588 int QuicStreamFactory::Job::DoConnect() { | 724 int QuicStreamFactory::Job::DoConnect() { |
| 589 io_state_ = STATE_CONNECT_COMPLETE; | 725 io_state_ = STATE_CONNECT_COMPLETE; |
| 590 | 726 |
| 591 bool require_confirmation = factory_->require_confirmation() || | 727 bool require_confirmation = factory_->require_confirmation() || |
| 592 was_alternative_service_recently_broken_; | 728 was_alternative_service_recently_broken_; |
| 729 job_net_log_.BeginEvent( |
| 730 NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 731 NetLog::BoolCallback("require_confirmation", require_confirmation)); |
| 593 | 732 |
| 594 int rv = factory_->CreateSession( | 733 int rv = factory_->CreateSession( |
| 595 key_, cert_verify_flags_, std::move(server_info_), require_confirmation, | 734 key_, cert_verify_flags_, std::move(server_info_), require_confirmation, |
| 596 address_list_, dns_resolution_start_time_, dns_resolution_end_time_, | 735 address_list_, dns_resolution_start_time_, dns_resolution_end_time_, |
| 597 net_log_, &session_); | 736 job_net_log_, &session_); |
| 598 if (rv != OK) { | 737 if (rv != OK) { |
| 599 DCHECK(rv != ERR_IO_PENDING); | 738 DCHECK(rv != ERR_IO_PENDING); |
| 600 DCHECK(!session_); | 739 DCHECK(!session_); |
| 601 return rv; | 740 return rv; |
| 602 } | 741 } |
| 603 | 742 |
| 604 if (!session_->connection()->connected()) | 743 if (!session_->connection()->connected()) |
| 605 return ERR_CONNECTION_CLOSED; | 744 return ERR_CONNECTION_CLOSED; |
| 606 | 745 |
| 607 session_->StartReading(); | 746 session_->StartReading(); |
| 608 if (!session_->connection()->connected()) | 747 if (!session_->connection()->connected()) |
| 609 return ERR_QUIC_PROTOCOL_ERROR; | 748 return ERR_QUIC_PROTOCOL_ERROR; |
| 610 | 749 |
| 611 rv = session_->CryptoConnect( | 750 rv = session_->CryptoConnect( |
| 612 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); | 751 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); |
| 613 | 752 |
| 614 if (!session_->connection()->connected() && | 753 if (!session_->connection()->connected() && |
| 615 session_->error() == QUIC_PROOF_INVALID) { | 754 session_->error() == QUIC_PROOF_INVALID) { |
| 616 return ERR_QUIC_HANDSHAKE_FAILED; | 755 return ERR_QUIC_HANDSHAKE_FAILED; |
| 617 } | 756 } |
| 618 | 757 |
| 758 if (rv == ERR_IO_PENDING) { |
| 759 crypto_connect_io_pending_ = true; |
| 760 } |
| 761 |
| 619 return rv; | 762 return rv; |
| 620 } | 763 } |
| 621 | 764 |
| 622 int QuicStreamFactory::Job::DoResumeConnect() { | 765 int QuicStreamFactory::Job::DoResumeConnect() { |
| 766 job_net_log_.BeginEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, |
| 767 NetLog::BoolCallback("resume_connection", true)); |
| 623 io_state_ = STATE_CONNECT_COMPLETE; | 768 io_state_ = STATE_CONNECT_COMPLETE; |
| 624 | 769 |
| 625 int rv = session_->ResumeCryptoConnect( | 770 int rv = session_->ResumeCryptoConnect( |
| 626 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); | 771 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); |
| 627 | 772 |
| 628 return rv; | 773 return rv; |
| 629 } | 774 } |
| 630 | 775 |
| 631 int QuicStreamFactory::Job::DoConnectComplete(int rv) { | 776 int QuicStreamFactory::Job::DoConnectComplete(int rv) { |
| 777 job_net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT); |
| 632 if (session_ && session_->error() == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { | 778 if (session_ && session_->error() == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { |
| 633 num_sent_client_hellos_ += session_->GetNumSentClientHellos(); | 779 num_sent_client_hellos_ += session_->GetNumSentClientHellos(); |
| 634 if (num_sent_client_hellos_ >= QuicCryptoClientStream::kMaxClientHellos) | 780 if (num_sent_client_hellos_ >= QuicCryptoClientStream::kMaxClientHellos) |
| 635 return ERR_QUIC_HANDSHAKE_FAILED; | 781 return ERR_QUIC_HANDSHAKE_FAILED; |
| 636 // The handshake was rejected statelessly, so create another connection | 782 // The handshake was rejected statelessly, so create another connection |
| 637 // to resume the handshake. | 783 // to resume the handshake. |
| 638 io_state_ = STATE_CONNECT; | 784 io_state_ = STATE_CONNECT; |
| 639 return OK; | 785 return OK; |
| 640 } | 786 } |
| 641 | 787 |
| 642 if (was_alternative_service_recently_broken_) | 788 if (was_alternative_service_recently_broken_) |
| 643 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ConnectAfterBroken", rv == OK); | 789 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ConnectAfterBroken", rv == OK); |
| 644 | 790 |
| 645 if (rv != OK) | 791 if (rv != OK) |
| 646 return rv; | 792 return rv; |
| 647 | 793 |
| 648 DCHECK(!factory_->HasActiveSession(key_.server_id())); | 794 DCHECK(!factory_->HasActiveSession(key_.server_id())); |
| 649 // There may well now be an active session for this IP. If so, use the | 795 // There may well now be an active session for this IP. If so, use the |
| 650 // existing session instead. | 796 // existing session instead. |
| 651 AddressList address( | 797 AddressList address( |
| 652 session_->connection()->peer_address().impl().socket_address()); | 798 session_->connection()->peer_address().impl().socket_address()); |
| 653 if (factory_->OnResolution(key_, address)) { | 799 if (factory_->OnResolution(key_, address)) { |
| 654 session_->connection()->CloseConnection( | 800 session_->connection()->CloseConnection( |
| 655 QUIC_CONNECTION_IP_POOLED, "An active session exists for the given IP.", | 801 QUIC_CONNECTION_IP_POOLED, "An active session exists for the given IP.", |
| 656 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 802 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 803 session_was_active_ = true; |
| 657 session_ = nullptr; | 804 session_ = nullptr; |
| 658 return OK; | 805 return OK; |
| 659 } | 806 } |
| 660 | 807 |
| 661 factory_->ActivateSession(key_, session_); | 808 factory_->ActivateSession(key_, session_); |
| 809 session_was_active_ = true; |
| 662 | 810 |
| 663 return OK; | 811 return OK; |
| 664 } | 812 } |
| 665 | 813 |
| 666 QuicStreamRequest::QuicStreamRequest(QuicStreamFactory* factory) | 814 QuicStreamRequest::QuicStreamRequest(QuicStreamFactory* factory) |
| 667 : factory_(factory) {} | 815 : factory_(factory) {} |
| 668 | 816 |
| 669 QuicStreamRequest::~QuicStreamRequest() { | 817 QuicStreamRequest::~QuicStreamRequest() { |
| 670 if (factory_ && !callback_.is_null()) | 818 if (factory_ && !callback_.is_null()) |
| 671 factory_->CancelRequest(this); | 819 factory_->CancelRequest(this); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 694 DCHECK(session_); | 842 DCHECK(session_); |
| 695 return rv; | 843 return rv; |
| 696 } | 844 } |
| 697 | 845 |
| 698 void QuicStreamRequest::SetSession(QuicChromiumClientSession* session) { | 846 void QuicStreamRequest::SetSession(QuicChromiumClientSession* session) { |
| 699 DCHECK(session); | 847 DCHECK(session); |
| 700 session_ = session->GetWeakPtr(); | 848 session_ = session->GetWeakPtr(); |
| 701 } | 849 } |
| 702 | 850 |
| 703 void QuicStreamRequest::OnRequestComplete(int rv) { | 851 void QuicStreamRequest::OnRequestComplete(int rv) { |
| 852 net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM); |
| 704 factory_ = nullptr; | 853 factory_ = nullptr; |
| 705 callback_.Run(rv); | 854 callback_.Run(rv); |
| 706 } | 855 } |
| 707 | 856 |
| 708 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { | 857 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { |
| 709 if (!factory_) | 858 if (!factory_) |
| 710 return base::TimeDelta(); | 859 return base::TimeDelta(); |
| 711 return factory_->GetTimeDelayForWaitingJob(server_id_); | 860 return factory_->GetTimeDelayForWaitingJob(server_id_); |
| 712 } | 861 } |
| 713 | 862 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 bool migrate_sessions_early, | 911 bool migrate_sessions_early, |
| 763 bool allow_server_migration, | 912 bool allow_server_migration, |
| 764 bool force_hol_blocking, | 913 bool force_hol_blocking, |
| 765 bool race_cert_verification, | 914 bool race_cert_verification, |
| 766 bool do_not_fragment, | 915 bool do_not_fragment, |
| 767 bool estimate_initial_rtt, | 916 bool estimate_initial_rtt, |
| 768 const QuicTagVector& connection_options, | 917 const QuicTagVector& connection_options, |
| 769 bool enable_token_binding) | 918 bool enable_token_binding) |
| 770 : require_confirmation_(true), | 919 : require_confirmation_(true), |
| 771 net_log_(net_log), | 920 net_log_(net_log), |
| 921 quic_net_log_( |
| 922 NetLogWithSource::Make(net_log, |
| 923 NetLogSourceType::QUIC_STREAM_FACTORY)), |
| 772 host_resolver_(host_resolver), | 924 host_resolver_(host_resolver), |
| 773 client_socket_factory_(client_socket_factory), | 925 client_socket_factory_(client_socket_factory), |
| 774 http_server_properties_(http_server_properties), | 926 http_server_properties_(http_server_properties), |
| 775 push_delegate_(nullptr), | 927 push_delegate_(nullptr), |
| 776 proxy_delegate_(proxy_delegate), | 928 proxy_delegate_(proxy_delegate), |
| 777 transport_security_state_(transport_security_state), | 929 transport_security_state_(transport_security_state), |
| 778 cert_transparency_verifier_(cert_transparency_verifier), | 930 cert_transparency_verifier_(cert_transparency_verifier), |
| 779 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 931 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 780 random_generator_(random_generator), | 932 random_generator_(random_generator), |
| 781 clock_(clock), | 933 clock_(clock), |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 return false; | 1115 return false; |
| 964 } | 1116 } |
| 965 | 1117 |
| 966 int QuicStreamFactory::Create(const QuicServerId& server_id, | 1118 int QuicStreamFactory::Create(const QuicServerId& server_id, |
| 967 const HostPortPair& destination, | 1119 const HostPortPair& destination, |
| 968 int cert_verify_flags, | 1120 int cert_verify_flags, |
| 969 const GURL& url, | 1121 const GURL& url, |
| 970 base::StringPiece method, | 1122 base::StringPiece method, |
| 971 const NetLogWithSource& net_log, | 1123 const NetLogWithSource& net_log, |
| 972 QuicStreamRequest* request) { | 1124 QuicStreamRequest* request) { |
| 1125 std::string server_id_string = server_id.ToString(); |
| 1126 net_log.BeginEvent(NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM, |
| 1127 NetLog::StringCallback("server_id", &server_id_string)); |
| 973 if (clock_skew_detector_.ClockSkewDetected(base::TimeTicks::Now(), | 1128 if (clock_skew_detector_.ClockSkewDetected(base::TimeTicks::Now(), |
| 974 base::Time::Now())) { | 1129 base::Time::Now())) { |
| 975 while (!active_sessions_.empty()) { | 1130 while (!active_sessions_.empty()) { |
| 976 QuicChromiumClientSession* session = active_sessions_.begin()->second; | 1131 QuicChromiumClientSession* session = active_sessions_.begin()->second; |
| 1132 QuicServerId server_id = session->server_id(); |
| 977 OnSessionGoingAway(session); | 1133 OnSessionGoingAway(session); |
| 1134 // possible place where active_session is removed; but active_jobs not. |
| 1135 DCHECK(!HasActiveSession(server_id)); |
| 1136 DCHECK(!HasActiveJob(server_id)); |
| 978 // TODO(rch): actually close the session? | 1137 // TODO(rch): actually close the session? |
| 979 } | 1138 } |
| 980 } | 1139 } |
| 981 DCHECK(server_id.host_port_pair().Equals(HostPortPair::FromURL(url))); | 1140 DCHECK(server_id.host_port_pair().Equals(HostPortPair::FromURL(url))); |
| 982 // Enforce session affinity for promised streams. | 1141 // Enforce session affinity for promised streams. |
| 983 QuicClientPromisedInfo* promised = | 1142 QuicClientPromisedInfo* promised = |
| 984 push_promise_index_.GetPromised(url.spec()); | 1143 push_promise_index_.GetPromised(url.spec()); |
| 985 if (promised) { | 1144 if (promised) { |
| 986 QuicChromiumClientSession* session = | 1145 QuicChromiumClientSession* session = |
| 987 static_cast<QuicChromiumClientSession*>(promised->session()); | 1146 static_cast<QuicChromiumClientSession*>(promised->session()); |
| 988 DCHECK(session); | 1147 DCHECK(session); |
| 989 if (session->server_id().privacy_mode() == server_id.privacy_mode()) { | 1148 if (session->server_id().privacy_mode() == server_id.privacy_mode()) { |
| 990 request->SetSession(session); | 1149 request->SetSession(session); |
| 991 ++num_push_streams_created_; | 1150 ++num_push_streams_created_; |
| 1151 net_log.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM, |
| 1152 NetLog::BoolCallback("is_promised", true)); |
| 992 return OK; | 1153 return OK; |
| 993 } | 1154 } |
| 994 // This should happen extremely rarely (if ever), but if somehow a | 1155 // This should happen extremely rarely (if ever), but if somehow a |
| 995 // request comes in with a mismatched privacy mode, consider the | 1156 // request comes in with a mismatched privacy mode, consider the |
| 996 // promise borked. | 1157 // promise borked. |
| 997 promised->Cancel(); | 1158 promised->Cancel(); |
| 998 } | 1159 } |
| 999 | 1160 |
| 1000 // Use active session for |server_id| if such exists. | 1161 // Use active session for |server_id| if such exists. |
| 1001 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. | 1162 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. |
| 1002 if (!active_sessions_.empty()) { | 1163 if (!active_sessions_.empty()) { |
| 1003 SessionMap::iterator it = active_sessions_.find(server_id); | 1164 SessionMap::iterator it = active_sessions_.find(server_id); |
| 1004 if (it != active_sessions_.end()) { | 1165 if (it != active_sessions_.end()) { |
| 1005 QuicChromiumClientSession* session = it->second; | 1166 QuicChromiumClientSession* session = it->second; |
| 1006 request->SetSession(session); | 1167 request->SetSession(session); |
| 1168 net_log.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM, |
| 1169 NetLog::BoolCallback("active_session_exists", true)); |
| 1007 return OK; | 1170 return OK; |
| 1008 } | 1171 } |
| 1009 } | 1172 } |
| 1010 | 1173 |
| 1011 // Associate with active job to |server_id| if such exists. | 1174 // Associate with active job to |server_id| if such exists. |
| 1012 if (HasActiveJob(server_id)) { | 1175 if (HasActiveJob(server_id)) { |
| 1013 active_requests_[request] = server_id; | 1176 active_requests_[request] = server_id; |
| 1014 job_requests_map_[server_id].insert(request); | 1177 job_requests_map_[server_id].insert(request); |
| 1178 if (active_jobs_[server_id].size() == 1) { |
| 1179 const NetLogWithSource job_net_log = |
| 1180 active_jobs_[server_id].begin()->first->net_log(); |
| 1181 job_net_log.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND, |
| 1182 net_log.source().ToEventParametersCallback()); |
| 1183 net_log.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND, |
| 1184 job_net_log.source().ToEventParametersCallback()); |
| 1185 active_jobs_[server_id].begin()->first->LogCurrentStatus(); |
| 1186 } |
| 1187 // Safe access, HasActiveJob. |
| 1188 size_t job_count = active_jobs_[server_id].size(); |
| 1189 net_log.AddEvent( |
| 1190 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_BOUND_TO_ACTIVE_JOB, |
| 1191 NetLog::Int64Callback("job_count", job_count)); |
| 1192 net_log.AddEvent( |
| 1193 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_BOUND_TO_ACTIVE_JOB, |
| 1194 NetLog::BoolCallback("active_jobs_exist", true)); |
| 1015 return ERR_IO_PENDING; | 1195 return ERR_IO_PENDING; |
| 1016 } | 1196 } |
| 1017 | 1197 |
| 1018 // Pool to active session to |destination| if possible. | 1198 // Pool to active session to |destination| if possible. |
| 1019 if (!active_sessions_.empty() && !disable_connection_pooling_) { | 1199 if (!active_sessions_.empty() && !disable_connection_pooling_) { |
| 1020 for (const auto& key_value : active_sessions_) { | 1200 for (const auto& key_value : active_sessions_) { |
| 1021 QuicChromiumClientSession* session = key_value.second; | 1201 QuicChromiumClientSession* session = key_value.second; |
| 1022 if (destination.Equals(all_sessions_[session].destination()) && | 1202 if (destination.Equals(all_sessions_[session].destination()) && |
| 1023 session->CanPool(server_id.host(), server_id.privacy_mode())) { | 1203 session->CanPool(server_id.host(), server_id.privacy_mode())) { |
| 1024 request->SetSession(session); | 1204 request->SetSession(session); |
| 1205 net_log.EndEvent( |
| 1206 NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM, |
| 1207 NetLog::BoolCallback("pool_to_active_session", true)); |
| 1025 return OK; | 1208 return OK; |
| 1026 } | 1209 } |
| 1027 } | 1210 } |
| 1028 } | 1211 } |
| 1029 | 1212 |
| 1030 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ | 1213 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ |
| 1031 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. | 1214 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. |
| 1032 if (!task_runner_) | 1215 if (!task_runner_) |
| 1033 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); | 1216 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); |
| 1034 | 1217 |
| 1035 std::unique_ptr<QuicServerInfo> quic_server_info; | 1218 std::unique_ptr<QuicServerInfo> quic_server_info; |
| 1036 if (quic_server_info_factory_.get()) { | 1219 if (quic_server_info_factory_.get()) { |
| 1037 bool load_from_disk_cache = !disable_disk_cache_; | 1220 bool load_from_disk_cache = !disable_disk_cache_; |
| 1038 MaybeInitialize(); | 1221 MaybeInitialize(); |
| 1039 if (!base::ContainsKey(quic_supported_servers_at_startup_, destination)) { | 1222 if (!base::ContainsKey(quic_supported_servers_at_startup_, destination)) { |
| 1040 // If there is no entry for QUIC, consider that as a new server and | 1223 // If there is no entry for QUIC, consider that as a new server and |
| 1041 // don't wait for Cache thread to load the data for that server. | 1224 // don't wait for Cache thread to load the data for that server. |
| 1042 load_from_disk_cache = false; | 1225 load_from_disk_cache = false; |
| 1043 } | 1226 } |
| 1044 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) | 1227 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) |
| 1045 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | 1228 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
| 1046 } | 1229 } |
| 1047 | 1230 |
| 1048 ignore_result(StartCertVerifyJob(server_id, cert_verify_flags, net_log)); | 1231 ignore_result(StartCertVerifyJob(server_id, cert_verify_flags, net_log)); |
| 1049 | 1232 |
| 1050 QuicSessionKey key(destination, server_id); | 1233 QuicSessionKey key(destination, server_id); |
| 1234 |
| 1235 size_t job_count; |
| 1236 // Log that we create a new Job to serve the request. |
| 1237 net_log.AddEvent(NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_CREATE_NEW_JOB); |
| 1238 |
| 1051 std::unique_ptr<Job> job = base::MakeUnique<Job>( | 1239 std::unique_ptr<Job> job = base::MakeUnique<Job>( |
| 1052 this, host_resolver_, key, WasQuicRecentlyBroken(server_id), | 1240 this, host_resolver_, key, WasQuicRecentlyBroken(server_id), |
| 1053 cert_verify_flags, std::move(quic_server_info), net_log); | 1241 cert_verify_flags, std::move(quic_server_info), net_log); |
| 1054 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 1242 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
| 1055 base::Unretained(this), job.get())); | 1243 base::Unretained(this), job.get())); |
| 1056 if (rv == ERR_IO_PENDING) { | 1244 if (rv == ERR_IO_PENDING) { |
| 1057 active_requests_[request] = server_id; | 1245 active_requests_[request] = server_id; |
| 1058 job_requests_map_[server_id].insert(request); | 1246 job_requests_map_[server_id].insert(request); |
| 1059 Job* job_ptr = job.get(); | 1247 Job* job_ptr = job.get(); |
| 1060 active_jobs_[server_id][job_ptr] = std::move(job); | 1248 active_jobs_[server_id][job_ptr] = std::move(job); |
| 1249 |
| 1250 // Safe access after insertion. |
| 1251 job_count = active_jobs_[server_id].size(); |
| 1252 |
| 1253 // The new job can't finish immediately, added to active job list. |
| 1254 net_log.AddEvent( |
| 1255 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_NEW_JOB_PENDING, |
| 1256 NetLog::Int64Callback("active_job_count", job_count)); |
| 1257 |
| 1258 // Once one of the associated job finishes, QuicStreamFactory::OnJobComplete |
| 1259 // will be invoked. On success, notify all the requests. Else if there's no |
| 1260 // other job, it will notify request(s). Else, ignore if there's other jobs |
| 1261 // running. |
| 1061 return rv; | 1262 return rv; |
| 1062 } | 1263 } |
| 1063 if (rv == OK) { | 1264 if (rv == OK) { |
| 1265 job_count = 0; |
| 1266 if (HasActiveJob(server_id)) { |
| 1267 job_count = active_jobs_[server_id].size(); |
| 1268 } |
| 1269 bool active_session_found = |
| 1270 (active_sessions_.find(server_id) != active_sessions_.end()); |
| 1271 net_log.AddEvent( |
| 1272 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_NEW_JOB_SUCCEED, |
| 1273 NetLog::Int64Callback("job_count", job_count)); |
| 1274 net_log.AddEvent( |
| 1275 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_NEW_JOB_SUCCEED, |
| 1276 NetLog::BoolCallback("active_session_found", active_session_found)); |
| 1064 // TODO(rtenneti): crbug.com/498823 - revert active_sessions_.empty() | 1277 // TODO(rtenneti): crbug.com/498823 - revert active_sessions_.empty() |
| 1065 // related changes. | 1278 // related changes. |
| 1066 if (active_sessions_.empty()) | 1279 if (active_sessions_.empty()) |
| 1067 return ERR_QUIC_PROTOCOL_ERROR; | 1280 return ERR_QUIC_PROTOCOL_ERROR; |
| 1068 SessionMap::iterator it = active_sessions_.find(server_id); | 1281 SessionMap::iterator it = active_sessions_.find(server_id); |
| 1069 DCHECK(it != active_sessions_.end()); | 1282 DCHECK(it != active_sessions_.end()); |
| 1070 if (it == active_sessions_.end()) | 1283 if (it == active_sessions_.end()) |
| 1071 return ERR_QUIC_PROTOCOL_ERROR; | 1284 return ERR_QUIC_PROTOCOL_ERROR; |
| 1072 QuicChromiumClientSession* session = it->second; | 1285 QuicChromiumClientSession* session = it->second; |
| 1073 request->SetSession(session); | 1286 request->SetSession(session); |
| 1287 } else { |
| 1288 job_count = 0; |
| 1289 if (HasActiveJob(server_id)) { |
| 1290 job_count = active_jobs_[server_id].size(); |
| 1291 } |
| 1292 |
| 1293 bool active_session_found = |
| 1294 (active_sessions_.find(server_id) != active_sessions_.end()); |
| 1295 net_log.AddEvent( |
| 1296 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_NEW_JOB_FAILED, |
| 1297 NetLog::Int64Callback("job_count", job_count)); |
| 1298 net_log.AddEvent( |
| 1299 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_NEW_JOB_FAILED, |
| 1300 NetLog::BoolCallback("active_session_found", active_session_found)); |
| 1074 } | 1301 } |
| 1302 net_log.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_CREATE_HTTP_STREAM); |
| 1075 return rv; | 1303 return rv; |
| 1076 } | 1304 } |
| 1077 | 1305 |
| 1078 QuicStreamFactory::QuicSessionKey::QuicSessionKey( | 1306 QuicStreamFactory::QuicSessionKey::QuicSessionKey( |
| 1079 const HostPortPair& destination, | 1307 const HostPortPair& destination, |
| 1080 const QuicServerId& server_id) | 1308 const QuicServerId& server_id) |
| 1081 : destination_(destination), server_id_(server_id) {} | 1309 : destination_(destination), server_id_(server_id) {} |
| 1082 | 1310 |
| 1083 bool QuicStreamFactory::QuicSessionKey::operator<( | 1311 bool QuicStreamFactory::QuicSessionKey::operator<( |
| 1084 const QuicSessionKey& other) const { | 1312 const QuicSessionKey& other) const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 if (disable_connection_pooling_) | 1344 if (disable_connection_pooling_) |
| 1117 return false; | 1345 return false; |
| 1118 for (const IPEndPoint& address : address_list) { | 1346 for (const IPEndPoint& address : address_list) { |
| 1119 if (!base::ContainsKey(ip_aliases_, address)) | 1347 if (!base::ContainsKey(ip_aliases_, address)) |
| 1120 continue; | 1348 continue; |
| 1121 | 1349 |
| 1122 const SessionSet& sessions = ip_aliases_[address]; | 1350 const SessionSet& sessions = ip_aliases_[address]; |
| 1123 for (QuicChromiumClientSession* session : sessions) { | 1351 for (QuicChromiumClientSession* session : sessions) { |
| 1124 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) | 1352 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) |
| 1125 continue; | 1353 continue; |
| 1354 std::string server_id_string = server_id.ToString(); |
| 1355 quic_net_log_.AddEvent( |
| 1356 NetLogEventType::QUIC_STREAM_FACTORY_ACTIVE_SESSION_INSERTION, |
| 1357 NetLog::StringCallback("server_id", &server_id_string)); |
| 1126 active_sessions_[server_id] = session; | 1358 active_sessions_[server_id] = session; |
| 1127 session_aliases_[session].insert(key); | 1359 session_aliases_[session].insert(key); |
| 1128 return true; | 1360 return true; |
| 1129 } | 1361 } |
| 1130 } | 1362 } |
| 1131 return false; | 1363 return false; |
| 1132 } | 1364 } |
| 1133 | 1365 |
| 1134 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { | 1366 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { |
| 1135 // Copy |server_id|, because |job| might be destroyed before this method | 1367 // Copy |server_id|, because |job| might be destroyed before this method |
| 1136 // returns. | 1368 // returns. |
| 1137 const QuicServerId server_id(job->key().server_id()); | 1369 const QuicServerId server_id(job->key().server_id()); |
| 1370 std::string server_id_string = server_id.ToString(); |
| 1371 quic_net_log_.BeginEvent( |
| 1372 NetLogEventType::QUIC_STREAM_FACTORY_JOB_COMPLETE, |
| 1373 NetLog::StringCallback("server id", &server_id_string)); |
| 1374 |
| 1138 if (rv != OK) { | 1375 if (rv != OK) { |
| 1376 CHECK(HasActiveJob(server_id)); |
| 1139 JobSet* jobs = &(active_jobs_[server_id]); | 1377 JobSet* jobs = &(active_jobs_[server_id]); |
| 1140 if (jobs->size() > 1) { | 1378 if (jobs->size() > 1) { |
| 1141 // If there is another pending job, then we can delete this job and let | 1379 // If there is another pending job, then we can delete this job and let |
| 1142 // the other job handle the request. | 1380 // the other job handle the request. |
| 1381 job->net_log().AddEvent( |
| 1382 NetLogEventType::QUIC_STREAM_FACTORY_JOB_CANCELLED_BY_FACTORY); |
| 1383 |
| 1143 job->Cancel(); | 1384 job->Cancel(); |
| 1385 |
| 1386 size_t job_count = active_jobs_[server_id].size(); |
| 1387 quic_net_log_.AddEvent( |
| 1388 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_ACTIVE_JOB_COUNT, |
| 1389 NetLog::Int64Callback("job count before erase", job_count)); |
| 1144 jobs->erase(job); | 1390 jobs->erase(job); |
| 1391 job_count = active_jobs_[server_id].size(); |
| 1392 quic_net_log_.EndEvent( |
| 1393 NetLogEventType::QUIC_STREAM_FACTORY_JOB_COMPLETE, |
| 1394 NetLog::BoolCallback("has_active_job", HasActiveJob(server_id))); |
| 1145 return; | 1395 return; |
| 1146 } | 1396 } |
| 1147 } | 1397 } |
| 1148 | 1398 |
| 1399 job->net_log().AddEvent( |
| 1400 NetLogEventType::QUIC_STREAM_FACTORY_JOB_COMPLTE_FROM_FACTORY, |
| 1401 NetLog::BoolCallback("is_success", rv == OK)); |
| 1402 |
| 1149 if (rv == OK) { | 1403 if (rv == OK) { |
| 1150 if (!always_require_handshake_confirmation_) | 1404 if (!always_require_handshake_confirmation_) |
| 1151 set_require_confirmation(false); | 1405 set_require_confirmation(false); |
| 1152 | 1406 |
| 1153 if (!job_requests_map_[server_id].empty()) { | 1407 if (!job_requests_map_[server_id].empty()) { |
| 1154 SessionMap::iterator session_it = active_sessions_.find(server_id); | 1408 SessionMap::iterator session_it = active_sessions_.find(server_id); |
| 1155 DCHECK(session_it != active_sessions_.end()); | 1409 DCHECK(session_it != active_sessions_.end()); |
| 1156 QuicChromiumClientSession* session = session_it->second; | 1410 QuicChromiumClientSession* session = session_it->second; |
| 1157 for (QuicStreamRequest* request : job_requests_map_[server_id]) { | 1411 for (QuicStreamRequest* request : job_requests_map_[server_id]) { |
| 1158 DCHECK(request->server_id() == server_id); | 1412 DCHECK(request->server_id() == server_id); |
| 1159 // Do not notify |request| yet. | 1413 // Do not notify |request| yet. |
| 1160 request->SetSession(session); | 1414 request->SetSession(session); |
| 1161 } | 1415 } |
| 1162 } | 1416 } |
| 1163 } | 1417 } |
| 1164 | 1418 |
| 1165 while (!job_requests_map_[server_id].empty()) { | 1419 while (!job_requests_map_[server_id].empty()) { |
| 1166 RequestSet::iterator it = job_requests_map_[server_id].begin(); | 1420 RequestSet::iterator it = job_requests_map_[server_id].begin(); |
| 1167 QuicStreamRequest* request = *it; | 1421 QuicStreamRequest* request = *it; |
| 1168 job_requests_map_[server_id].erase(it); | 1422 job_requests_map_[server_id].erase(it); |
| 1169 active_requests_.erase(request); | 1423 active_requests_.erase(request); |
| 1170 // Even though we're invoking callbacks here, we don't need to worry | 1424 // Even though we're invoking callbacks here, we don't need to worry |
| 1171 // about |this| being deleted, because the factory is owned by the | 1425 // about |this| being deleted, because the factory is owned by the |
| 1172 // profile which can not be deleted via callbacks. | 1426 // profile which can not be deleted via callbacks. |
| 1173 request->OnRequestComplete(rv); | 1427 request->OnRequestComplete(rv); |
| 1174 } | 1428 } |
| 1175 | 1429 |
| 1430 CHECK(HasActiveJob(server_id)); |
| 1431 |
| 1176 for (auto& other_job : active_jobs_[server_id]) { | 1432 for (auto& other_job : active_jobs_[server_id]) { |
| 1177 if (other_job.first != job) | 1433 if (other_job.first != job) { |
| 1434 other_job.first->net_log().AddEvent( |
| 1435 NetLogEventType::QUIC_STREAM_FACTORY_JOB_CANCELLED_BY_FACTORY); |
| 1178 other_job.first->Cancel(); | 1436 other_job.first->Cancel(); |
| 1437 } |
| 1179 } | 1438 } |
| 1180 | 1439 |
| 1440 size_t job_count = active_jobs_[server_id].size(); |
| 1441 quic_net_log_.AddEvent( |
| 1442 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_ACTIVE_JOB_COUNT, |
| 1443 NetLog::Int64Callback("job count before clear", job_count)); |
| 1444 |
| 1181 active_jobs_[server_id].clear(); | 1445 active_jobs_[server_id].clear(); |
| 1182 active_jobs_.erase(server_id); | 1446 active_jobs_.erase(server_id); |
| 1183 job_requests_map_.erase(server_id); | 1447 job_requests_map_.erase(server_id); |
| 1448 |
| 1449 quic_net_log_.EndEvent( |
| 1450 NetLogEventType::QUIC_STREAM_FACTORY_JOB_COMPLETE, |
| 1451 NetLog::BoolCallback("has_active_job", HasActiveJob(server_id))); |
| 1184 } | 1452 } |
| 1185 | 1453 |
| 1186 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { | 1454 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { |
| 1187 active_cert_verifier_jobs_.erase(job->server_id()); | 1455 active_cert_verifier_jobs_.erase(job->server_id()); |
| 1188 } | 1456 } |
| 1189 | 1457 |
| 1190 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( | 1458 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( |
| 1191 QuicChromiumClientSession* session) { | 1459 QuicChromiumClientSession* session) { |
| 1192 return std::unique_ptr<QuicHttpStream>( | 1460 return std::unique_ptr<QuicHttpStream>( |
| 1193 new QuicHttpStream(session->GetWeakPtr())); | 1461 new QuicHttpStream(session->GetWeakPtr())); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); | 1498 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); |
| 1231 ++it) { | 1499 ++it) { |
| 1232 const QuicServerId& server_id = it->server_id(); | 1500 const QuicServerId& server_id = it->server_id(); |
| 1233 DCHECK(active_sessions_.count(server_id)); | 1501 DCHECK(active_sessions_.count(server_id)); |
| 1234 DCHECK_EQ(session, active_sessions_[server_id]); | 1502 DCHECK_EQ(session, active_sessions_[server_id]); |
| 1235 // Track sessions which have recently gone away so that we can disable | 1503 // Track sessions which have recently gone away so that we can disable |
| 1236 // port suggestions. | 1504 // port suggestions. |
| 1237 if (session->goaway_received()) | 1505 if (session->goaway_received()) |
| 1238 gone_away_aliases_.insert(*it); | 1506 gone_away_aliases_.insert(*it); |
| 1239 | 1507 |
| 1508 std::string server_id_string = server_id.ToString(); |
| 1509 quic_net_log_.AddEvent( |
| 1510 NetLogEventType::QUIC_STREAM_FACTORY_ACTIVE_SESSION_DELETION, |
| 1511 NetLog::StringCallback("server_id", &server_id_string)); |
| 1240 active_sessions_.erase(server_id); | 1512 active_sessions_.erase(server_id); |
| 1241 ProcessGoingAwaySession(session, server_id, true); | 1513 ProcessGoingAwaySession(session, server_id, true); |
| 1242 } | 1514 } |
| 1243 ProcessGoingAwaySession(session, all_sessions_[session].server_id(), false); | 1515 ProcessGoingAwaySession(session, all_sessions_[session].server_id(), false); |
| 1244 if (!aliases.empty()) { | 1516 if (!aliases.empty()) { |
| 1245 DCHECK(base::ContainsKey(session_peer_ip_, session)); | 1517 DCHECK(base::ContainsKey(session_peer_ip_, session)); |
| 1246 const IPEndPoint peer_address = session_peer_ip_[session]; | 1518 const IPEndPoint peer_address = session_peer_ip_[session]; |
| 1247 ip_aliases_[peer_address].erase(session); | 1519 ip_aliases_[peer_address].erase(session); |
| 1248 if (ip_aliases_[peer_address].empty()) | 1520 if (ip_aliases_[peer_address].empty()) |
| 1249 ip_aliases_.erase(peer_address); | 1521 ip_aliases_.erase(peer_address); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); | 1843 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); |
| 1572 } | 1844 } |
| 1573 | 1845 |
| 1574 bool QuicStreamFactory::HasActiveSession(const QuicServerId& server_id) const { | 1846 bool QuicStreamFactory::HasActiveSession(const QuicServerId& server_id) const { |
| 1575 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() check. | 1847 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() check. |
| 1576 if (active_sessions_.empty()) | 1848 if (active_sessions_.empty()) |
| 1577 return false; | 1849 return false; |
| 1578 return base::ContainsKey(active_sessions_, server_id); | 1850 return base::ContainsKey(active_sessions_, server_id); |
| 1579 } | 1851 } |
| 1580 | 1852 |
| 1581 bool QuicStreamFactory::HasActiveJob(const QuicServerId& server_id) const { | 1853 bool QuicStreamFactory::HasActiveJob(const QuicServerId& server_id) { |
| 1582 return base::ContainsKey(active_jobs_, server_id); | 1854 bool has = base::ContainsKey(active_jobs_, server_id); |
| 1855 |
| 1856 size_t job_count = 0; |
| 1857 if (has) { |
| 1858 job_count = active_jobs_[server_id].size(); |
| 1859 } |
| 1860 |
| 1861 quic_net_log_.AddEvent( |
| 1862 NetLogEventType::QUIC_STREAM_FACTORY_REQUEST_ACTIVE_JOB_COUNT, |
| 1863 NetLog::Int64Callback("has_active_job_count", job_count)); |
| 1864 return has; |
| 1583 } | 1865 } |
| 1584 | 1866 |
| 1585 bool QuicStreamFactory::HasActiveCertVerifierJob( | 1867 bool QuicStreamFactory::HasActiveCertVerifierJob( |
| 1586 const QuicServerId& server_id) const { | 1868 const QuicServerId& server_id) const { |
| 1587 return base::ContainsKey(active_cert_verifier_jobs_, server_id); | 1869 return base::ContainsKey(active_cert_verifier_jobs_, server_id); |
| 1588 } | 1870 } |
| 1589 | 1871 |
| 1590 int QuicStreamFactory::ConfigureSocket(DatagramClientSocket* socket, | 1872 int QuicStreamFactory::ConfigureSocket(DatagramClientSocket* socket, |
| 1591 IPEndPoint addr, | 1873 IPEndPoint addr, |
| 1592 NetworkHandle network) { | 1874 NetworkHandle network) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 return ERR_CONNECTION_CLOSED; | 2033 return ERR_CONNECTION_CLOSED; |
| 1752 } | 2034 } |
| 1753 return OK; | 2035 return OK; |
| 1754 } | 2036 } |
| 1755 | 2037 |
| 1756 void QuicStreamFactory::ActivateSession(const QuicSessionKey& key, | 2038 void QuicStreamFactory::ActivateSession(const QuicSessionKey& key, |
| 1757 QuicChromiumClientSession* session) { | 2039 QuicChromiumClientSession* session) { |
| 1758 const QuicServerId& server_id(key.server_id()); | 2040 const QuicServerId& server_id(key.server_id()); |
| 1759 DCHECK(!HasActiveSession(server_id)); | 2041 DCHECK(!HasActiveSession(server_id)); |
| 1760 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); | 2042 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); |
| 2043 std::string server_id_string = server_id.ToString(); |
| 2044 quic_net_log_.AddEvent( |
| 2045 NetLogEventType::QUIC_STREAM_FACTORY_ACTIVE_SESSION_INSERTION, |
| 2046 NetLog::StringCallback("server_id", &server_id_string)); |
| 1761 active_sessions_[server_id] = session; | 2047 active_sessions_[server_id] = session; |
| 1762 session_aliases_[session].insert(key); | 2048 session_aliases_[session].insert(key); |
| 1763 const IPEndPoint peer_address = | 2049 const IPEndPoint peer_address = |
| 1764 session->connection()->peer_address().impl().socket_address(); | 2050 session->connection()->peer_address().impl().socket_address(); |
| 1765 DCHECK(!base::ContainsKey(ip_aliases_[peer_address], session)); | 2051 DCHECK(!base::ContainsKey(ip_aliases_[peer_address], session)); |
| 1766 ip_aliases_[peer_address].insert(session); | 2052 ip_aliases_[peer_address].insert(session); |
| 1767 DCHECK(!base::ContainsKey(session_peer_ip_, session)); | 2053 DCHECK(!base::ContainsKey(session_peer_ip_, session)); |
| 1768 session_peer_ip_[session] = peer_address; | 2054 session_peer_ip_[session] = peer_address; |
| 1769 } | 2055 } |
| 1770 | 2056 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 void QuicStreamFactory::OpenFactory() { | 2269 void QuicStreamFactory::OpenFactory() { |
| 1984 status_ = OPEN; | 2270 status_ = OPEN; |
| 1985 } | 2271 } |
| 1986 | 2272 |
| 1987 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 2273 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
| 1988 if (status_ == OPEN) | 2274 if (status_ == OPEN) |
| 1989 consecutive_disabled_count_ = 0; | 2275 consecutive_disabled_count_ = 0; |
| 1990 } | 2276 } |
| 1991 | 2277 |
| 1992 } // namespace net | 2278 } // namespace net |
| OLD | NEW |