Commit 339489a3 authored by akalin@chromium.org's avatar akalin@chromium.org

Refactor in preparation for SPDY 4, part 1.

Zero behavioral change to the on-the-wire format nor protocol semantics.

This lands server change 40997047.

Also create spdy_protocol.cc and move some functions to it to
avoid clang warnings.


Review URL: https://chromiumcodereview.appspot.com/12220116

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182053 0039d316-1c4b-4281-b951-d872f2087c98
parent f5a27759
...@@ -826,6 +826,7 @@ ...@@ -826,6 +826,7 @@
'spdy/spdy_http_utils.h', 'spdy/spdy_http_utils.h',
'spdy/spdy_io_buffer.cc', 'spdy/spdy_io_buffer.cc',
'spdy/spdy_io_buffer.h', 'spdy/spdy_io_buffer.h',
'spdy/spdy_protocol.cc',
'spdy/spdy_protocol.h', 'spdy/spdy_protocol.h',
'spdy/spdy_proxy_client_socket.cc', 'spdy/spdy_proxy_client_socket.cc',
'spdy/spdy_proxy_client_socket.h', 'spdy/spdy_proxy_client_socket.h',
......
...@@ -12,7 +12,7 @@ namespace net { ...@@ -12,7 +12,7 @@ namespace net {
namespace { namespace {
// Creates a FlagsAndLength. // Creates a FlagsAndLength.
FlagsAndLength CreateFlagsAndLength(SpdyControlFlags flags, size_t length) { FlagsAndLength CreateFlagsAndLength(uint8 flags, size_t length) {
DCHECK_EQ(0u, length & ~static_cast<size_t>(kLengthMask)); DCHECK_EQ(0u, length & ~static_cast<size_t>(kLengthMask));
FlagsAndLength flags_length; FlagsAndLength flags_length;
flags_length.length_ = htonl(static_cast<uint32>(length)); flags_length.length_ = htonl(static_cast<uint32>(length));
...@@ -30,7 +30,7 @@ SpdyFrameBuilder::SpdyFrameBuilder(size_t size) ...@@ -30,7 +30,7 @@ SpdyFrameBuilder::SpdyFrameBuilder(size_t size)
} }
SpdyFrameBuilder::SpdyFrameBuilder(SpdyControlType type, SpdyFrameBuilder::SpdyFrameBuilder(SpdyControlType type,
SpdyControlFlags flags, uint8 flags,
int spdy_version, int spdy_version,
size_t size) size_t size)
: buffer_(new char[size]), : buffer_(new char[size]),
......
...@@ -31,7 +31,9 @@ class NET_EXPORT_PRIVATE SpdyFrameBuilder { ...@@ -31,7 +31,9 @@ class NET_EXPORT_PRIVATE SpdyFrameBuilder {
// Initializes a SpdyFrameBuilder with a buffer of given size, // Initializes a SpdyFrameBuilder with a buffer of given size,
// populate with a SPDY control frame header based on // populate with a SPDY control frame header based on
// |type|, |flags|, and |spdy_version|. // |type|, |flags|, and |spdy_version|.
SpdyFrameBuilder(SpdyControlType type, SpdyControlFlags flags, //
// TODO(akalin): Add a typedef for this uint8.
SpdyFrameBuilder(SpdyControlType type, uint8 flags,
int spdy_version, size_t size); int spdy_version, size_t size);
// Initiailizes a SpdyFrameBuilder with a buffer of given size, // Initiailizes a SpdyFrameBuilder with a buffer of given size,
......
This diff is collapsed.
...@@ -44,6 +44,10 @@ class TestSpdyVisitor; ...@@ -44,6 +44,10 @@ class TestSpdyVisitor;
} // namespace test } // namespace test
// A datastructure for holding a set of headers from either a
// SYN_STREAM or SYN_REPLY frame.
typedef std::map<std::string, std::string> SpdyHeaderBlock;
// A datastructure for holding the ID and flag fields for SETTINGS. // A datastructure for holding the ID and flag fields for SETTINGS.
// Conveniently handles converstion to/from wire format. // Conveniently handles converstion to/from wire format.
class NET_EXPORT_PRIVATE SettingsFlagsAndId { class NET_EXPORT_PRIVATE SettingsFlagsAndId {
...@@ -72,6 +76,7 @@ typedef std::pair<SpdySettingsFlags, uint32> SettingsFlagsAndValue; ...@@ -72,6 +76,7 @@ typedef std::pair<SpdySettingsFlags, uint32> SettingsFlagsAndValue;
typedef std::map<SpdySettingsIds, SettingsFlagsAndValue> SettingsMap; typedef std::map<SpdySettingsIds, SettingsFlagsAndValue> SettingsMap;
// A datastrcture for holding the contents of a CREDENTIAL frame. // A datastrcture for holding the contents of a CREDENTIAL frame.
// TODO(hkhalil): Remove, use SpdyCredentialIR instead.
struct NET_EXPORT_PRIVATE SpdyCredential { struct NET_EXPORT_PRIVATE SpdyCredential {
SpdyCredential(); SpdyCredential();
~SpdyCredential(); ~SpdyCredential();
...@@ -299,6 +304,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -299,6 +304,7 @@ class NET_EXPORT_PRIVATE SpdyFramer {
const SpdyHeaderBlock* headers); const SpdyHeaderBlock* headers);
// Retrieve serialized length of SpdyHeaderBlock. // Retrieve serialized length of SpdyHeaderBlock.
// TODO(hkhalil): Change to const reference instead of const pointer.
static size_t GetSerializedLength(const int spdy_version, static size_t GetSerializedLength(const int spdy_version,
const SpdyHeaderBlock* headers); const SpdyHeaderBlock* headers);
...@@ -360,6 +366,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -360,6 +366,7 @@ class NET_EXPORT_PRIVATE SpdyFramer {
SpdyControlFlags flags, SpdyControlFlags flags,
bool compressed, bool compressed,
const SpdyHeaderBlock* headers); const SpdyHeaderBlock* headers);
SpdySerializedFrame* SerializeSynStream(const SpdySynStreamIR& syn_stream);
// Create a SpdySynReplyControlFrame. // Create a SpdySynReplyControlFrame.
// |stream_id| is the stream for this frame. // |stream_id| is the stream for this frame.
...@@ -371,17 +378,22 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -371,17 +378,22 @@ class NET_EXPORT_PRIVATE SpdyFramer {
SpdyControlFlags flags, SpdyControlFlags flags,
bool compressed, bool compressed,
const SpdyHeaderBlock* headers); const SpdyHeaderBlock* headers);
SpdySerializedFrame* SerializeSynReply(const SpdySynReplyIR& syn_reply);
SpdyRstStreamControlFrame* CreateRstStream(SpdyStreamId stream_id, SpdyRstStreamControlFrame* CreateRstStream(SpdyStreamId stream_id,
SpdyRstStreamStatus status) const; SpdyRstStreamStatus status) const;
SpdySerializedFrame* SerializeRstStream(
const SpdyRstStreamIR& rst_stream) const;
// Creates an instance of SpdySettingsControlFrame. The SETTINGS frame is // Creates an instance of SpdySettingsControlFrame. The SETTINGS frame is
// used to communicate name/value pairs relevant to the communication channel. // used to communicate name/value pairs relevant to the communication channel.
SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const; SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const;
SpdySerializedFrame* SerializeSettings(const SpdySettingsIR& settings) const;
// Creates an instance of SpdyPingControlFrame. The unique_id is used to // Creates an instance of SpdyPingControlFrame. The unique_id is used to
// identify the ping request/response. // identify the ping request/response.
SpdyPingControlFrame* CreatePingFrame(uint32 unique_id) const; SpdyPingControlFrame* CreatePingFrame(uint32 unique_id) const;
SpdySerializedFrame* SerializePing(const SpdyPingIR& ping) const;
// Creates an instance of SpdyGoAwayControlFrame. The GOAWAY frame is used // Creates an instance of SpdyGoAwayControlFrame. The GOAWAY frame is used
// prior to the shutting down of the TCP connection, and includes the // prior to the shutting down of the TCP connection, and includes the
...@@ -389,6 +401,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -389,6 +401,7 @@ class NET_EXPORT_PRIVATE SpdyFramer {
// to completion. // to completion.
SpdyGoAwayControlFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id, SpdyGoAwayControlFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id,
SpdyGoAwayStatus status) const; SpdyGoAwayStatus status) const;
SpdySerializedFrame* SerializeGoAway(const SpdyGoAwayIR& goaway) const;
// Creates an instance of SpdyHeadersControlFrame. The HEADERS frame is used // Creates an instance of SpdyHeadersControlFrame. The HEADERS frame is used
// for sending additional headers outside of a SYN_STREAM/SYN_REPLY. The // for sending additional headers outside of a SYN_STREAM/SYN_REPLY. The
...@@ -397,18 +410,23 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -397,18 +410,23 @@ class NET_EXPORT_PRIVATE SpdyFramer {
SpdyControlFlags flags, SpdyControlFlags flags,
bool compressed, bool compressed,
const SpdyHeaderBlock* headers); const SpdyHeaderBlock* headers);
SpdySerializedFrame* SerializeHeaders(const SpdyHeadersIR& headers);
// Creates an instance of SpdyWindowUpdateControlFrame. The WINDOW_UPDATE // Creates an instance of SpdyWindowUpdateControlFrame. The WINDOW_UPDATE
// frame is used to implement per stream flow control in SPDY. // frame is used to implement per stream flow control in SPDY.
SpdyWindowUpdateControlFrame* CreateWindowUpdate( SpdyWindowUpdateControlFrame* CreateWindowUpdate(
SpdyStreamId stream_id, SpdyStreamId stream_id,
uint32 delta_window_size) const; uint32 delta_window_size) const;
SpdySerializedFrame* SerializeWindowUpdate(
const SpdyWindowUpdateIR& window_update) const;
// Creates an instance of SpdyCredentialControlFrame. The CREDENTIAL // Creates an instance of SpdyCredentialControlFrame. The CREDENTIAL
// frame is used to send a client certificate to the server when // frame is used to send a client certificate to the server when
// request more than one origin are sent over the same SPDY session. // request more than one origin are sent over the same SPDY session.
SpdyCredentialControlFrame* CreateCredentialFrame( SpdyCredentialControlFrame* CreateCredentialFrame(
const SpdyCredential& credential) const; const SpdyCredential& credential) const;
SpdySerializedFrame* SerializeCredential(
const SpdyCredentialIR& credential) const;
// Given a SpdySettingsControlFrame, extract the settings. // Given a SpdySettingsControlFrame, extract the settings.
// Returns true on successful parse, false otherwise. // Returns true on successful parse, false otherwise.
...@@ -430,6 +448,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -430,6 +448,7 @@ class NET_EXPORT_PRIVATE SpdyFramer {
// To mark this frame as the last data frame, enable DATA_FLAG_FIN. // To mark this frame as the last data frame, enable DATA_FLAG_FIN.
SpdyDataFrame* CreateDataFrame(SpdyStreamId stream_id, const char* data, SpdyDataFrame* CreateDataFrame(SpdyStreamId stream_id, const char* data,
uint32 len, SpdyDataFlags flags) const; uint32 len, SpdyDataFlags flags) const;
SpdySerializedFrame* SerializeData(const SpdyDataIR& data) const;
// NOTES about frame compression. // NOTES about frame compression.
// We want spdy to compress headers across the entire session. As long as // We want spdy to compress headers across the entire session. As long as
...@@ -467,7 +486,9 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -467,7 +486,9 @@ class NET_EXPORT_PRIVATE SpdyFramer {
const SpdyControlFrame* control_frame); const SpdyControlFrame* control_frame);
// For ease of testing and experimentation we can tweak compression on/off. // For ease of testing and experimentation we can tweak compression on/off.
void set_enable_compression(bool value); void set_enable_compression(bool value) {
enable_compression_ = value;
}
// Used only in log messages. // Used only in log messages.
void set_display_protocol(const std::string& protocol) { void set_display_protocol(const std::string& protocol) {
...@@ -560,6 +581,10 @@ class NET_EXPORT_PRIVATE SpdyFramer { ...@@ -560,6 +581,10 @@ class NET_EXPORT_PRIVATE SpdyFramer {
void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, void WriteHeaderBlockToZ(const SpdyHeaderBlock* headers,
z_stream* out) const; z_stream* out) const;
void SerializeNameValueBlock(
SpdyFrameBuilder* builder,
const SpdyFrameWithNameValueBlockIR& frame) const;
// Set the error code and moves the framer into the error state. // Set the error code and moves the framer into the error state.
void set_error(SpdyError error); void set_error(SpdyError error);
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/spdy/spdy_protocol.h"
namespace net {
SpdyFrameWithNameValueBlockIR::SpdyFrameWithNameValueBlockIR(
SpdyStreamId stream_id) : SpdyFrameWithFinIR(stream_id) {}
SpdyFrameWithNameValueBlockIR::~SpdyFrameWithNameValueBlockIR() {}
SpdySettingsIR::SpdySettingsIR() : clear_settings_(false) {}
SpdySettingsIR::~SpdySettingsIR() {}
SpdyCredentialIR::SpdyCredentialIR(int16 slot) {
set_slot(slot);
}
SpdyCredentialIR::~SpdyCredentialIR() {}
} // namespace
...@@ -8,9 +8,12 @@ ...@@ -8,9 +8,12 @@
#define NET_SPDY_SPDY_PROTOCOL_H_ #define NET_SPDY_SPDY_PROTOCOL_H_
#include <limits> #include <limits>
#include <map>
#include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/string_piece.h"
#include "base/sys_byteorder.h" #include "base/sys_byteorder.h"
#include "net/spdy/spdy_bitmasks.h" #include "net/spdy/spdy_bitmasks.h"
...@@ -355,6 +358,7 @@ const int kV3DictionarySize = arraysize(kV3Dictionary); ...@@ -355,6 +358,7 @@ const int kV3DictionarySize = arraysize(kV3Dictionary);
// Note: all protocol data structures are on-the-wire format. That means that // Note: all protocol data structures are on-the-wire format. That means that
// data is stored in network-normalized order. Readers must use the // data is stored in network-normalized order. Readers must use the
// accessors provided or call ntohX() functions. // accessors provided or call ntohX() functions.
// TODO(hkhalil): remove above note.
// Types of Spdy Control Frames. // Types of Spdy Control Frames.
enum SpdyControlType { enum SpdyControlType {
...@@ -445,6 +449,12 @@ typedef uint32 SpdyStreamId; ...@@ -445,6 +449,12 @@ typedef uint32 SpdyStreamId;
// number between 0 and 3. // number between 0 and 3.
typedef uint8 SpdyPriority; typedef uint8 SpdyPriority;
typedef uint8 SpdyCredentialSlot;
typedef std::map<std::string, std::string> SpdyNameValueBlock;
typedef uint32 SpdyPingId;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// These structures mirror the protocol structure definitions. // These structures mirror the protocol structure definitions.
...@@ -532,6 +542,298 @@ struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock { ...@@ -532,6 +542,298 @@ struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock {
#pragma pack(pop) #pragma pack(pop)
class SpdyFrame;
typedef SpdyFrame SpdySerializedFrame;
class SpdyFramer;
class SpdyFrameBuilder;
// Intermediate representation for SPDY frames.
// TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is
// gone.
class SpdyFrameIR {
public:
virtual ~SpdyFrameIR() {}
protected:
SpdyFrameIR() {}
private:
DISALLOW_COPY_AND_ASSIGN(SpdyFrameIR);
};
// Abstract class intended to be inherited by IRs that have a stream associated
// to them.
class SpdyFrameWithStreamIdIR : public SpdyFrameIR {
public:
virtual ~SpdyFrameWithStreamIdIR() {}
SpdyStreamId stream_id() const { return stream_id_; }
void set_stream_id(SpdyStreamId stream_id) {
// TODO(hkhalil): DCHECK_LT(0u, stream_id);
DCHECK_EQ(0u, stream_id & ~kStreamIdMask);
stream_id_ = stream_id;
}
protected:
explicit SpdyFrameWithStreamIdIR(SpdyStreamId stream_id) {
set_stream_id(stream_id);
}
private:
SpdyStreamId stream_id_;
DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithStreamIdIR);
};
// Abstract class intended to be inherited by IRs that have the option of a FIN
// flag. Implies SpdyFrameWithStreamIdIR.
class SpdyFrameWithFinIR : public SpdyFrameWithStreamIdIR {
public:
virtual ~SpdyFrameWithFinIR() {}
bool fin() const { return fin_; }
void set_fin(bool fin) { fin_ = fin; }
protected:
explicit SpdyFrameWithFinIR(SpdyStreamId stream_id)
: SpdyFrameWithStreamIdIR(stream_id),
fin_(false) {}
private:
bool fin_;
DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR);
};
// Abstract class intended to be inherited by IRs that contain a name-value
// block. Implies SpdyFrameWithFinIR.
class SpdyFrameWithNameValueBlockIR : public SpdyFrameWithFinIR {
public:
const SpdyNameValueBlock& name_value_block() const {
return name_value_block_;
}
SpdyNameValueBlock* GetMutableNameValueBlock() { return &name_value_block_; }
protected:
explicit SpdyFrameWithNameValueBlockIR(SpdyStreamId stream_id);
virtual ~SpdyFrameWithNameValueBlockIR();
private:
SpdyNameValueBlock name_value_block_;
DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithNameValueBlockIR);
};
class SpdyDataIR : public SpdyFrameWithFinIR {
public:
SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data)
: SpdyFrameWithFinIR(stream_id) {
set_data(data);
}
base::StringPiece data() const { return data_; }
void set_data(const base::StringPiece& data) { data.CopyToString(&data_); }
private:
std::string data_;
DISALLOW_COPY_AND_ASSIGN(SpdyDataIR);
};
class SpdySynStreamIR : public SpdyFrameWithNameValueBlockIR {
public:
explicit SpdySynStreamIR(SpdyStreamId stream_id)
: SpdyFrameWithNameValueBlockIR(stream_id),
associated_to_stream_id_(0),
priority_(0),
slot_(0),
unidirectional_(false) {}
SpdyStreamId associated_to_stream_id() const {
return associated_to_stream_id_;
}
void set_associated_to_stream_id(SpdyStreamId stream_id) {
associated_to_stream_id_ = stream_id;
}
SpdyPriority priority() const { return priority_; }
void set_priority(SpdyPriority priority) { priority_ = priority; }
SpdyCredentialSlot slot() const { return slot_; }
void set_slot(SpdyCredentialSlot slot) { slot_ = slot; }
bool unidirectional() const { return unidirectional_; }
void set_unidirectional(bool unidirectional) {
unidirectional_ = unidirectional;
}
private:
SpdyStreamId associated_to_stream_id_;
SpdyPriority priority_;
SpdyCredentialSlot slot_;
bool unidirectional_;
DISALLOW_COPY_AND_ASSIGN(SpdySynStreamIR);
};
class SpdySynReplyIR : public SpdyFrameWithNameValueBlockIR {
public:
explicit SpdySynReplyIR(SpdyStreamId stream_id)
: SpdyFrameWithNameValueBlockIR(stream_id) {}
private:
DISALLOW_COPY_AND_ASSIGN(SpdySynReplyIR);
};
class SpdyRstStreamIR : public SpdyFrameWithStreamIdIR {
public:
SpdyRstStreamIR(SpdyStreamId stream_id, SpdyRstStreamStatus status)
: SpdyFrameWithStreamIdIR(stream_id) {
set_status(status);
}
SpdyRstStreamStatus status() const {
return status_;
}
void set_status(SpdyRstStreamStatus status) {
DCHECK_NE(status, RST_STREAM_INVALID);
DCHECK_LT(status, RST_STREAM_NUM_STATUS_CODES);
status_ = status;
}
private:
SpdyRstStreamStatus status_;
DISALLOW_COPY_AND_ASSIGN(SpdyRstStreamIR);
};
class SpdySettingsIR : public SpdyFrameIR {
public:
// Associates flags with a value.
struct Value {
Value() : persist_value(false),
persisted(false),
value(0) {}
bool persist_value;
bool persisted;
int32 value;
};
typedef std::map<SpdySettingsIds, Value> ValueMap;
SpdySettingsIR();
virtual ~SpdySettingsIR();
// Overwrites as appropriate.
const ValueMap& values() const { return values_; }
void AddSetting(SpdySettingsIds id,
bool persist_value,
bool persisted,
int32 value) {
// TODO(hkhalil): DCHECK_LE(SETTINGS_UPLOAD_BANDWIDTH, id);
// TODO(hkhalil): DCHECK_GE(SETTINGS_INITIAL_WINDOW_SIZE, id);
values_[id].persist_value = persist_value;
values_[id].persisted = persisted;
values_[id].value = value;
}
bool clear_settings() const { return clear_settings_; }
void set_clear_settings(bool clear_settings) {
clear_settings_ = clear_settings;
}
private:
ValueMap values_;
bool clear_settings_;
DISALLOW_COPY_AND_ASSIGN(SpdySettingsIR);
};
class SpdyPingIR : public SpdyFrameIR {
public:
explicit SpdyPingIR(SpdyPingId id) : id_(id) {}
SpdyPingId id() const { return id_; }
private:
SpdyPingId id_;
DISALLOW_COPY_AND_ASSIGN(SpdyPingIR);
};
class SpdyGoAwayIR : public SpdyFrameIR {
public:
SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyGoAwayStatus status) {
set_last_good_stream_id(last_good_stream_id);
set_status(status);
}
SpdyStreamId last_good_stream_id() const { return last_good_stream_id_; }
void set_last_good_stream_id(SpdyStreamId last_good_stream_id) {
DCHECK_LE(0u, last_good_stream_id);
DCHECK_EQ(0u, last_good_stream_id & ~kStreamIdMask);
last_good_stream_id_ = last_good_stream_id;
}
SpdyGoAwayStatus status() const { return status_; }
void set_status(SpdyGoAwayStatus status) {
// TODO(hkhalil): Check valid ranges of status?
status_ = status;
}
private:
SpdyStreamId last_good_stream_id_;
SpdyGoAwayStatus status_;
DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayIR);
};
class SpdyHeadersIR : public SpdyFrameWithNameValueBlockIR {
public:
explicit SpdyHeadersIR(SpdyStreamId stream_id)
: SpdyFrameWithNameValueBlockIR(stream_id) {}
private:
DISALLOW_COPY_AND_ASSIGN(SpdyHeadersIR);
};
class SpdyWindowUpdateIR : public SpdyFrameWithStreamIdIR {
public:
SpdyWindowUpdateIR(SpdyStreamId stream_id, int32 delta)
: SpdyFrameWithStreamIdIR(stream_id) {
set_delta(delta);
}
int32 delta() const { return delta_; }
void set_delta(int32 delta) {
DCHECK_LT(0, delta);
DCHECK_LE(delta, kSpdyStreamMaximumWindowSize);
delta_ = delta;
}
private:
int32 delta_;
DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateIR);
};
class SpdyCredentialIR : public SpdyFrameIR {
public:
typedef std::vector<std::string> CertificateList;
explicit SpdyCredentialIR(int16 slot);
virtual ~SpdyCredentialIR();
int16 slot() const { return slot_; }
void set_slot(int16 slot) {
// TODO(hkhalil): Verify valid slot range?
slot_ = slot;
}
base::StringPiece proof() const { return proof_; }
void set_proof(const base::StringPiece& proof) {
proof.CopyToString(&proof_);
}
const CertificateList* certificates() const { return &certificates_; }
void AddCertificate(const base::StringPiece& certificate) {
certificates_.push_back(certificate.as_string());
}
private:
int16 slot_;
std::string proof_;
CertificateList certificates_;
DISALLOW_COPY_AND_ASSIGN(SpdyCredentialIR);
};
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Wrapper classes for various SPDY frames. // Wrapper classes for various SPDY frames.
...@@ -731,7 +1033,7 @@ class SpdySynStreamControlFrame : public SpdyControlFrame { ...@@ -731,7 +1033,7 @@ class SpdySynStreamControlFrame : public SpdyControlFrame {
} }
void set_credential_slot(uint8 credential_slot) { void set_credential_slot(uint8 credential_slot) {
DCHECK(version() >= 3); DCHECK_LE(3, version());
mutable_block()->credential_slot_ = credential_slot; mutable_block()->credential_slot_ = credential_slot;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment