OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/quic_config.h" | 5 #include "net/quic/quic_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 return QUIC_NO_ERROR; | 401 return QUIC_NO_ERROR; |
402 } | 402 } |
403 | 403 |
404 QuicConfig::QuicConfig() | 404 QuicConfig::QuicConfig() |
405 : max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), | 405 : max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
406 max_idle_time_before_crypto_handshake_(QuicTime::Delta::Zero()), | 406 max_idle_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
407 max_undecryptable_packets_(0), | 407 max_undecryptable_packets_(0), |
408 connection_options_(kCOPT, PRESENCE_OPTIONAL), | 408 connection_options_(kCOPT, PRESENCE_OPTIONAL), |
409 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), | 409 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
410 silent_close_(kSCLS, PRESENCE_OPTIONAL), | 410 silent_close_(kSCLS, PRESENCE_OPTIONAL), |
411 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), | 411 max_streams_per_connection_(kMSPC, PRESENCE_OPTIONAL), |
| 412 max_incoming_dynamic_streams_(kMIDS, PRESENCE_OPTIONAL), |
412 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), | 413 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), |
413 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 414 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
414 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 415 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
415 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 416 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
416 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), | 417 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), |
417 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), | 418 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), |
418 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), | 419 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), |
419 alternate_server_address_(kASAD, PRESENCE_OPTIONAL) { | 420 alternate_server_address_(kASAD, PRESENCE_OPTIONAL) { |
420 SetDefaults(); | 421 SetDefaults(); |
421 } | 422 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 495 |
495 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, | 496 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, |
496 size_t default_streams) { | 497 size_t default_streams) { |
497 max_streams_per_connection_.set(max_streams, default_streams); | 498 max_streams_per_connection_.set(max_streams, default_streams); |
498 } | 499 } |
499 | 500 |
500 uint32_t QuicConfig::MaxStreamsPerConnection() const { | 501 uint32_t QuicConfig::MaxStreamsPerConnection() const { |
501 return max_streams_per_connection_.GetUint32(); | 502 return max_streams_per_connection_.GetUint32(); |
502 } | 503 } |
503 | 504 |
| 505 void QuicConfig::SetMaxIncomingDynamicStreamsToSend( |
| 506 uint32_t max_incoming_dynamic_streams) { |
| 507 max_incoming_dynamic_streams_.SetSendValue(max_incoming_dynamic_streams); |
| 508 } |
| 509 |
| 510 uint32_t QuicConfig::GetMaxIncomingDynamicStreamsToSend() { |
| 511 return max_incoming_dynamic_streams_.GetSendValue(); |
| 512 } |
| 513 |
| 514 bool QuicConfig::HasReceivedMaxIncomingDynamicStreams() { |
| 515 return max_incoming_dynamic_streams_.HasReceivedValue(); |
| 516 } |
| 517 |
| 518 uint32_t QuicConfig::ReceivedMaxIncomingDynamicStreams() { |
| 519 return max_incoming_dynamic_streams_.GetReceivedValue(); |
| 520 } |
| 521 |
504 bool QuicConfig::HasSetBytesForConnectionIdToSend() const { | 522 bool QuicConfig::HasSetBytesForConnectionIdToSend() const { |
505 return bytes_for_connection_id_.HasSendValue(); | 523 return bytes_for_connection_id_.HasSendValue(); |
506 } | 524 } |
507 | 525 |
508 void QuicConfig::SetBytesForConnectionIdToSend(uint32_t bytes) { | 526 void QuicConfig::SetBytesForConnectionIdToSend(uint32_t bytes) { |
509 bytes_for_connection_id_.SetSendValue(bytes); | 527 bytes_for_connection_id_.SetSendValue(bytes); |
510 } | 528 } |
511 | 529 |
512 bool QuicConfig::HasReceivedBytesForConnectionId() const { | 530 bool QuicConfig::HasReceivedBytesForConnectionId() const { |
513 return bytes_for_connection_id_.HasReceivedValue(); | 531 return bytes_for_connection_id_.HasReceivedValue(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 return idle_connection_state_lifetime_seconds_.negotiated() && | 650 return idle_connection_state_lifetime_seconds_.negotiated() && |
633 max_streams_per_connection_.negotiated(); | 651 max_streams_per_connection_.negotiated(); |
634 } | 652 } |
635 | 653 |
636 void QuicConfig::SetDefaults() { | 654 void QuicConfig::SetDefaults() { |
637 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, | 655 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, |
638 kDefaultIdleTimeoutSecs); | 656 kDefaultIdleTimeoutSecs); |
639 silent_close_.set(1, 0); | 657 silent_close_.set(1, 0); |
640 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, | 658 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, |
641 kDefaultMaxStreamsPerConnection); | 659 kDefaultMaxStreamsPerConnection); |
| 660 SetMaxIncomingDynamicStreamsToSend(kDefaultMaxStreamsPerConnection); |
642 max_time_before_crypto_handshake_ = | 661 max_time_before_crypto_handshake_ = |
643 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); | 662 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); |
644 max_idle_time_before_crypto_handshake_ = | 663 max_idle_time_before_crypto_handshake_ = |
645 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); | 664 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); |
646 max_undecryptable_packets_ = kDefaultMaxUndecryptablePackets; | 665 max_undecryptable_packets_ = kDefaultMaxUndecryptablePackets; |
647 | 666 |
648 SetInitialStreamFlowControlWindowToSend(kMinimumFlowControlSendWindow); | 667 SetInitialStreamFlowControlWindowToSend(kMinimumFlowControlSendWindow); |
649 SetInitialSessionFlowControlWindowToSend(kMinimumFlowControlSendWindow); | 668 SetInitialSessionFlowControlWindowToSend(kMinimumFlowControlSendWindow); |
650 } | 669 } |
651 | 670 |
652 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 671 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
653 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); | 672 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
654 silent_close_.ToHandshakeMessage(out); | 673 silent_close_.ToHandshakeMessage(out); |
655 max_streams_per_connection_.ToHandshakeMessage(out); | 674 max_streams_per_connection_.ToHandshakeMessage(out); |
| 675 max_incoming_dynamic_streams_.ToHandshakeMessage(out); |
656 bytes_for_connection_id_.ToHandshakeMessage(out); | 676 bytes_for_connection_id_.ToHandshakeMessage(out); |
657 initial_round_trip_time_us_.ToHandshakeMessage(out); | 677 initial_round_trip_time_us_.ToHandshakeMessage(out); |
658 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); | 678 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
659 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); | 679 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
660 socket_receive_buffer_.ToHandshakeMessage(out); | 680 socket_receive_buffer_.ToHandshakeMessage(out); |
661 connection_migration_disabled_.ToHandshakeMessage(out); | 681 connection_migration_disabled_.ToHandshakeMessage(out); |
662 connection_options_.ToHandshakeMessage(out); | 682 connection_options_.ToHandshakeMessage(out); |
663 alternate_server_address_.ToHandshakeMessage(out); | 683 alternate_server_address_.ToHandshakeMessage(out); |
664 } | 684 } |
665 | 685 |
(...skipping 10 matching lines...) Expand all Loading... |
676 } | 696 } |
677 if (error == QUIC_NO_ERROR) { | 697 if (error == QUIC_NO_ERROR) { |
678 error = | 698 error = |
679 silent_close_.ProcessPeerHello(peer_hello, hello_type, error_details); | 699 silent_close_.ProcessPeerHello(peer_hello, hello_type, error_details); |
680 } | 700 } |
681 if (error == QUIC_NO_ERROR) { | 701 if (error == QUIC_NO_ERROR) { |
682 error = max_streams_per_connection_.ProcessPeerHello(peer_hello, hello_type, | 702 error = max_streams_per_connection_.ProcessPeerHello(peer_hello, hello_type, |
683 error_details); | 703 error_details); |
684 } | 704 } |
685 if (error == QUIC_NO_ERROR) { | 705 if (error == QUIC_NO_ERROR) { |
| 706 error = max_incoming_dynamic_streams_.ProcessPeerHello( |
| 707 peer_hello, hello_type, error_details); |
| 708 } |
| 709 if (error == QUIC_NO_ERROR) { |
686 error = bytes_for_connection_id_.ProcessPeerHello(peer_hello, hello_type, | 710 error = bytes_for_connection_id_.ProcessPeerHello(peer_hello, hello_type, |
687 error_details); | 711 error_details); |
688 } | 712 } |
689 if (error == QUIC_NO_ERROR) { | 713 if (error == QUIC_NO_ERROR) { |
690 error = initial_round_trip_time_us_.ProcessPeerHello(peer_hello, hello_type, | 714 error = initial_round_trip_time_us_.ProcessPeerHello(peer_hello, hello_type, |
691 error_details); | 715 error_details); |
692 } | 716 } |
693 if (error == QUIC_NO_ERROR) { | 717 if (error == QUIC_NO_ERROR) { |
694 error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( | 718 error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( |
695 peer_hello, hello_type, error_details); | 719 peer_hello, hello_type, error_details); |
(...skipping 15 matching lines...) Expand all Loading... |
711 error_details); | 735 error_details); |
712 } | 736 } |
713 if (error == QUIC_NO_ERROR) { | 737 if (error == QUIC_NO_ERROR) { |
714 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, | 738 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, |
715 error_details); | 739 error_details); |
716 } | 740 } |
717 return error; | 741 return error; |
718 } | 742 } |
719 | 743 |
720 } // namespace net | 744 } // namespace net |
OLD | NEW |