Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: net/quic/chromium/quic_stream_factory.cc

Issue 2820573004: Remove the code to store and load QUIC server configs in the disk cache. (Closed)
Patch Set: Fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_peer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 // Responsible for creating a new QUIC session to the specified server, and 325 // Responsible for creating a new QUIC session to the specified server, and
326 // for notifying any associated requests when complete. 326 // for notifying any associated requests when complete.
327 class QuicStreamFactory::Job { 327 class QuicStreamFactory::Job {
328 public: 328 public:
329 Job(QuicStreamFactory* factory, 329 Job(QuicStreamFactory* factory,
330 HostResolver* host_resolver, 330 HostResolver* host_resolver,
331 const QuicSessionKey& key, 331 const QuicSessionKey& key,
332 bool was_alternative_service_recently_broken, 332 bool was_alternative_service_recently_broken,
333 int cert_verify_flags, 333 int cert_verify_flags,
334 std::unique_ptr<QuicServerInfo> server_info,
335 const NetLogWithSource& net_log); 334 const NetLogWithSource& net_log);
336 335
337 // Creates a new job to handle the resumption of for connecting an
338 // existing session.
339 Job(QuicStreamFactory* factory,
340 HostResolver* host_resolver,
341 QuicChromiumClientSession* session,
342 const QuicSessionKey& key);
343
344 ~Job(); 336 ~Job();
345 337
346 int Run(const CompletionCallback& callback); 338 int Run(const CompletionCallback& callback);
347 339
348 int DoLoop(int rv); 340 int DoLoop(int rv);
349 int DoResolveHost(); 341 int DoResolveHost();
350 int DoResolveHostComplete(int rv); 342 int DoResolveHostComplete(int rv);
351 int DoLoadServerInfo();
352 int DoLoadServerInfoComplete(int rv);
353 int DoConnect(); 343 int DoConnect();
354 int DoConnectComplete(int rv); 344 int DoConnectComplete(int rv);
355 345
356 void OnIOComplete(int rv); 346 void OnIOComplete(int rv);
357 347
358 void RunAuxilaryJob();
359
360 void Cancel(); 348 void Cancel();
361 349
362 void CancelWaitForDataReadyCallback();
363
364 const QuicSessionKey& key() const { return key_; } 350 const QuicSessionKey& key() const { return key_; }
365 351
366 const NetLogWithSource& net_log() const { return net_log_; } 352 const NetLogWithSource& net_log() const { return net_log_; }
367 353
368 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 354 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
369 355
370 // Returns the estimate of dynamically allocated memory in bytes. 356 // Returns the estimate of dynamically allocated memory in bytes.
371 size_t EstimateMemoryUsage() const; 357 size_t EstimateMemoryUsage() const;
372 358
373 private: 359 private:
374 enum IoState { 360 enum IoState {
375 STATE_NONE, 361 STATE_NONE,
376 STATE_RESOLVE_HOST, 362 STATE_RESOLVE_HOST,
377 STATE_RESOLVE_HOST_COMPLETE, 363 STATE_RESOLVE_HOST_COMPLETE,
378 STATE_LOAD_SERVER_INFO,
379 STATE_LOAD_SERVER_INFO_COMPLETE,
380 STATE_CONNECT, 364 STATE_CONNECT,
381 STATE_CONNECT_COMPLETE, 365 STATE_CONNECT_COMPLETE,
382 }; 366 };
383 IoState io_state_; 367 IoState io_state_;
384 368
385 QuicStreamFactory* factory_; 369 QuicStreamFactory* factory_;
386 HostResolver* host_resolver_; 370 HostResolver* host_resolver_;
387 std::unique_ptr<HostResolver::Request> request_; 371 std::unique_ptr<HostResolver::Request> request_;
388 const QuicSessionKey key_; 372 const QuicSessionKey key_;
389 const int cert_verify_flags_; 373 const int cert_verify_flags_;
390 const bool was_alternative_service_recently_broken_; 374 const bool was_alternative_service_recently_broken_;
391 std::unique_ptr<QuicServerInfo> server_info_;
392 bool started_another_job_;
393 const NetLogWithSource net_log_; 375 const NetLogWithSource net_log_;
394 int num_sent_client_hellos_; 376 int num_sent_client_hellos_;
395 QuicChromiumClientSession* session_; 377 QuicChromiumClientSession* session_;
396 CompletionCallback callback_; 378 CompletionCallback callback_;
397 AddressList address_list_; 379 AddressList address_list_;
398 base::TimeTicks dns_resolution_start_time_; 380 base::TimeTicks dns_resolution_start_time_;
399 base::TimeTicks dns_resolution_end_time_; 381 base::TimeTicks dns_resolution_end_time_;
400 base::WeakPtrFactory<Job> weak_factory_; 382 base::WeakPtrFactory<Job> weak_factory_;
401 DISALLOW_COPY_AND_ASSIGN(Job); 383 DISALLOW_COPY_AND_ASSIGN(Job);
402 }; 384 };
403 385
404 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, 386 QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
405 HostResolver* host_resolver, 387 HostResolver* host_resolver,
406 const QuicSessionKey& key, 388 const QuicSessionKey& key,
407 bool was_alternative_service_recently_broken, 389 bool was_alternative_service_recently_broken,
408 int cert_verify_flags, 390 int cert_verify_flags,
409 std::unique_ptr<QuicServerInfo> server_info,
410 const NetLogWithSource& net_log) 391 const NetLogWithSource& net_log)
411 : io_state_(STATE_RESOLVE_HOST), 392 : io_state_(STATE_RESOLVE_HOST),
412 factory_(factory), 393 factory_(factory),
413 host_resolver_(host_resolver), 394 host_resolver_(host_resolver),
414 key_(key), 395 key_(key),
415 cert_verify_flags_(cert_verify_flags), 396 cert_verify_flags_(cert_verify_flags),
416 was_alternative_service_recently_broken_( 397 was_alternative_service_recently_broken_(
417 was_alternative_service_recently_broken), 398 was_alternative_service_recently_broken),
418 server_info_(std::move(server_info)),
419 started_another_job_(false),
420 net_log_( 399 net_log_(
421 NetLogWithSource::Make(net_log.net_log(), 400 NetLogWithSource::Make(net_log.net_log(),
422 NetLogSourceType::QUIC_STREAM_FACTORY_JOB)), 401 NetLogSourceType::QUIC_STREAM_FACTORY_JOB)),
423 num_sent_client_hellos_(0), 402 num_sent_client_hellos_(0),
424 session_(nullptr), 403 session_(nullptr),
425 weak_factory_(this) { 404 weak_factory_(this) {
426 net_log_.BeginEvent( 405 net_log_.BeginEvent(
427 NetLogEventType::QUIC_STREAM_FACTORY_JOB, 406 NetLogEventType::QUIC_STREAM_FACTORY_JOB,
428 base::Bind(&NetLogQuicStreamFactoryJobCallback, &key_.server_id())); 407 base::Bind(&NetLogQuicStreamFactoryJobCallback, &key_.server_id()));
429 // Associate |net_log_| with |net_log|. 408 // Associate |net_log_| with |net_log|.
430 net_log_.AddEvent( 409 net_log_.AddEvent(
431 NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB, 410 NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB,
432 net_log.source().ToEventParametersCallback()); 411 net_log.source().ToEventParametersCallback());
433 net_log.AddEvent( 412 net_log.AddEvent(
434 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB, 413 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB,
435 net_log_.source().ToEventParametersCallback()); 414 net_log_.source().ToEventParametersCallback());
436 } 415 }
437 416
438 QuicStreamFactory::Job::~Job() { 417 QuicStreamFactory::Job::~Job() {
439 net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB); 418 net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB);
440 DCHECK(callback_.is_null()); 419 DCHECK(callback_.is_null());
441
442 // If disk cache has a pending WaitForDataReadyCallback, cancel that callback.
443 if (server_info_)
444 server_info_->ResetWaitForDataReadyCallback();
445 } 420 }
446 421
447 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { 422 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) {
448 int rv = DoLoop(OK); 423 int rv = DoLoop(OK);
449 if (rv == ERR_IO_PENDING) 424 if (rv == ERR_IO_PENDING)
450 callback_ = callback; 425 callback_ = callback;
451 426
452 return rv > 0 ? OK : rv; 427 return rv > 0 ? OK : rv;
453 } 428 }
454 429
455 int QuicStreamFactory::Job::DoLoop(int rv) { 430 int QuicStreamFactory::Job::DoLoop(int rv) {
456 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::Job::DoLoop"); 431 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::Job::DoLoop");
457 do { 432 do {
458 IoState state = io_state_; 433 IoState state = io_state_;
459 io_state_ = STATE_NONE; 434 io_state_ = STATE_NONE;
460 switch (state) { 435 switch (state) {
461 case STATE_RESOLVE_HOST: 436 case STATE_RESOLVE_HOST:
462 CHECK_EQ(OK, rv); 437 CHECK_EQ(OK, rv);
463 rv = DoResolveHost(); 438 rv = DoResolveHost();
464 break; 439 break;
465 case STATE_RESOLVE_HOST_COMPLETE: 440 case STATE_RESOLVE_HOST_COMPLETE:
466 rv = DoResolveHostComplete(rv); 441 rv = DoResolveHostComplete(rv);
467 break; 442 break;
468 case STATE_LOAD_SERVER_INFO:
469 CHECK_EQ(OK, rv);
470 rv = DoLoadServerInfo();
471 break;
472 case STATE_LOAD_SERVER_INFO_COMPLETE:
473 rv = DoLoadServerInfoComplete(rv);
474 break;
475 case STATE_CONNECT: 443 case STATE_CONNECT:
476 CHECK_EQ(OK, rv); 444 CHECK_EQ(OK, rv);
477 rv = DoConnect(); 445 rv = DoConnect();
478 break; 446 break;
479 case STATE_CONNECT_COMPLETE: 447 case STATE_CONNECT_COMPLETE:
480 rv = DoConnectComplete(rv); 448 rv = DoConnectComplete(rv);
481 break; 449 break;
482 default: 450 default:
483 NOTREACHED() << "io_state_: " << io_state_; 451 NOTREACHED() << "io_state_: " << io_state_;
484 break; 452 break;
485 } 453 }
486 } while (io_state_ != STATE_NONE && rv != ERR_IO_PENDING); 454 } while (io_state_ != STATE_NONE && rv != ERR_IO_PENDING);
487 return rv; 455 return rv;
488 } 456 }
489 457
490 void QuicStreamFactory::Job::OnIOComplete(int rv) { 458 void QuicStreamFactory::Job::OnIOComplete(int rv) {
491 rv = DoLoop(rv); 459 rv = DoLoop(rv);
492 if (rv != ERR_IO_PENDING && !callback_.is_null()) 460 if (rv != ERR_IO_PENDING && !callback_.is_null())
493 base::ResetAndReturn(&callback_).Run(rv); 461 base::ResetAndReturn(&callback_).Run(rv);
494 } 462 }
495 463
496 void QuicStreamFactory::Job::RunAuxilaryJob() {
497 int rv = Run(base::Bind(&QuicStreamFactory::OnJobComplete,
498 base::Unretained(factory_), this));
499 if (rv != ERR_IO_PENDING)
500 factory_->OnJobComplete(this, rv);
501 }
502
503 void QuicStreamFactory::Job::Cancel() { 464 void QuicStreamFactory::Job::Cancel() {
504 callback_.Reset(); 465 callback_.Reset();
505 if (session_) 466 if (session_)
506 session_->connection()->CloseConnection( 467 session_->connection()->CloseConnection(
507 QUIC_CONNECTION_CANCELLED, "New job canceled.", 468 QUIC_CONNECTION_CANCELLED, "New job canceled.",
508 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 469 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
509 } 470 }
510 471
511 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() {
512 // If we are waiting for WaitForDataReadyCallback, then cancel the callback.
513 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE)
514 return;
515 server_info_->CancelWaitForDataReadyCallback();
516 OnIOComplete(OK);
517 }
518
519 size_t QuicStreamFactory::Job::EstimateMemoryUsage() const { 472 size_t QuicStreamFactory::Job::EstimateMemoryUsage() const {
520 return base::trace_event::EstimateMemoryUsage(key_) + 473 return base::trace_event::EstimateMemoryUsage(key_);
521 base::trace_event::EstimateMemoryUsage(server_info_);
522 } 474 }
523 475
524 int QuicStreamFactory::Job::DoResolveHost() { 476 int QuicStreamFactory::Job::DoResolveHost() {
525 dns_resolution_start_time_ = base::TimeTicks::Now(); 477 dns_resolution_start_time_ = base::TimeTicks::Now();
526 // Start loading the data now, and wait for it after we resolve the host.
527 if (server_info_)
528 server_info_->Start();
529 478
530 io_state_ = STATE_RESOLVE_HOST_COMPLETE; 479 io_state_ = STATE_RESOLVE_HOST_COMPLETE;
531 return host_resolver_->Resolve( 480 return host_resolver_->Resolve(
532 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, 481 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY,
533 &address_list_, 482 &address_list_,
534 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), 483 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()),
535 &request_, net_log_); 484 &request_, net_log_);
536 } 485 }
537 486
538 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { 487 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) {
539 dns_resolution_end_time_ = base::TimeTicks::Now(); 488 dns_resolution_end_time_ = base::TimeTicks::Now();
540 if (rv != OK) 489 if (rv != OK)
541 return rv; 490 return rv;
542 491
543 DCHECK(!factory_->HasActiveSession(key_.server_id())); 492 DCHECK(!factory_->HasActiveSession(key_.server_id()));
544 493
545 // Inform the factory of this resolution, which will set up 494 // Inform the factory of this resolution, which will set up
546 // a session alias, if possible. 495 // a session alias, if possible.
547 if (factory_->OnResolution(key_, address_list_)) 496 if (factory_->OnResolution(key_, address_list_))
548 return OK; 497 return OK;
549 498
550 if (server_info_)
551 io_state_ = STATE_LOAD_SERVER_INFO;
552 else
553 io_state_ = STATE_CONNECT;
554 return OK;
555 }
556
557 int QuicStreamFactory::Job::DoLoadServerInfo() {
558 net_log_.BeginEvent(
559 NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER_INFO);
560
561 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE;
562
563 DCHECK(server_info_);
564
565 // To mitigate the effects of disk cache taking too long to load QUIC server
566 // information, set up a timer to cancel WaitForDataReady's callback.
567 if (factory_->load_server_info_timeout_srtt_multiplier_ > 0) {
568 const int kMaxLoadServerInfoTimeoutMs = 50;
569 // Wait for DiskCache a maximum of 50ms.
570 int64_t load_server_info_timeout_ms =
571 std::min(static_cast<int>(
572 (factory_->load_server_info_timeout_srtt_multiplier_ *
573 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds(
574 key_.server_id())) /
575 1000),
576 kMaxLoadServerInfoTimeoutMs);
577 if (load_server_info_timeout_ms > 0) {
578 factory_->task_runner_->PostDelayedTask(
579 FROM_HERE,
580 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback,
581 GetWeakPtr()),
582 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms));
583 }
584 }
585
586 int rv = server_info_->WaitForDataReady(
587 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()));
588 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) {
589 // If we are waiting to load server config from the disk cache, then start
590 // another job.
591 started_another_job_ = true;
592 factory_->CreateAuxilaryJob(key_, cert_verify_flags_, net_log_);
593 }
594 return rv;
595 }
596
597 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) {
598 net_log_.EndEvent(NetLogEventType::QUIC_STREAM_FACTORY_JOB_LOAD_SERVER_INFO);
599 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime",
600 base::TimeTicks::Now() - dns_resolution_end_time_);
601
602 if (rv != OK)
603 server_info_.reset();
604
605 if (started_another_job_ &&
606 (!server_info_ || server_info_->state().server_config.empty() ||
607 !factory_->CryptoConfigCacheIsEmpty(key_.server_id()))) {
608 // If we have started another job and if we didn't load the server config
609 // from the disk cache or if we have received a new server config from the
610 // server, then cancel the current job.
611 io_state_ = STATE_NONE;
612 return ERR_CONNECTION_CLOSED;
613 }
614
615 io_state_ = STATE_CONNECT; 499 io_state_ = STATE_CONNECT;
616 return OK; 500 return OK;
617 } 501 }
618 502
619 int QuicStreamFactory::Job::DoConnect() { 503 int QuicStreamFactory::Job::DoConnect() {
620 io_state_ = STATE_CONNECT_COMPLETE; 504 io_state_ = STATE_CONNECT_COMPLETE;
621 505
622 bool require_confirmation = factory_->require_confirmation() || 506 bool require_confirmation = factory_->require_confirmation() ||
623 was_alternative_service_recently_broken_; 507 was_alternative_service_recently_broken_;
624 net_log_.BeginEvent( 508 net_log_.BeginEvent(
625 NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT, 509 NetLogEventType::QUIC_STREAM_FACTORY_JOB_CONNECT,
626 NetLog::BoolCallback("require_confirmation", require_confirmation)); 510 NetLog::BoolCallback("require_confirmation", require_confirmation));
627 511
628 int rv = factory_->CreateSession( 512 int rv =
629 key_, cert_verify_flags_, std::move(server_info_), require_confirmation, 513 factory_->CreateSession(key_, cert_verify_flags_, require_confirmation,
630 address_list_, dns_resolution_start_time_, dns_resolution_end_time_, 514 address_list_, dns_resolution_start_time_,
631 net_log_, &session_); 515 dns_resolution_end_time_, net_log_, &session_);
632 if (rv != OK) { 516 if (rv != OK) {
633 DCHECK(rv != ERR_IO_PENDING); 517 DCHECK(rv != ERR_IO_PENDING);
634 DCHECK(!session_); 518 DCHECK(!session_);
635 return rv; 519 return rv;
636 } 520 }
637 521
638 if (!session_->connection()->connected()) 522 if (!session_->connection()->connected())
639 return ERR_CONNECTION_CLOSED; 523 return ERR_CONNECTION_CLOSED;
640 524
641 session_->StartReading(); 525 session_->StartReading();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 ChannelIDService* channel_id_service, 648 ChannelIDService* channel_id_service,
765 TransportSecurityState* transport_security_state, 649 TransportSecurityState* transport_security_state,
766 CTVerifier* cert_transparency_verifier, 650 CTVerifier* cert_transparency_verifier,
767 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, 651 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
768 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, 652 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
769 QuicRandom* random_generator, 653 QuicRandom* random_generator,
770 QuicClock* clock, 654 QuicClock* clock,
771 size_t max_packet_length, 655 size_t max_packet_length,
772 const std::string& user_agent_id, 656 const std::string& user_agent_id,
773 const QuicVersionVector& supported_versions, 657 const QuicVersionVector& supported_versions,
774 float load_server_info_timeout_srtt_multiplier,
775 bool enable_connection_racing,
776 bool enable_non_blocking_io, 658 bool enable_non_blocking_io,
777 bool disable_disk_cache, 659 bool store_server_configs_in_properties,
778 int max_server_configs_stored_in_properties,
779 bool close_sessions_on_ip_change, 660 bool close_sessions_on_ip_change,
780 bool mark_quic_broken_when_network_blackholes, 661 bool mark_quic_broken_when_network_blackholes,
781 int idle_connection_timeout_seconds, 662 int idle_connection_timeout_seconds,
782 int reduced_ping_timeout_seconds, 663 int reduced_ping_timeout_seconds,
783 int packet_reader_yield_after_duration_milliseconds, 664 int packet_reader_yield_after_duration_milliseconds,
784 bool migrate_sessions_on_network_change, 665 bool migrate_sessions_on_network_change,
785 bool migrate_sessions_early, 666 bool migrate_sessions_early,
786 bool allow_server_migration, 667 bool allow_server_migration,
787 bool force_hol_blocking, 668 bool force_hol_blocking,
788 bool race_cert_verification, 669 bool race_cert_verification,
(...skipping 17 matching lines...) Expand all
806 clock_skew_detector_(base::TimeTicks::Now(), base::Time::Now()), 687 clock_skew_detector_(base::TimeTicks::Now(), base::Time::Now()),
807 socket_performance_watcher_factory_(socket_performance_watcher_factory), 688 socket_performance_watcher_factory_(socket_performance_watcher_factory),
808 config_(InitializeQuicConfig(connection_options, 689 config_(InitializeQuicConfig(connection_options,
809 idle_connection_timeout_seconds)), 690 idle_connection_timeout_seconds)),
810 crypto_config_(base::WrapUnique( 691 crypto_config_(base::WrapUnique(
811 new ProofVerifierChromium(cert_verifier, 692 new ProofVerifierChromium(cert_verifier,
812 ct_policy_enforcer, 693 ct_policy_enforcer,
813 transport_security_state, 694 transport_security_state,
814 cert_transparency_verifier))), 695 cert_transparency_verifier))),
815 supported_versions_(supported_versions), 696 supported_versions_(supported_versions),
816 load_server_info_timeout_srtt_multiplier_(
817 load_server_info_timeout_srtt_multiplier),
818 enable_connection_racing_(enable_connection_racing),
819 enable_non_blocking_io_(enable_non_blocking_io), 697 enable_non_blocking_io_(enable_non_blocking_io),
820 disable_disk_cache_(disable_disk_cache),
821 mark_quic_broken_when_network_blackholes_( 698 mark_quic_broken_when_network_blackholes_(
822 mark_quic_broken_when_network_blackholes), 699 mark_quic_broken_when_network_blackholes),
700 store_server_configs_in_properties_(store_server_configs_in_properties),
823 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), 701 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)),
824 reduced_ping_timeout_( 702 reduced_ping_timeout_(
825 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), 703 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)),
826 yield_after_packets_(kQuicYieldAfterPacketsRead), 704 yield_after_packets_(kQuicYieldAfterPacketsRead),
827 yield_after_duration_(QuicTime::Delta::FromMilliseconds( 705 yield_after_duration_(QuicTime::Delta::FromMilliseconds(
828 packet_reader_yield_after_duration_milliseconds)), 706 packet_reader_yield_after_duration_milliseconds)),
829 close_sessions_on_ip_change_(close_sessions_on_ip_change), 707 close_sessions_on_ip_change_(close_sessions_on_ip_change),
830 migrate_sessions_on_network_change_( 708 migrate_sessions_on_network_change_(
831 migrate_sessions_on_network_change && 709 migrate_sessions_on_network_change &&
832 NetworkChangeNotifier::AreNetworkHandlesSupported()), 710 NetworkChangeNotifier::AreNetworkHandlesSupported()),
833 migrate_sessions_early_(migrate_sessions_early && 711 migrate_sessions_early_(migrate_sessions_early &&
834 migrate_sessions_on_network_change_), 712 migrate_sessions_on_network_change_),
835 allow_server_migration_(allow_server_migration), 713 allow_server_migration_(allow_server_migration),
836 force_hol_blocking_(force_hol_blocking), 714 force_hol_blocking_(force_hol_blocking),
837 race_cert_verification_(race_cert_verification), 715 race_cert_verification_(race_cert_verification),
838 do_not_fragment_(do_not_fragment), 716 do_not_fragment_(do_not_fragment),
839 estimate_initial_rtt(estimate_initial_rtt), 717 estimate_initial_rtt(estimate_initial_rtt),
840 check_persisted_supports_quic_(true), 718 check_persisted_supports_quic_(true),
841 has_initialized_data_(false),
842 num_push_streams_created_(0), 719 num_push_streams_created_(0),
843 task_runner_(nullptr), 720 task_runner_(nullptr),
844 ssl_config_service_(ssl_config_service), 721 ssl_config_service_(ssl_config_service),
845 weak_factory_(this) { 722 weak_factory_(this) {
846 if (ssl_config_service_.get()) 723 if (ssl_config_service_.get())
847 ssl_config_service_->AddObserver(this); 724 ssl_config_service_->AddObserver(this);
848 DCHECK(transport_security_state_); 725 DCHECK(transport_security_state_);
849 DCHECK(http_server_properties_); 726 DCHECK(http_server_properties_);
850 crypto_config_.set_user_agent_id(user_agent_id); 727 crypto_config_.set_user_agent_id(user_agent_id);
851 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); 728 crypto_config_.AddCanonicalSuffix(".c.youtube.com");
852 crypto_config_.AddCanonicalSuffix(".ggpht.com"); 729 crypto_config_.AddCanonicalSuffix(".ggpht.com");
853 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); 730 crypto_config_.AddCanonicalSuffix(".googlevideo.com");
854 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); 731 crypto_config_.AddCanonicalSuffix(".googleusercontent.com");
855 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until 732 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until
856 // channel_id_service is supported in cronet. 733 // channel_id_service is supported in cronet.
857 if (channel_id_service) { 734 if (channel_id_service) {
858 crypto_config_.SetChannelIDSource( 735 crypto_config_.SetChannelIDSource(
859 new ChannelIDSourceChromium(channel_id_service)); 736 new ChannelIDSourceChromium(channel_id_service));
860 } 737 }
861 if (enable_token_binding && channel_id_service) 738 if (enable_token_binding && channel_id_service)
862 crypto_config_.tb_key_params.push_back(kTB10); 739 crypto_config_.tb_key_params.push_back(kTB10);
863 crypto::EnsureOpenSSLInit(); 740 crypto::EnsureOpenSSLInit();
864 bool has_aes_hardware_support = !!EVP_has_aes_hardware(); 741 bool has_aes_hardware_support = !!EVP_has_aes_hardware();
865 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", 742 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm",
866 has_aes_hardware_support); 743 has_aes_hardware_support);
867 if (has_aes_hardware_support) 744 if (has_aes_hardware_support)
868 crypto_config_.PreferAesGcm(); 745 crypto_config_.PreferAesGcm();
869 // When disk cache is used to store the server configs, HttpCache code calls
870 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't
871 // created.
872 if (max_server_configs_stored_in_properties > 0) {
873 quic_server_info_factory_.reset(
874 new PropertiesBasedQuicServerInfoFactory(http_server_properties_));
875 }
876 746
877 // migrate_sessions_early should only be set to true if 747 // migrate_sessions_early should only be set to true if
878 // migrate_sessions_on_network_change is set to true. 748 // migrate_sessions_on_network_change is set to true.
879 if (migrate_sessions_early) 749 if (migrate_sessions_early)
880 DCHECK(migrate_sessions_on_network_change); 750 DCHECK(migrate_sessions_on_network_change);
881 // close_sessions_on_ip_change and migrate_sessions_on_network_change should 751 // close_sessions_on_ip_change and migrate_sessions_on_network_change should
882 // never be simultaneously set to true. 752 // never be simultaneously set to true.
883 DCHECK(!(close_sessions_on_ip_change && migrate_sessions_on_network_change)); 753 DCHECK(!(close_sessions_on_ip_change && migrate_sessions_on_network_change));
884 754
885 if (migrate_sessions_on_network_change_) { 755 if (migrate_sessions_on_network_change_) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 int64_t srtt = 793 int64_t srtt =
924 1.5 * GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); 794 1.5 * GetServerNetworkStatsSmoothedRttInMicroseconds(server_id);
925 // Picked 300ms based on mean time from 795 // Picked 300ms based on mean time from
926 // Net.QuicSession.HostResolution.HandshakeConfirmedTime histogram. 796 // Net.QuicSession.HostResolution.HandshakeConfirmedTime histogram.
927 const int kDefaultRTT = 300 * kNumMicrosPerMilli; 797 const int kDefaultRTT = 300 * kNumMicrosPerMilli;
928 if (!srtt) 798 if (!srtt)
929 srtt = kDefaultRTT; 799 srtt = kDefaultRTT;
930 return base::TimeDelta::FromMicroseconds(srtt); 800 return base::TimeDelta::FromMicroseconds(srtt);
931 } 801 }
932 802
933 void QuicStreamFactory::set_quic_server_info_factory(
934 QuicServerInfoFactory* quic_server_info_factory) {
935 quic_server_info_factory_.reset(quic_server_info_factory);
936 }
937
938 void QuicStreamFactory::DumpMemoryStats( 803 void QuicStreamFactory::DumpMemoryStats(
939 base::trace_event::ProcessMemoryDump* pmd, 804 base::trace_event::ProcessMemoryDump* pmd,
940 const std::string& parent_absolute_name) const { 805 const std::string& parent_absolute_name) const {
941 if (all_sessions_.empty() && active_jobs_.empty()) 806 if (all_sessions_.empty() && active_jobs_.empty())
942 return; 807 return;
943 base::trace_event::MemoryAllocatorDump* factory_dump = 808 base::trace_event::MemoryAllocatorDump* factory_dump =
944 pmd->CreateAllocatorDump(parent_absolute_name + "/quic_stream_factory"); 809 pmd->CreateAllocatorDump(parent_absolute_name + "/quic_stream_factory");
945 size_t memory_estimate = 810 size_t memory_estimate =
946 base::trace_event::EstimateMemoryUsage(all_sessions_) + 811 base::trace_event::EstimateMemoryUsage(all_sessions_) +
947 base::trace_event::EstimateMemoryUsage(active_sessions_) + 812 base::trace_event::EstimateMemoryUsage(active_sessions_) +
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 return OK; 927 return OK;
1063 } 928 }
1064 } 929 }
1065 } 930 }
1066 931
1067 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ 932 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_
1068 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. 933 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed.
1069 if (!task_runner_) 934 if (!task_runner_)
1070 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); 935 task_runner_ = base::ThreadTaskRunnerHandle::Get().get();
1071 936
1072 std::unique_ptr<QuicServerInfo> quic_server_info;
1073 if (quic_server_info_factory_.get()) {
1074 bool load_from_disk_cache = !disable_disk_cache_;
1075 MaybeInitialize();
1076 if (!base::ContainsKey(quic_supported_servers_at_startup_, destination)) {
1077 // If there is no entry for QUIC, consider that as a new server and
1078 // don't wait for Cache thread to load the data for that server.
1079 load_from_disk_cache = false;
1080 }
1081 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id))
1082 quic_server_info = quic_server_info_factory_->GetForServer(server_id);
1083 }
1084
1085 ignore_result(StartCertVerifyJob(server_id, cert_verify_flags, net_log)); 937 ignore_result(StartCertVerifyJob(server_id, cert_verify_flags, net_log));
1086 938
1087 QuicSessionKey key(destination, server_id); 939 QuicSessionKey key(destination, server_id);
1088 std::unique_ptr<Job> job = base::MakeUnique<Job>( 940 std::unique_ptr<Job> job = base::MakeUnique<Job>(
1089 this, host_resolver_, key, WasQuicRecentlyBroken(server_id), 941 this, host_resolver_, key, WasQuicRecentlyBroken(server_id),
1090 cert_verify_flags, std::move(quic_server_info), net_log); 942 cert_verify_flags, net_log);
1091 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, 943 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
1092 base::Unretained(this), job.get())); 944 base::Unretained(this), job.get()));
1093 if (rv == ERR_IO_PENDING) { 945 if (rv == ERR_IO_PENDING) {
1094 job_requests_map_[server_id].insert(request); 946 job_requests_map_[server_id].insert(request);
1095 Job* job_ptr = job.get(); 947 Job* job_ptr = job.get();
1096 active_jobs_[server_id][job_ptr] = std::move(job); 948 active_jobs_[server_id][job_ptr] = std::move(job);
1097 return rv; 949 return rv;
1098 } 950 }
1099 if (rv == OK) { 951 if (rv == OK) {
1100 // TODO(rtenneti): crbug.com/498823 - revert active_sessions_.empty() 952 // TODO(rtenneti): crbug.com/498823 - revert active_sessions_.empty()
(...skipping 25 matching lines...) Expand all
1126 const QuicSessionKey& other) const { 978 const QuicSessionKey& other) const {
1127 return destination_.Equals(other.destination_) && 979 return destination_.Equals(other.destination_) &&
1128 server_id_ == other.server_id_; 980 server_id_ == other.server_id_;
1129 } 981 }
1130 982
1131 size_t QuicStreamFactory::QuicSessionKey::EstimateMemoryUsage() const { 983 size_t QuicStreamFactory::QuicSessionKey::EstimateMemoryUsage() const {
1132 return base::trace_event::EstimateMemoryUsage(destination_) + 984 return base::trace_event::EstimateMemoryUsage(destination_) +
1133 EstimateServerIdMemoryUsage(server_id_); 985 EstimateServerIdMemoryUsage(server_id_);
1134 } 986 }
1135 987
1136 void QuicStreamFactory::CreateAuxilaryJob(const QuicSessionKey& key,
1137 int cert_verify_flags,
1138 const NetLogWithSource& net_log) {
1139 Job* aux_job =
1140 new Job(this, host_resolver_, key, WasQuicRecentlyBroken(key.server_id()),
1141 cert_verify_flags, nullptr, net_log);
1142 active_jobs_[key.server_id()][aux_job] = base::WrapUnique(aux_job);
1143 task_runner_->PostTask(FROM_HERE,
1144 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob,
1145 aux_job->GetWeakPtr()));
1146 }
1147
1148 bool QuicStreamFactory::OnResolution(const QuicSessionKey& key, 988 bool QuicStreamFactory::OnResolution(const QuicSessionKey& key,
1149 const AddressList& address_list) { 989 const AddressList& address_list) {
1150 const QuicServerId& server_id(key.server_id()); 990 const QuicServerId& server_id(key.server_id());
1151 DCHECK(!HasActiveSession(server_id)); 991 DCHECK(!HasActiveSession(server_id));
1152 for (const IPEndPoint& address : address_list) { 992 for (const IPEndPoint& address : address_list) {
1153 if (!base::ContainsKey(ip_aliases_, address)) 993 if (!base::ContainsKey(ip_aliases_, address))
1154 continue; 994 continue;
1155 995
1156 const SessionSet& sessions = ip_aliases_[address]; 996 const SessionSet& sessions = ip_aliases_[address];
1157 for (QuicChromiumClientSession* session : sessions) { 997 for (QuicChromiumClientSession* session : sessions) {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 require_confirmation_ = false; 1476 require_confirmation_ = false;
1637 } 1477 }
1638 } 1478 }
1639 1479
1640 return OK; 1480 return OK;
1641 } 1481 }
1642 1482
1643 int QuicStreamFactory::CreateSession( 1483 int QuicStreamFactory::CreateSession(
1644 const QuicSessionKey& key, 1484 const QuicSessionKey& key,
1645 int cert_verify_flags, 1485 int cert_verify_flags,
1646 std::unique_ptr<QuicServerInfo> server_info,
1647 bool require_confirmation, 1486 bool require_confirmation,
1648 const AddressList& address_list, 1487 const AddressList& address_list,
1649 base::TimeTicks dns_resolution_start_time, 1488 base::TimeTicks dns_resolution_start_time,
1650 base::TimeTicks dns_resolution_end_time, 1489 base::TimeTicks dns_resolution_end_time,
1651 const NetLogWithSource& net_log, 1490 const NetLogWithSource& net_log,
1652 QuicChromiumClientSession** session) { 1491 QuicChromiumClientSession** session) {
1653 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::CreateSession"); 1492 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::CreateSession");
1654 IPEndPoint addr = *address_list.begin(); 1493 IPEndPoint addr = *address_list.begin();
1655 const QuicServerId& server_id = key.server_id(); 1494 const QuicServerId& server_id = key.server_id();
1656 DatagramSocket::BindType bind_type = DatagramSocket::DEFAULT_BIND; 1495 DatagramSocket::BindType bind_type = DatagramSocket::DEFAULT_BIND;
1657 std::unique_ptr<DatagramClientSocket> socket( 1496 std::unique_ptr<DatagramClientSocket> socket(
1658 client_socket_factory_->CreateDatagramClientSocket( 1497 client_socket_factory_->CreateDatagramClientSocket(
1659 bind_type, RandIntCallback(), net_log.net_log(), net_log.source())); 1498 bind_type, RandIntCallback(), net_log.net_log(), net_log.source()));
1660 1499
1661 // Passing in kInvalidNetworkHandle binds socket to default network. 1500 // Passing in kInvalidNetworkHandle binds socket to default network.
1662 int rv = ConfigureSocket(socket.get(), addr, 1501 int rv = ConfigureSocket(socket.get(), addr,
1663 NetworkChangeNotifier::kInvalidNetworkHandle); 1502 NetworkChangeNotifier::kInvalidNetworkHandle);
1664 if (rv != OK) 1503 if (rv != OK)
1665 return rv; 1504 return rv;
1666 1505
1667 if (!helper_.get()) { 1506 if (!helper_.get()) {
1668 helper_.reset(new QuicChromiumConnectionHelper(clock_, random_generator_)); 1507 helper_.reset(new QuicChromiumConnectionHelper(clock_, random_generator_));
1669 } 1508 }
1670 1509
1671 if (!alarm_factory_.get()) { 1510 if (!alarm_factory_.get()) {
1672 alarm_factory_.reset(new QuicChromiumAlarmFactory( 1511 alarm_factory_.reset(new QuicChromiumAlarmFactory(
1673 base::ThreadTaskRunnerHandle::Get().get(), clock_)); 1512 base::ThreadTaskRunnerHandle::Get().get(), clock_));
1674 } 1513 }
1514
1675 QuicConnectionId connection_id = random_generator_->RandUint64(); 1515 QuicConnectionId connection_id = random_generator_->RandUint64();
1516 std::unique_ptr<QuicServerInfo> server_info;
1517 if (store_server_configs_in_properties_) {
1518 server_info = base::MakeUnique<PropertiesBasedQuicServerInfo>(
1519 server_id, http_server_properties_);
1520 }
1676 InitializeCachedStateInCryptoConfig(server_id, server_info, &connection_id); 1521 InitializeCachedStateInCryptoConfig(server_id, server_info, &connection_id);
1677 1522
1678 QuicChromiumPacketWriter* writer = new QuicChromiumPacketWriter(socket.get()); 1523 QuicChromiumPacketWriter* writer = new QuicChromiumPacketWriter(socket.get());
1679 QuicConnection* connection = new QuicConnection( 1524 QuicConnection* connection = new QuicConnection(
1680 connection_id, QuicSocketAddress(QuicSocketAddressImpl(addr)), 1525 connection_id, QuicSocketAddress(QuicSocketAddressImpl(addr)),
1681 helper_.get(), alarm_factory_.get(), writer, true /* owns_writer */, 1526 helper_.get(), alarm_factory_.get(), writer, true /* owns_writer */,
1682 Perspective::IS_CLIENT, supported_versions_); 1527 Perspective::IS_CLIENT, supported_versions_);
1683 connection->set_ping_timeout(ping_timeout_); 1528 connection->set_ping_timeout(ping_timeout_);
1684 connection->SetMaxPacketLength(max_packet_length_); 1529 connection->SetMaxPacketLength(max_packet_length_);
1685 1530
1686 QuicConfig config = config_; 1531 QuicConfig config = config_;
1687 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); 1532 config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
1688 config.SetInitialSessionFlowControlWindowToSend( 1533 config.SetInitialSessionFlowControlWindowToSend(
1689 kQuicSessionMaxRecvWindowSize); 1534 kQuicSessionMaxRecvWindowSize);
1690 config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize); 1535 config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize);
1691 config.SetBytesForConnectionIdToSend(0); 1536 config.SetBytesForConnectionIdToSend(0);
1692 ConfigureInitialRttEstimate(server_id, &config); 1537 ConfigureInitialRttEstimate(server_id, &config);
1693 1538
1694 if (force_hol_blocking_) 1539 if (force_hol_blocking_)
1695 config.SetForceHolBlocking(); 1540 config.SetForceHolBlocking();
1696 1541
1697 if (quic_server_info_factory_.get() && !server_info) {
1698 // Start the disk cache loading so that we can persist the newer QUIC server
1699 // information and/or inform the disk cache that we have reused
1700 // |server_info|.
1701 server_info = quic_server_info_factory_->GetForServer(server_id);
1702 server_info->Start();
1703 }
1704
1705 // Use the factory to create a new socket performance watcher, and pass the 1542 // Use the factory to create a new socket performance watcher, and pass the
1706 // ownership to QuicChromiumClientSession. 1543 // ownership to QuicChromiumClientSession.
1707 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher; 1544 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher;
1708 if (socket_performance_watcher_factory_) { 1545 if (socket_performance_watcher_factory_) {
1709 socket_performance_watcher = 1546 socket_performance_watcher =
1710 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( 1547 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher(
1711 SocketPerformanceWatcherFactory::PROTOCOL_QUIC); 1548 SocketPerformanceWatcherFactory::PROTOCOL_QUIC);
1712 } 1549 }
1713 1550
1714 *session = new QuicChromiumClientSession( 1551 *session = new QuicChromiumClientSession(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 const std::unique_ptr<QuicServerInfo>& server_info, 1674 const std::unique_ptr<QuicServerInfo>& server_info,
1838 QuicConnectionId* connection_id) { 1675 QuicConnectionId* connection_id) {
1839 QuicCryptoClientConfig::CachedState* cached = 1676 QuicCryptoClientConfig::CachedState* cached =
1840 crypto_config_.LookupOrCreate(server_id); 1677 crypto_config_.LookupOrCreate(server_id);
1841 if (cached->has_server_designated_connection_id()) 1678 if (cached->has_server_designated_connection_id())
1842 *connection_id = cached->GetNextServerDesignatedConnectionId(); 1679 *connection_id = cached->GetNextServerDesignatedConnectionId();
1843 1680
1844 if (!cached->IsEmpty()) 1681 if (!cached->IsEmpty())
1845 return; 1682 return;
1846 1683
1847 // |server_info| will be NULL, if a non-empty server config already exists in 1684 if (!server_info || !server_info->Load())
1848 // the memory cache.
1849 if (!server_info)
1850 return; 1685 return;
1851 1686
1852 // TODO(rtenneti): Delete the following histogram after collecting stats.
1853 // If the AlternativeServiceMap contained an entry for this host, check if
1854 // the disk cache contained an entry for it.
1855 if (base::ContainsKey(quic_supported_servers_at_startup_,
1856 server_id.host_port_pair())) {
1857 UMA_HISTOGRAM_BOOLEAN("Net.QuicServerInfo.ExpectConfigMissingFromDiskCache",
1858 server_info->state().server_config.empty());
1859 }
1860
1861 cached->Initialize(server_info->state().server_config, 1687 cached->Initialize(server_info->state().server_config,
1862 server_info->state().source_address_token, 1688 server_info->state().source_address_token,
1863 server_info->state().certs, server_info->state().cert_sct, 1689 server_info->state().certs, server_info->state().cert_sct,
1864 server_info->state().chlo_hash, 1690 server_info->state().chlo_hash,
1865 server_info->state().server_config_sig, clock_->WallNow(), 1691 server_info->state().server_config_sig, clock_->WallNow(),
1866 QuicWallTime::Zero()); 1692 QuicWallTime::Zero());
1867 } 1693 }
1868 1694
1869 void QuicStreamFactory::MaybeInitialize() {
1870 // We don't initialize data from HttpServerProperties in the constructor
1871 // because HttpServerProperties has not yet initialized. We're guaranteed
1872 // HttpServerProperties has been initialized by the first time a request is
1873 // made.
1874 if (has_initialized_data_)
1875 return;
1876
1877 has_initialized_data_ = true;
1878
1879 // Query the proxy delegate for the default alternative proxy server.
1880 ProxyServer default_alternative_proxy_server =
1881 proxy_delegate_ ? proxy_delegate_->GetDefaultAlternativeProxy()
1882 : ProxyServer();
1883 if (default_alternative_proxy_server.is_quic()) {
1884 quic_supported_servers_at_startup_.insert(
1885 default_alternative_proxy_server.host_port_pair());
1886 }
1887
1888 for (const std::pair<const url::SchemeHostPort, AlternativeServiceInfoVector>&
1889 key_value : http_server_properties_->alternative_service_map()) {
1890 HostPortPair host_port_pair(key_value.first.host(), key_value.first.port());
1891 for (const AlternativeServiceInfo& alternative_service_info :
1892 key_value.second) {
1893 if (alternative_service_info.alternative_service.protocol == kProtoQUIC) {
1894 quic_supported_servers_at_startup_.insert(host_port_pair);
1895 break;
1896 }
1897 }
1898 }
1899
1900 if (http_server_properties_->max_server_configs_stored_in_properties() == 0)
1901 return;
1902 // Create a temporary QuicServerInfo object to deserialize and to populate the
1903 // in-memory crypto server config cache in the MRU order.
1904 std::unique_ptr<QuicServerInfo> server_info;
1905 CompletionCallback callback;
1906 // Get the list of servers to be deserialized first because WaitForDataReady
1907 // touches quic_server_info_map.
1908 const QuicServerInfoMap& quic_server_info_map =
1909 http_server_properties_->quic_server_info_map();
1910 std::vector<QuicServerId> server_list;
1911 for (const auto& key_value : quic_server_info_map)
1912 server_list.push_back(key_value.first);
1913 for (auto it = server_list.rbegin(); it != server_list.rend(); ++it) {
1914 const QuicServerId& server_id = *it;
1915 server_info = quic_server_info_factory_->GetForServer(server_id);
1916 if (server_info->WaitForDataReady(callback) == OK) {
1917 DVLOG(1) << "Initialized server config for: " << server_id.ToString();
1918 InitializeCachedStateInCryptoConfig(server_id, server_info, nullptr);
1919 }
1920 }
1921 }
1922
1923 void QuicStreamFactory::ProcessGoingAwaySession( 1695 void QuicStreamFactory::ProcessGoingAwaySession(
1924 QuicChromiumClientSession* session, 1696 QuicChromiumClientSession* session,
1925 const QuicServerId& server_id, 1697 const QuicServerId& server_id,
1926 bool session_was_active) { 1698 bool session_was_active) {
1927 if (!http_server_properties_) 1699 if (!http_server_properties_)
1928 return; 1700 return;
1929 1701
1930 const QuicConnectionStats& stats = session->connection()->GetStats(); 1702 const QuicConnectionStats& stats = session->connection()->GetStats();
1931 const AlternativeService alternative_service(kProtoQUIC, 1703 const AlternativeService alternative_service(kProtoQUIC,
1932 server_id.host_port_pair()); 1704 server_id.host_port_pair());
(...skipping 30 matching lines...) Expand all
1963 // Since the session was active, there's no longer an 1735 // Since the session was active, there's no longer an
1964 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1736 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1965 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1737 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1966 // it as recently broken, which means that 0-RTT will be disabled but we'll 1738 // it as recently broken, which means that 0-RTT will be disabled but we'll
1967 // still race. 1739 // still race.
1968 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1740 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1969 alternative_service); 1741 alternative_service);
1970 } 1742 }
1971 1743
1972 } // namespace net 1744 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698