summaryrefslogtreecommitdiffstats
path: root/net/quic/quic_config.cc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 02:42:02 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 02:42:02 +0000
commitffc34bf0f1eda7817216eb2ce9cdd31f97bc3b60 (patch)
treeabe432a1c24028cfb0a1c649550914209809eec6 /net/quic/quic_config.cc
parente6f7a0abccc7a0513e1e3654e06f6fc819933ebd (diff)
downloadchromium_src-ffc34bf0f1eda7817216eb2ce9cdd31f97bc3b60.zip
chromium_src-ffc34bf0f1eda7817216eb2ce9cdd31f97bc3b60.tar.gz
chromium_src-ffc34bf0f1eda7817216eb2ce9cdd31f97bc3b60.tar.bz2
Land Recent QUIC Changes.
Refactor of QUIC's rtt storage and calculation to have a single RttStats object used by the SentPacketManager, LossDetectionAlgorithms, and SendAlgorithms. Merge internal change: 62624956 https://codereview.chromium.org/185053006/ QUIC refactor to move the pending_crypto_packet_count_ from the QuicSentPacketManager to the QuicUnackedPacketMap. Merge internal change: 62614116 https://codereview.chromium.org/188273003/ QUIC - Fix the spelling error in "frame received." message. Merge internal change: 62491376 https://codereview.chromium.org/188173003/ Doing a best-effort attempt to send connection close packet for open quic connection before we call exit(). The actual sending of the connection close is flag protected, though worst case we'd crash right before exit() anyway. Merge internal change: 62484710 https://codereview.chromium.org/180953008/ Test only change to QUIC TCPLossAlgorithmTest to ensure the early retransmit alarms is set for the earliest outstanding packet. Merge internal change: 62438180 https://codereview.chromium.org/188153003/ CL generated with data from dead-code analysis using Scythe remove_dead_code tool. Cleanup of net/quic using Scythe Merge internal change: 62404986 https://codereview.chromium.org/183683025/ Allow fixed (non-negotiated) values to be sent in QUIC CHLO/SHLO. Also adds IFCW tag for describing initial flow control window in CHLO/SHLO. Not used yet. Merge internal change: 62403534 https://codereview.chromium.org/188183002/ Sync'ing changes with internal tree. https://codereview.chromium.org/184853014/ Merge internal change: 62295877 Make the VER tag required in QUIC CHLO and SHLO messages. Merge internal change: 62286870 https://codereview.chromium.org/186313002/ R=rch@chromium.org Review URL: https://codereview.chromium.org/188333003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/quic_config.cc')
-rw-r--r--net/quic/quic_config.cc166
1 files changed, 125 insertions, 41 deletions
diff --git a/net/quic/quic_config.cc b/net/quic/quic_config.cc
index 86a37b3..9a5f403 100644
--- a/net/quic/quic_config.cc
+++ b/net/quic/quic_config.cc
@@ -16,17 +16,57 @@ using std::string;
namespace net {
-QuicNegotiableValue::QuicNegotiableValue(QuicTag tag, Presence presence)
+// Reads the value corresponding to |name_| from |msg| into |out|. If the
+// |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set
+// to |default_value|.
+QuicErrorCode ReadUint32(const CryptoHandshakeMessage& msg,
+ QuicTag tag,
+ QuicConfigPresence presence,
+ uint32 default_value,
+ uint32* out,
+ string* error_details) {
+ DCHECK(error_details != NULL);
+ QuicErrorCode error = msg.GetUint32(tag, out);
+ switch (error) {
+ case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND:
+ if (presence == PRESENCE_REQUIRED) {
+ *error_details = "Missing " + QuicUtils::TagToString(tag);
+ break;
+ }
+ error = QUIC_NO_ERROR;
+ *out = default_value;
+ break;
+ case QUIC_NO_ERROR:
+ break;
+ default:
+ *error_details = "Bad " + QuicUtils::TagToString(tag);
+ break;
+ }
+ return error;
+}
+
+
+QuicConfigValue::QuicConfigValue(QuicTag tag,
+ QuicConfigPresence presence)
: tag_(tag),
- presence_(presence),
+ presence_(presence) {
+}
+QuicConfigValue::~QuicConfigValue() {}
+
+QuicNegotiableValue::QuicNegotiableValue(QuicTag tag,
+ QuicConfigPresence presence)
+ : QuicConfigValue(tag, presence),
negotiated_(false) {
}
+QuicNegotiableValue::~QuicNegotiableValue() {}
-QuicNegotiableUint32::QuicNegotiableUint32(QuicTag tag, Presence presence)
+QuicNegotiableUint32::QuicNegotiableUint32(QuicTag tag,
+ QuicConfigPresence presence)
: QuicNegotiableValue(tag, presence),
max_value_(0),
default_value_(0) {
}
+QuicNegotiableUint32::~QuicNegotiableUint32() {}
void QuicNegotiableUint32::set(uint32 max, uint32 default_value) {
DCHECK_LE(default_value, max);
@@ -50,41 +90,21 @@ void QuicNegotiableUint32::ToHandshakeMessage(
}
}
-QuicErrorCode QuicNegotiableUint32::ReadUint32(
- const CryptoHandshakeMessage& msg,
- uint32* out,
- string* error_details) const {
- DCHECK(error_details != NULL);
- QuicErrorCode error = msg.GetUint32(tag_, out);
- switch (error) {
- case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND:
- if (presence_ == QuicNegotiableValue::PRESENCE_REQUIRED) {
- *error_details = "Missing " + QuicUtils::TagToString(tag_);
- break;
- }
- error = QUIC_NO_ERROR;
- *out = default_value_;
-
- case QUIC_NO_ERROR:
- break;
- default:
- *error_details = "Bad " + QuicUtils::TagToString(tag_);
- break;
- }
- return error;
-}
-
QuicErrorCode QuicNegotiableUint32::ProcessClientHello(
const CryptoHandshakeMessage& client_hello,
string* error_details) {
DCHECK(!negotiated_);
DCHECK(error_details != NULL);
uint32 value;
- QuicErrorCode error = ReadUint32(client_hello, &value, error_details);
+ QuicErrorCode error = ReadUint32(client_hello,
+ tag_,
+ presence_,
+ default_value_,
+ &value,
+ error_details);
if (error != QUIC_NO_ERROR) {
return error;
}
-
negotiated_ = true;
negotiated_value_ = std::min(value, max_value_);
@@ -97,7 +117,12 @@ QuicErrorCode QuicNegotiableUint32::ProcessServerHello(
DCHECK(!negotiated_);
DCHECK(error_details != NULL);
uint32 value;
- QuicErrorCode error = ReadUint32(server_hello, &value, error_details);
+ QuicErrorCode error = ReadUint32(server_hello,
+ tag_,
+ presence_,
+ max_value_,
+ &value,
+ error_details);
if (error != QUIC_NO_ERROR) {
return error;
}
@@ -113,7 +138,7 @@ QuicErrorCode QuicNegotiableUint32::ProcessServerHello(
return QUIC_NO_ERROR;
}
-QuicNegotiableTag::QuicNegotiableTag(QuicTag tag, Presence presence)
+QuicNegotiableTag::QuicNegotiableTag(QuicTag tag, QuicConfigPresence presence)
: QuicNegotiableValue(tag, presence),
negotiated_tag_(0),
default_value_(0) {
@@ -226,16 +251,58 @@ QuicErrorCode QuicNegotiableTag::ProcessServerHello(
return QUIC_NO_ERROR;
}
-QuicConfig::QuicConfig() :
- congestion_control_(kCGST, QuicNegotiableValue::PRESENCE_REQUIRED),
- idle_connection_state_lifetime_seconds_(
- kICSL, QuicNegotiableValue::PRESENCE_REQUIRED),
- keepalive_timeout_seconds_(kKATO, QuicNegotiableValue::PRESENCE_OPTIONAL),
- max_streams_per_connection_(kMSPC, QuicNegotiableValue::PRESENCE_REQUIRED),
- max_time_before_crypto_handshake_(QuicTime::Delta::Zero()),
- server_initial_congestion_window_(
- kSWND, QuicNegotiableValue::PRESENCE_OPTIONAL),
- initial_round_trip_time_us_(kIRTT, QuicNegotiableValue::PRESENCE_OPTIONAL) {
+QuicFixedUint32::QuicFixedUint32(QuicTag tag,
+ QuicConfigPresence presence,
+ uint32 default_value)
+ : QuicConfigValue(tag, presence),
+ value_(default_value) {
+}
+QuicFixedUint32::~QuicFixedUint32() {}
+
+uint32 QuicFixedUint32::GetUint32() const {
+ return value_;
+}
+
+void QuicFixedUint32::ToHandshakeMessage(
+ CryptoHandshakeMessage* out) const {
+ out->SetValue(tag_, value_);
+}
+
+QuicErrorCode QuicFixedUint32::ProcessClientHello(
+ const CryptoHandshakeMessage& client_hello,
+ string* error_details) {
+ DCHECK(error_details != NULL);
+ QuicErrorCode error =
+ ReadUint32(client_hello, tag_, presence_, value_, &value_, error_details);
+ if (error != QUIC_NO_ERROR) {
+ return error;
+ }
+ return QUIC_NO_ERROR;
+}
+
+QuicErrorCode QuicFixedUint32::ProcessServerHello(
+ const CryptoHandshakeMessage& server_hello,
+ string* error_details) {
+ DCHECK(error_details != NULL);
+ QuicErrorCode error =
+ ReadUint32(server_hello, tag_, presence_, value_, &value_, error_details);
+ if (error != QUIC_NO_ERROR) {
+ return error;
+ }
+ return QUIC_NO_ERROR;
+}
+
+QuicConfig::QuicConfig()
+ : congestion_control_(kCGST, PRESENCE_REQUIRED),
+ idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED),
+ keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL),
+ max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED),
+ max_time_before_crypto_handshake_(QuicTime::Delta::Zero()),
+ server_initial_congestion_window_(kSWND, PRESENCE_OPTIONAL),
+ initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL),
+ // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring
+ // QUIC_VERSION_17.
+ peer_initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL, 0) {
// All optional non-zero parameters should be initialized here.
server_initial_congestion_window_.set(kMaxInitialWindow,
kDefaultInitialWindow);
@@ -308,6 +375,14 @@ uint32 QuicConfig::initial_round_trip_time_us() const {
return initial_round_trip_time_us_.GetUint32();
}
+void QuicConfig::set_peer_initial_flow_control_window_bytes(uint32 window) {
+ peer_initial_flow_control_window_bytes_.set_value(window);
+}
+
+uint32 QuicConfig::peer_initial_flow_control_window_bytes() const {
+ return peer_initial_flow_control_window_bytes_.GetUint32();
+}
+
bool QuicConfig::negotiated() {
// TODO(ianswett): Add the negotiated parameters once and iterate over all
// of them in negotiated, ToHandshakeMessage, ProcessClientHello, and
@@ -356,6 +431,7 @@ void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const {
server_initial_congestion_window_.ToHandshakeMessage(out);
// TODO(ianswett): Don't transmit parameters which are optional and not set.
initial_round_trip_time_us_.ToHandshakeMessage(out);
+ peer_initial_flow_control_window_bytes_.ToHandshakeMessage(out);
}
QuicErrorCode QuicConfig::ProcessClientHello(
@@ -387,6 +463,10 @@ QuicErrorCode QuicConfig::ProcessClientHello(
error = initial_round_trip_time_us_.ProcessClientHello(
client_hello, error_details);
}
+ if (error == QUIC_NO_ERROR) {
+ error = peer_initial_flow_control_window_bytes_.ProcessClientHello(
+ client_hello, error_details);
+ }
return error;
}
@@ -419,6 +499,10 @@ QuicErrorCode QuicConfig::ProcessServerHello(
error = initial_round_trip_time_us_.ProcessServerHello(
server_hello, error_details);
}
+ if (error == QUIC_NO_ERROR) {
+ error = peer_initial_flow_control_window_bytes_.ProcessServerHello(
+ server_hello, error_details);
+ }
return error;
}