| Index: net/quic/quic_config.h
|
| diff --git a/net/quic/quic_config.h b/net/quic/quic_config.h
|
| index 7bba457ff51d59db318acbfcb63b332fcd0a2a4b..7e61a9ded55e8194866627a2793aaeca4a66a2f2 100644
|
| --- a/net/quic/quic_config.h
|
| +++ b/net/quic/quic_config.h
|
| @@ -15,33 +15,62 @@ namespace net {
|
|
|
| class CryptoHandshakeMessage;
|
|
|
| -class NET_EXPORT_PRIVATE QuicNegotiableValue {
|
| +// Describes whether or not a given QuicTag is required or optional in the
|
| +// handshake message.
|
| +enum QuicConfigPresence {
|
| + // This value can be absent from the handshake message. Default value is
|
| + // selected as the negotiated value in such a case.
|
| + PRESENCE_OPTIONAL,
|
| + // This value is required in the handshake message otherwise the Process*Hello
|
| + // function returns an error.
|
| + PRESENCE_REQUIRED,
|
| +};
|
| +
|
| +// An abstract base class that stores a value that can be sent in CHLO/SHLO
|
| +// message. These values can be OPTIONAL or REQUIRED, depending on |presence_|.
|
| +class NET_EXPORT_PRIVATE QuicConfigValue {
|
| public:
|
| - enum Presence {
|
| - // This negotiable value can be absent from the handshake message. Default
|
| - // value is selected as the negotiated value in such a case.
|
| - PRESENCE_OPTIONAL,
|
| - // This negotiable value is required in the handshake message otherwise the
|
| - // Process*Hello function returns an error.
|
| - PRESENCE_REQUIRED,
|
| - };
|
| + QuicConfigValue(QuicTag tag, QuicConfigPresence presence);
|
| + virtual ~QuicConfigValue();
|
| +
|
| + // Serialises tag name and value(s) to |out|.
|
| + virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const = 0;
|
| +
|
| + // Selects a mutually acceptable value from those offered in |client_hello|
|
| + // and those defined in the subclass.
|
| + virtual QuicErrorCode ProcessClientHello(
|
| + const CryptoHandshakeMessage& client_hello,
|
| + std::string* error_details) = 0;
|
| +
|
| + // Selects a mutually acceptable value from those offered in |server_hello|
|
| + // and those defined in the subclass.
|
| + virtual QuicErrorCode ProcessServerHello(
|
| + const CryptoHandshakeMessage& server_hello,
|
| + std::string* error_details) = 0;
|
|
|
| - QuicNegotiableValue(QuicTag tag, Presence presence);
|
| + protected:
|
| + const QuicTag tag_;
|
| + const QuicConfigPresence presence_;
|
| +};
|
| +
|
| +class NET_EXPORT_PRIVATE QuicNegotiableValue : public QuicConfigValue {
|
| + public:
|
| + QuicNegotiableValue(QuicTag tag, QuicConfigPresence presence);
|
| + virtual ~QuicNegotiableValue();
|
|
|
| bool negotiated() const {
|
| return negotiated_;
|
| }
|
|
|
| protected:
|
| - const QuicTag tag_;
|
| - const Presence presence_;
|
| bool negotiated_;
|
| };
|
|
|
| class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue {
|
| public:
|
| // Default and max values default to 0.
|
| - QuicNegotiableUint32(QuicTag name, Presence presence);
|
| + QuicNegotiableUint32(QuicTag name, QuicConfigPresence presence);
|
| + virtual ~QuicNegotiableUint32();
|
|
|
| // Sets the maximum possible value that can be achieved after negotiation and
|
| // also the default values to be assumed if PRESENCE_OPTIONAL and the *HLO msg
|
| @@ -55,30 +84,25 @@ class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue {
|
|
|
| // Serialises |name_| and value to |out|. If |negotiated_| is true then
|
| // |negotiated_value_| is serialised, otherwise |max_value_| is serialised.
|
| - void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
|
| + virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
|
|
|
| // Sets |negotiated_value_| to the minimum of |max_value_| and the
|
| // corresponding value from |client_hello|. If the corresponding value is
|
| // missing and PRESENCE_OPTIONAL then |negotiated_value_| is set to
|
| // |default_value_|.
|
| - QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
|
| - std::string* error_details);
|
| + virtual QuicErrorCode ProcessClientHello(
|
| + const CryptoHandshakeMessage& client_hello,
|
| + std::string* error_details) OVERRIDE;
|
|
|
| // Sets the |negotiated_value_| to the corresponding value from
|
| // |server_hello|. Returns error if the value received in |server_hello| is
|
| // greater than |max_value_|. If the corresponding value is missing and
|
| // PRESENCE_OPTIONAL then |negotiated_value_| is set to |0|,
|
| - QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
|
| - std::string* error_details);
|
| + virtual QuicErrorCode ProcessServerHello(
|
| + const CryptoHandshakeMessage& server_hello,
|
| + std::string* error_details) OVERRIDE;
|
|
|
| private:
|
| - // 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 |max_value_|.
|
| - QuicErrorCode ReadUint32(const CryptoHandshakeMessage& msg,
|
| - uint32* out,
|
| - std::string* error_details) const;
|
| -
|
| uint32 max_value_;
|
| uint32 default_value_;
|
| uint32 negotiated_value_;
|
| @@ -86,8 +110,8 @@ class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue {
|
|
|
| class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue {
|
| public:
|
| - QuicNegotiableTag(QuicTag name, Presence presence);
|
| - ~QuicNegotiableTag();
|
| + QuicNegotiableTag(QuicTag name, QuicConfigPresence presence);
|
| + virtual ~QuicNegotiableTag();
|
|
|
| // Sets the possible values that |negotiated_tag_| can take after negotiation
|
| // and the default value that |negotiated_tag_| takes if OPTIONAL and *HLO
|
| @@ -101,19 +125,21 @@ class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue {
|
| // Serialises |name_| and vector (either possible or negotiated) to |out|. If
|
| // |negotiated_| is true then |negotiated_tag_| is serialised, otherwise
|
| // |possible_values_| is serialised.
|
| - void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
|
| + virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
|
|
|
| // Selects the tag common to both tags in |client_hello| for |name_| and
|
| // |possible_values_| with preference to tag in |possible_values_|. The
|
| // selected tag is set as |negotiated_tag_|.
|
| - QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
|
| - std::string* error_details);
|
| + virtual QuicErrorCode ProcessClientHello(
|
| + const CryptoHandshakeMessage& client_hello,
|
| + std::string* error_details) OVERRIDE;
|
|
|
| // Sets the value for |name_| tag in |server_hello| as |negotiated_value_|.
|
| // Returns error if the value received in |server_hello| isn't present in
|
| // |possible_values_|.
|
| - QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
|
| - std::string* error_details);
|
| + virtual QuicErrorCode ProcessServerHello(
|
| + const CryptoHandshakeMessage& server_hello,
|
| + std::string* error_details) OVERRIDE;
|
|
|
| private:
|
| // Reads the vector corresponding to |name_| from |msg| into |out|. If the
|
| @@ -129,6 +155,36 @@ class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue {
|
| QuicTag default_value_;
|
| };
|
|
|
| +// Stores uint32 from CHLO or SHLO messages that are not negotiated.
|
| +class NET_EXPORT_PRIVATE QuicFixedUint32 : public QuicConfigValue {
|
| + public:
|
| + QuicFixedUint32(QuicTag name,
|
| + QuicConfigPresence presence,
|
| + uint32 default_value);
|
| + virtual ~QuicFixedUint32();
|
| +
|
| + // Returns the value in the *HLO message (or the default if not).
|
| + uint32 GetUint32() const;
|
| +
|
| + void set_value(uint32 value) { value_ = value; }
|
| +
|
| + // Serialises |name_| and |value_| to |out|.
|
| + virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
|
| +
|
| + // Sets |value_| to the corresponding value from |client_hello_| if it exists.
|
| + virtual QuicErrorCode ProcessClientHello(
|
| + const CryptoHandshakeMessage& client_hello,
|
| + std::string* error_details) OVERRIDE;
|
| +
|
| + // Sets |value_| to the corresponding value from |server_hello_| if it exists.
|
| + virtual QuicErrorCode ProcessServerHello(
|
| + const CryptoHandshakeMessage& server_hello,
|
| + std::string* error_details) OVERRIDE;
|
| +
|
| + private:
|
| + uint32 value_;
|
| +};
|
| +
|
| // QuicConfig contains non-crypto configuration options that are negotiated in
|
| // the crypto handshake.
|
| class NET_EXPORT_PRIVATE QuicConfig {
|
| @@ -171,6 +227,10 @@ class NET_EXPORT_PRIVATE QuicConfig {
|
|
|
| uint32 initial_round_trip_time_us() const;
|
|
|
| + void set_peer_initial_flow_control_window_bytes(uint32 window);
|
| +
|
| + uint32 peer_initial_flow_control_window_bytes() const;
|
| +
|
| bool negotiated();
|
|
|
| // SetDefaults sets the members to sensible, default values.
|
| @@ -209,6 +269,8 @@ class NET_EXPORT_PRIVATE QuicConfig {
|
| QuicNegotiableUint32 server_initial_congestion_window_;
|
| // Initial round trip time estimate in microseconds.
|
| QuicNegotiableUint32 initial_round_trip_time_us_;
|
| + // Peer's initial flow control receive window in bytes.
|
| + QuicFixedUint32 peer_initial_flow_control_window_bytes_;
|
| };
|
|
|
| } // namespace net
|
|
|