| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 418 } |
| 419 break; | 419 break; |
| 420 default: | 420 default: |
| 421 *error_details = "Bad " + QuicUtils::TagToString(tag_); | 421 *error_details = "Bad " + QuicUtils::TagToString(tag_); |
| 422 break; | 422 break; |
| 423 } | 423 } |
| 424 return error; | 424 return error; |
| 425 } | 425 } |
| 426 | 426 |
| 427 QuicConfig::QuicConfig() | 427 QuicConfig::QuicConfig() |
| 428 : congestion_feedback_(kCGST, PRESENCE_REQUIRED), | 428 : max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
| 429 max_idle_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
| 430 congestion_feedback_(kCGST, PRESENCE_REQUIRED), |
| 429 connection_options_(kCOPT, PRESENCE_OPTIONAL), | 431 connection_options_(kCOPT, PRESENCE_OPTIONAL), |
| 430 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), | 432 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
| 431 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), | 433 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), |
| 432 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), | 434 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), |
| 433 max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), | |
| 434 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), | 435 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), |
| 435 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 436 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
| 436 // TODO(rjshade): Remove this when retiring QUIC_VERSION_19. | 437 // TODO(rjshade): Remove this when retiring QUIC_VERSION_19. |
| 437 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), | 438 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), |
| 438 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring | 439 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 439 // QUIC_VERSION_19. | 440 // QUIC_VERSION_19. |
| 440 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 441 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
| 441 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring | 442 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 442 // QUIC_VERSION_19. | 443 // QUIC_VERSION_19. |
| 443 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 444 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 498 |
| 498 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, | 499 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, |
| 499 size_t default_streams) { | 500 size_t default_streams) { |
| 500 max_streams_per_connection_.set(max_streams, default_streams); | 501 max_streams_per_connection_.set(max_streams, default_streams); |
| 501 } | 502 } |
| 502 | 503 |
| 503 uint32 QuicConfig::MaxStreamsPerConnection() const { | 504 uint32 QuicConfig::MaxStreamsPerConnection() const { |
| 504 return max_streams_per_connection_.GetUint32(); | 505 return max_streams_per_connection_.GetUint32(); |
| 505 } | 506 } |
| 506 | 507 |
| 507 void QuicConfig::set_max_time_before_crypto_handshake( | |
| 508 QuicTime::Delta max_time_before_crypto_handshake) { | |
| 509 max_time_before_crypto_handshake_ = max_time_before_crypto_handshake; | |
| 510 } | |
| 511 | |
| 512 QuicTime::Delta QuicConfig::max_time_before_crypto_handshake() const { | |
| 513 return max_time_before_crypto_handshake_; | |
| 514 } | |
| 515 | |
| 516 void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) { | 508 void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) { |
| 517 initial_congestion_window_.SetSendValue(initial_window); | 509 initial_congestion_window_.SetSendValue(initial_window); |
| 518 } | 510 } |
| 519 | 511 |
| 520 bool QuicConfig::HasReceivedInitialCongestionWindow() const { | 512 bool QuicConfig::HasReceivedInitialCongestionWindow() const { |
| 521 return initial_congestion_window_.HasReceivedValue(); | 513 return initial_congestion_window_.HasReceivedValue(); |
| 522 } | 514 } |
| 523 | 515 |
| 524 uint32 QuicConfig::ReceivedInitialCongestionWindow() const { | 516 uint32 QuicConfig::ReceivedInitialCongestionWindow() const { |
| 525 return initial_congestion_window_.GetReceivedValue(); | 517 return initial_congestion_window_.GetReceivedValue(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 } | 612 } |
| 621 | 613 |
| 622 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { | 614 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { |
| 623 return socket_receive_buffer_.HasReceivedValue(); | 615 return socket_receive_buffer_.HasReceivedValue(); |
| 624 } | 616 } |
| 625 | 617 |
| 626 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { | 618 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { |
| 627 return socket_receive_buffer_.GetReceivedValue(); | 619 return socket_receive_buffer_.GetReceivedValue(); |
| 628 } | 620 } |
| 629 | 621 |
| 630 bool QuicConfig::negotiated() { | 622 bool QuicConfig::negotiated() const { |
| 631 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 623 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
| 632 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and | 624 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
| 633 // ProcessServerHello. | 625 // ProcessServerHello. |
| 634 return congestion_feedback_.negotiated() && | 626 return congestion_feedback_.negotiated() && |
| 635 idle_connection_state_lifetime_seconds_.negotiated() && | 627 idle_connection_state_lifetime_seconds_.negotiated() && |
| 636 keepalive_timeout_seconds_.negotiated() && | 628 keepalive_timeout_seconds_.negotiated() && |
| 637 max_streams_per_connection_.negotiated(); | 629 max_streams_per_connection_.negotiated(); |
| 638 } | 630 } |
| 639 | 631 |
| 640 void QuicConfig::SetDefaults() { | 632 void QuicConfig::SetDefaults() { |
| 641 QuicTagVector congestion_feedback; | 633 QuicTagVector congestion_feedback; |
| 642 congestion_feedback.push_back(kQBIC); | 634 congestion_feedback.push_back(kQBIC); |
| 643 congestion_feedback_.set(congestion_feedback, kQBIC); | 635 congestion_feedback_.set(congestion_feedback, kQBIC); |
| 644 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, | 636 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, |
| 645 kDefaultInitialTimeoutSecs); | 637 kDefaultIdleTimeoutSecs); |
| 646 // kKATO is optional. Return 0 if not negotiated. | 638 // kKATO is optional. Return 0 if not negotiated. |
| 647 keepalive_timeout_seconds_.set(0, 0); | 639 keepalive_timeout_seconds_.set(0, 0); |
| 648 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, | 640 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, |
| 649 kDefaultMaxStreamsPerConnection); | 641 kDefaultMaxStreamsPerConnection); |
| 650 max_time_before_crypto_handshake_ = QuicTime::Delta::FromSeconds( | 642 max_time_before_crypto_handshake_ = |
| 651 kDefaultMaxTimeForCryptoHandshakeSecs); | 643 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); |
| 644 max_idle_time_before_crypto_handshake_ = |
| 645 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); |
| 652 | 646 |
| 653 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 647 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 654 SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 648 SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 655 SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 649 SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 656 } | 650 } |
| 657 | 651 |
| 658 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 652 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
| 659 congestion_feedback_.ToHandshakeMessage(out); | 653 congestion_feedback_.ToHandshakeMessage(out); |
| 660 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); | 654 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
| 661 keepalive_timeout_seconds_.ToHandshakeMessage(out); | 655 keepalive_timeout_seconds_.ToHandshakeMessage(out); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 peer_hello, hello_type, error_details); | 711 peer_hello, hello_type, error_details); |
| 718 } | 712 } |
| 719 if (error == QUIC_NO_ERROR) { | 713 if (error == QUIC_NO_ERROR) { |
| 720 error = connection_options_.ProcessPeerHello( | 714 error = connection_options_.ProcessPeerHello( |
| 721 peer_hello, hello_type, error_details); | 715 peer_hello, hello_type, error_details); |
| 722 } | 716 } |
| 723 return error; | 717 return error; |
| 724 } | 718 } |
| 725 | 719 |
| 726 } // namespace net | 720 } // namespace net |
| OLD | NEW |