From 977bd848c54ac0d8b7cd907d1f70cec19b01802d Mon Sep 17 00:00:00 2001 From: "akalin@chromium.org" Date: Thu, 16 May 2013 17:43:42 +0000 Subject: Add SpdyMajorVersion enum and use it everywhere This is a bit more type-safe than just passing around ints. Also add TODO for NPN->SpdyVersion conversion functions. This lands server change 45485205. R=rch@chromium.org Review URL: https://codereview.chromium.org/14348010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200568 0039d316-1c4b-4281-b951-d872f2087c98 --- net/spdy/buffered_spdy_framer.cc | 3 +- net/spdy/buffered_spdy_framer.h | 2 +- net/spdy/buffered_spdy_framer_spdy2_unittest.cc | 10 +- net/spdy/buffered_spdy_framer_spdy3_unittest.cc | 10 +- net/spdy/spdy_frame_builder_test.cc | 13 +- net/spdy/spdy_framer.cc | 15 +- net/spdy/spdy_framer.h | 21 +-- net/spdy/spdy_framer_test.cc | 159 ++++++++++----------- net/spdy/spdy_http_stream.cc | 6 +- net/spdy/spdy_http_stream_spdy3_unittest.cc | 11 +- .../spdy_network_transaction_spdy2_unittest.cc | 22 +-- .../spdy_network_transaction_spdy3_unittest.cc | 22 +-- net/spdy/spdy_protocol.h | 15 +- net/spdy/spdy_session.cc | 10 +- net/spdy/spdy_session_spdy2_unittest.cc | 14 +- net/spdy/spdy_session_spdy3_unittest.cc | 18 +-- net/spdy/spdy_test_util_common.cc | 20 +-- net/spdy/spdy_test_util_common.h | 12 +- net/spdy/spdy_test_util_spdy2.cc | 4 +- net/spdy/spdy_test_util_spdy3.cc | 25 ++-- net/spdy/spdy_test_util_spdy3.h | 8 +- net/spdy/spdy_websocket_test_util_spdy2.cc | 2 +- net/spdy/spdy_websocket_test_util_spdy3.cc | 2 +- 23 files changed, 205 insertions(+), 219 deletions(-) (limited to 'net/spdy') diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc index 07e9451..e62316c 100644 --- a/net/spdy/buffered_spdy_framer.cc +++ b/net/spdy/buffered_spdy_framer.cc @@ -8,7 +8,8 @@ namespace net { -BufferedSpdyFramer::BufferedSpdyFramer(int version, bool enable_compression) +BufferedSpdyFramer::BufferedSpdyFramer(SpdyMajorVersion version, + bool enable_compression) : spdy_framer_(version), visitor_(NULL), header_buffer_used_(0), diff --git a/net/spdy/buffered_spdy_framer.h b/net/spdy/buffered_spdy_framer.h index 893c78c..2df0c9b 100644 --- a/net/spdy/buffered_spdy_framer.h +++ b/net/spdy/buffered_spdy_framer.h @@ -98,7 +98,7 @@ class NET_EXPORT_PRIVATE BufferedSpdyFramerVisitorInterface { class NET_EXPORT_PRIVATE BufferedSpdyFramer : public SpdyFramerVisitorInterface { public: - BufferedSpdyFramer(int version, + BufferedSpdyFramer(SpdyMajorVersion version, bool enable_compression); virtual ~BufferedSpdyFramer(); diff --git a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc index 403e945..3248f7e 100644 --- a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc @@ -16,7 +16,7 @@ namespace { class TestBufferedSpdyVisitor : public BufferedSpdyFramerVisitorInterface { public: TestBufferedSpdyVisitor() - : buffered_spdy_framer_(2, true), + : buffered_spdy_framer_(SPDY2, true), error_count_(0), setting_count_(0), syn_frame_count_(0), @@ -185,7 +185,7 @@ class BufferedSpdyFramerSpdy2Test : public PlatformTest { }; TEST_F(BufferedSpdyFramerSpdy2Test, OnSetting) { - SpdyFramer framer(2); + SpdyFramer framer(SPDY2); SettingsMap settings; settings[SETTINGS_UPLOAD_BANDWIDTH] = SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); @@ -206,7 +206,7 @@ TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynStreamHeaderBlock) { SpdyHeaderBlock headers; headers["aa"] = "vv"; headers["bb"] = "ww"; - BufferedSpdyFramer framer(2, true); + BufferedSpdyFramer framer(SPDY2, true); scoped_ptr control_frame( framer.CreateSynStream(1, // stream_id 0, // associated_stream_id @@ -232,7 +232,7 @@ TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynReplyHeaderBlock) { SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; - BufferedSpdyFramer framer(2, true); + BufferedSpdyFramer framer(SPDY2, true); scoped_ptr control_frame( framer.CreateSynReply(1, // stream_id CONTROL_FLAG_NONE, @@ -255,7 +255,7 @@ TEST_F(BufferedSpdyFramerSpdy2Test, ReadHeadersHeaderBlock) { SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; - BufferedSpdyFramer framer(2, true); + BufferedSpdyFramer framer(SPDY2, true); scoped_ptr control_frame( framer.CreateHeaders(1, // stream_id CONTROL_FLAG_NONE, diff --git a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc index 3ed5a1a..b9058fc 100644 --- a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc @@ -16,7 +16,7 @@ namespace { class TestBufferedSpdyVisitor : public BufferedSpdyFramerVisitorInterface { public: TestBufferedSpdyVisitor() - : buffered_spdy_framer_(3, true), + : buffered_spdy_framer_(SPDY3, true), error_count_(0), setting_count_(0), syn_frame_count_(0), @@ -183,7 +183,7 @@ class BufferedSpdyFramerSpdy3Test : public PlatformTest { }; TEST_F(BufferedSpdyFramerSpdy3Test, OnSetting) { - SpdyFramer framer(3); + SpdyFramer framer(SPDY3); framer.set_enable_compression(false); SettingsMap settings; settings[SETTINGS_UPLOAD_BANDWIDTH] = @@ -205,7 +205,7 @@ TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynStreamHeaderBlock) { SpdyHeaderBlock headers; headers["aa"] = "vv"; headers["bb"] = "ww"; - BufferedSpdyFramer framer(3, true); + BufferedSpdyFramer framer(SPDY3, true); scoped_ptr control_frame( framer.CreateSynStream(1, // stream_id 0, // associated_stream_id @@ -231,7 +231,7 @@ TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynReplyHeaderBlock) { SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; - BufferedSpdyFramer framer(3, true); + BufferedSpdyFramer framer(SPDY3, true); scoped_ptr control_frame( framer.CreateSynReply(1, // stream_id CONTROL_FLAG_NONE, @@ -254,7 +254,7 @@ TEST_F(BufferedSpdyFramerSpdy3Test, ReadHeadersHeaderBlock) { SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "delta"; - BufferedSpdyFramer framer(3, true); + BufferedSpdyFramer framer(SPDY3, true); scoped_ptr control_frame( framer.CreateHeaders(1, // stream_id CONTROL_FLAG_NONE, diff --git a/net/spdy/spdy_frame_builder_test.cc b/net/spdy/spdy_frame_builder_test.cc index 65d9b05..014449b 100644 --- a/net/spdy/spdy_frame_builder_test.cc +++ b/net/spdy/spdy_frame_builder_test.cc @@ -23,21 +23,14 @@ TEST(SpdyFrameBuilderTestVersionAgnostic, GetWritableBuffer) { base::StringPiece(frame->data(), builder_size)); } -enum SpdyFrameBuilderTestTypes { - SPDY2 = 2, - SPDY3 = 3, - SPDY4 = 4, -}; - -class SpdyFrameBuilderTest - : public ::testing::TestWithParam { +class SpdyFrameBuilderTest : public ::testing::TestWithParam { protected: virtual void SetUp() { spdy_version_ = GetParam(); } - // Version of SPDY protocol to be used. - unsigned char spdy_version_; + // Major version of SPDY protocol to be used. + SpdyMajorVersion spdy_version_; }; // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index b3954484..5d1d445 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -51,8 +51,6 @@ const uint8 kNoFlags = 0; } // namespace -const int SpdyFramer::kMinSpdyVersion = kSpdyVersion2; -const int SpdyFramer::kMaxSpdyVersion = kSpdyVersion4; const SpdyStreamId SpdyFramer::kInvalidStream = -1; const size_t SpdyFramer::kHeaderDataChunkMaxSize = 1024; // The size of the control frame buffer. Must be >= the minimum size of the @@ -116,7 +114,7 @@ void SettingsFlagsAndId::ConvertFlagsAndIdForSpdy2(uint32* val) { SpdyCredential::SpdyCredential() : slot(0) {} SpdyCredential::~SpdyCredential() {} -SpdyFramer::SpdyFramer(int version) +SpdyFramer::SpdyFramer(SpdyMajorVersion version) : current_frame_buffer_(new char[kControlFrameBufferSize]), enable_compression_(true), visitor_(NULL), @@ -125,8 +123,8 @@ SpdyFramer::SpdyFramer(int version) spdy_version_(version), syn_frame_processed_(false), probable_http_response_(false) { - DCHECK_GE(kMaxSpdyVersion, version); - DCHECK_LE(kMinSpdyVersion, version); + DCHECK_GE(spdy_version_, SPDY_MIN_VERSION); + DCHECK_LE(spdy_version_, SPDY_MAX_VERSION); Reset(); } @@ -163,10 +161,9 @@ size_t SpdyFramer::GetDataFrameMinimumSize() const { // Size, in bytes, of the control frame header. size_t SpdyFramer::GetControlFrameHeaderSize() const { switch (protocol_version()) { - case 2: - case 3: - return 8; - case 4: + case SPDY2: + case SPDY3: + case SPDY4: return 8; } LOG(DFATAL) << "Unhandled SPDY version."; diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index c4e452c..856f029 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h @@ -289,12 +289,6 @@ class NET_EXPORT_PRIVATE SpdyFramer { LAST_ERROR, // Must be the last entry in the enum. }; - // The minimum supported SPDY version that SpdyFramer can speak. - static const int kMinSpdyVersion; - - // The maximum supported SPDY version that SpdyFramer can speak. - static const int kMaxSpdyVersion; - // Constant for invalid (or unknown) stream IDs. static const SpdyStreamId kInvalidStream; @@ -314,7 +308,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { const SpdyHeaderBlock* headers); // Create a new Framer, provided a SPDY version. - explicit SpdyFramer(int version); + explicit SpdyFramer(SpdyMajorVersion version); virtual ~SpdyFramer(); // Set callbacks to be called from the framer. A visitor must be set, or @@ -507,7 +501,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { static const char* StatusCodeToString(int status_code); static const char* FrameTypeToString(SpdyFrameType type); - int protocol_version() const { return spdy_version_; } + SpdyMajorVersion protocol_version() const { return spdy_version_; } bool probable_http_response() const { return probable_http_response_; } @@ -616,10 +610,10 @@ class NET_EXPORT_PRIVATE SpdyFramer { // The theoretical maximum for SPDY3 and earlier is (2^24 - 1) + // 8, since the length field does not count the size of the // header. - if (spdy_version_ == kSpdyVersion2) { + if (spdy_version_ == SPDY2) { return 64 * 1024; } - if (spdy_version_ == kSpdyVersion3) { + if (spdy_version_ == SPDY3) { return 16 * 1024 * 1024; } // The theoretical maximum for SPDY4 is 2^16 - 1, as the length @@ -674,11 +668,8 @@ class NET_EXPORT_PRIVATE SpdyFramer { std::string display_protocol_; - // The SPDY version to be spoken/understood by this framer. We support only - // integer versions here, as major version numbers indicate framer-layer - // incompatibility and minor version numbers indicate application-layer - // incompatibility. - const int spdy_version_; + // The major SPDY version to be spoken/understood by this framer. + const SpdyMajorVersion spdy_version_; // Tracks if we've ever gotten far enough in framing to see a control frame of // type SYN_STREAM or SYN_REPLY. diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 60d784a..6773671 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -100,7 +100,7 @@ class SpdyFramerTestUtil { class DecompressionVisitor : public SpdyFramerVisitorInterface { public: - explicit DecompressionVisitor(int version) + explicit DecompressionVisitor(SpdyMajorVersion version) : version_(version), size_(0), finished_(false) {} void ResetBuffer() { @@ -245,7 +245,7 @@ class SpdyFramerTestUtil { } private: - int version_; + SpdyMajorVersion version_; scoped_ptr buffer_; size_t size_; bool finished_; @@ -263,7 +263,7 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface, static const size_t kDefaultHeaderBufferSize = 16 * 1024 * 1024; static const size_t kDefaultCredentialBufferSize = 16 * 1024; - explicit TestSpdyVisitor(int version) + explicit TestSpdyVisitor(SpdyMajorVersion version) : framer_(version), use_compression_(false), error_count_(0), @@ -543,17 +543,11 @@ using net::test::GetSerializedHeaders; namespace net { -enum SpdyFramerTestTypes { - SPDY2 = 2, - SPDY3 = 3, - SPDY4 = 4, -}; - -class SpdyFramerTest - : public ::testing::TestWithParam { +class SpdyFramerTest : public ::testing::TestWithParam { protected: virtual void SetUp() { spdy_version_ = GetParam(); + spdy_version_ch_ = static_cast(spdy_version_); } void CompareFrame(const string& description, @@ -621,7 +615,8 @@ class SpdyFramerTest bool IsSpdy4() { return spdy_version_ == SPDY4; } // Version of SPDY protocol to be used. - unsigned char spdy_version_; + SpdyMajorVersion spdy_version_; + unsigned char spdy_version_ch_; }; // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. @@ -733,7 +728,7 @@ TEST_P(SpdyFramerTest, CreateCredential) { { const char kDescription[] = "CREDENTIAL frame"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x0A, + 0x80, spdy_version_ch_, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x33, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 'p', 'r', @@ -786,7 +781,7 @@ TEST_P(SpdyFramerTest, ParseCredentialFrameData) { { const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x0A, + 0x80, spdy_version_ch_, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x33, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 'p', 'r', @@ -1040,7 +1035,7 @@ TEST_P(SpdyFramerTest, CompressEmptyHeaders) { TEST_P(SpdyFramerTest, Basic) { const unsigned char kV2Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1048,7 +1043,7 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x02, 'h', 'h', 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x08, // HEADERS on Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x08, // HEADERS on Stream #1 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -1063,7 +1058,7 @@ TEST_P(SpdyFramerTest, Basic) { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #3 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #3 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, @@ -1078,7 +1073,7 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x00, 0x00, 0x04, 0xde, 0xad, 0xbe, 0xef, - 0x80, spdy_version_, 0x00, 0x03, // RST_STREAM on Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #1 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1086,14 +1081,14 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3 0x00, 0x00, 0x00, 0x00, - 0x80, spdy_version_, 0x00, 0x03, // RST_STREAM on Stream #3 + 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, }; const unsigned char kV3Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1103,7 +1098,7 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x00, 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x08, // HEADERS on Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x08, // HEADERS on Stream #1 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -1121,7 +1116,7 @@ TEST_P(SpdyFramerTest, Basic) { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #3 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #3 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, @@ -1137,7 +1132,7 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x00, 0x00, 0x04, 0xde, 0xad, 0xbe, 0xef, - 0x80, spdy_version_, 0x00, 0x03, // RST_STREAM on Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #1 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1145,7 +1140,7 @@ TEST_P(SpdyFramerTest, Basic) { 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3 0x00, 0x00, 0x00, 0x00, - 0x80, spdy_version_, 0x00, 0x03, // RST_STREAM on Stream #3 + 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, @@ -1227,7 +1222,7 @@ TEST_P(SpdyFramerTest, Basic) { // Test that the FIN flag on a data frame signifies EOF. TEST_P(SpdyFramerTest, FinOnDataFrame) { const unsigned char kV2Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1235,7 +1230,7 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { 0x00, 0x02, 'h', 'h', 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x02, // SYN REPLY Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -1253,7 +1248,7 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { 0xde, 0xad, 0xbe, 0xef, }; const unsigned char kV3Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1263,7 +1258,7 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { 0x00, 0x00, 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x02, // SYN REPLY Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -1332,7 +1327,7 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { // Test that the FIN flag on a SYN reply frame signifies EOF. TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { const unsigned char kV2Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1340,7 +1335,7 @@ TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { 0x00, 0x02, 'h', 'h', 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x02, // SYN REPLY Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -1348,7 +1343,7 @@ TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { 0x00, 0x02, 'b', 'b', }; const unsigned char kV3Input[] = { - 0x80, spdy_version_, 0x00, 0x01, // SYN Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1358,7 +1353,7 @@ TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { 0x00, 0x00, 0x00, 0x02, 'v', 'v', - 0x80, spdy_version_, 0x00, 0x02, // SYN REPLY Stream #1 + 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -1591,7 +1586,7 @@ TEST_P(SpdyFramerTest, WindowUpdateFrame) { const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x09, + 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x12, 0x34, 0x56, 0x78 @@ -1780,7 +1775,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { const unsigned char kPri = IsSpdy2() ? 0xC0 : 0xE0; const unsigned char kCre = IsSpdy2() ? 0 : 2; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1792,7 +1787,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { 0x03, 'b', 'a', 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -1847,7 +1842,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x1D, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, @@ -1859,7 +1854,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x27, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, @@ -1913,7 +1908,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { const unsigned char kPri = IsSpdy2() ? 0x40 : 0x20; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x1D, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, @@ -1925,7 +1920,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { 0x00 }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x27, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, @@ -1986,7 +1981,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { const SpdyPriority priority = IsSpdy2() ? 2 : 4; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -2004,7 +1999,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { 0xff, 0xff, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x01, + 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, @@ -2069,7 +2064,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -2080,7 +2075,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { 0x03, 'b', 'a', 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -2124,7 +2119,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x19, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2135,7 +2130,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x21, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2179,7 +2174,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { headers["foo"] = ""; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x19, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2190,7 +2185,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { 0x00 }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x21, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2241,7 +2236,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x38, 0xea, @@ -2258,7 +2253,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { 0xff, 0xff, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x02, + 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x38, 0xea, 0xe3, 0xc6, @@ -2309,7 +2304,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x03, + 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -2331,7 +2326,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame with max stream ID"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x03, + 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, @@ -2353,7 +2348,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame with max status code"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x03, + 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x06, @@ -2390,14 +2385,14 @@ TEST_P(SpdyFramerTest, CreateSettings) { EXPECT_EQ(kValue, settings[kId].second); const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x04, 0x03, 0x02, 0x01, 0x0a, 0x0b, 0x0c, 0x0d, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, @@ -2435,7 +2430,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { &settings, 0x03000003, 0xff000004); // 4th Setting const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // 1st Setting @@ -2474,7 +2469,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { SettingsMap settings; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, }; @@ -2498,7 +2493,7 @@ TEST_P(SpdyFramerTest, CreatePingFrame) { { const char kDescription[] = "PING frame"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x06, + 0x80, spdy_version_ch_, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x12, 0x34, 0x56, 0x78, }; @@ -2522,12 +2517,12 @@ TEST_P(SpdyFramerTest, CreateGoAway) { { const char kDescription[] = "GOAWAY frame"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -2551,12 +2546,12 @@ TEST_P(SpdyFramerTest, CreateGoAway) { { const char kDescription[] = "GOAWAY frame with max stream ID, status"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x7f, 0xff, 0xff, 0xff, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2591,7 +2586,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -2602,7 +2597,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { 0x03, 'b', 'a', 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, @@ -2646,7 +2641,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x19, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2657,7 +2652,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { 'r' }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x21, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2701,7 +2696,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers["foo"] = ""; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x19, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2712,7 +2707,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { 0x00 }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x21, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, @@ -2763,7 +2758,7 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) { headers["foo"] = "bar"; const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x38, 0xea, @@ -2780,7 +2775,7 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) { 0xff, 0xff, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x08, + 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x38, 0xea, 0xe3, 0xc6, @@ -2831,7 +2826,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x09, + 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, @@ -2853,7 +2848,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x09, + 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, @@ -2874,7 +2869,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x09, + 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x7f, 0xff, 0xff, 0xff, @@ -3158,7 +3153,7 @@ TEST_P(SpdyFramerTest, ControlFrameSizesAreValidated) { ASSERT_GE(250u, SpdyFramer::kControlFrameBufferSize); const unsigned char length = 1 + SpdyFramer::kControlFrameBufferSize; const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, length, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -3268,7 +3263,7 @@ TEST_P(SpdyFramerTest, ReadDuplicateSettings) { SpdyFramer framer(spdy_version_); const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, // 1st Setting @@ -3279,7 +3274,7 @@ TEST_P(SpdyFramerTest, ReadDuplicateSettings) { 0x00, 0x00, 0x00, 0x03, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, // 1st Setting @@ -3319,7 +3314,7 @@ TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { SpdyFramer framer(spdy_version_); const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, // 1st Setting @@ -3330,7 +3325,7 @@ TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { 0x00, 0x00, 0x00, 0x03, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x04, + 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, // 1st Setting @@ -3516,7 +3511,7 @@ TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) { } SpdyFramer framer(spdy_version_); const unsigned char kFrameData[] = { - 0x80, spdy_version_, 0xff, 0xff, + 0x80, spdy_version_ch_, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; TestSpdyVisitor visitor(spdy_version_); @@ -4078,7 +4073,7 @@ TEST_P(SpdyFramerTest, RstStreamStatusBounds) { DCHECK_GE(0xff, RST_STREAM_NUM_STATUS_CODES); const unsigned char kV3RstStreamInvalid[] = { - 0x80, spdy_version_, 0x00, 0x03, + 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, RST_STREAM_INVALID @@ -4090,7 +4085,7 @@ TEST_P(SpdyFramerTest, RstStreamStatusBounds) { }; const unsigned char kV3RstStreamNumStatusCodes[] = { - 0x80, spdy_version_, 0x00, 0x03, + 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES @@ -4133,12 +4128,12 @@ TEST_P(SpdyFramerTest, RstStreamStatusBounds) { // Tests handling of a GOAWAY frame with out-of-bounds stream ID. TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) { const unsigned char kV2FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0xff, 0xff, }; const unsigned char kV3FrameData[] = { - 0x80, spdy_version_, 0x00, 0x07, + 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 84e30b5..96995b8 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -386,13 +386,13 @@ int SpdyHttpStream::OnResponseReceived(const SpdyHeaderBlock& response, SSLClientSocket::NextProtoToString(protocol_negotiated); response_info_->request_time = stream_->GetRequestTime(); switch (spdy_session_->GetProtocolVersion()) { - case kSpdyVersion2: + case SPDY2: response_info_->connection_info = HttpResponseInfo::CONNECTION_INFO_SPDY2; break; - case kSpdyVersion3: + case SPDY3: response_info_->connection_info = HttpResponseInfo::CONNECTION_INFO_SPDY3; break; - case kSpdyVersion4: + case SPDY4: response_info_->connection_info = HttpResponseInfo::CONNECTION_INFO_SPDY4; break; default: diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc index 76924fa..9d42941 100644 --- a/net/spdy/spdy_http_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc @@ -159,7 +159,7 @@ class SpdyHttpStreamSpdy3Test : public testing::Test { // // TODO(akalin): Find a less clunky way to do this once we unfork // the SPDY tests. - void RunSendChunkedPostTest(int spdy_version); + void RunSendChunkedPostTest(SpdyMajorVersion spdy_version); private: MockECSignatureCreatorFactory ec_signature_creator_factory_; @@ -317,7 +317,8 @@ TEST_F(SpdyHttpStreamSpdy3Test, LoadTimingTwoRequests) { TestLoadTimingReused(*http_stream2); } -void SpdyHttpStreamSpdy3Test::RunSendChunkedPostTest(int spdy_version) { +void SpdyHttpStreamSpdy3Test::RunSendChunkedPostTest( + SpdyMajorVersion spdy_version) { BufferedSpdyFramer framer(spdy_version, false); scoped_ptr initial_window_update( @@ -330,7 +331,7 @@ void SpdyHttpStreamSpdy3Test::RunSendChunkedPostTest(int spdy_version) { framer.CreateDataFrame(1, kUploadData, kUploadDataSize, DATA_FLAG_FIN)); std::vector writes; int seq = 0; - if (spdy_version == kSpdyVersion4) { + if (spdy_version == SPDY4) { writes.push_back(CreateMockWrite(*initial_window_update, seq++)); } writes.push_back(CreateMockWrite(*req, seq++)); @@ -393,12 +394,12 @@ void SpdyHttpStreamSpdy3Test::RunSendChunkedPostTest(int spdy_version) { } TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) { - RunSendChunkedPostTest(kSpdyVersion3); + RunSendChunkedPostTest(SPDY3); } TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost4) { session_deps_.protocol = kProtoSPDY4a2; - RunSendChunkedPostTest(kSpdyVersion4); + RunSendChunkedPostTest(SPDY4); } // Test to ensure the SpdyStream state machine does not get confused when a diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc index 3b5a03d..89c5e31 100644 --- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc @@ -664,7 +664,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, GetAtEachPriority) { MockWrite writes[] = { CreateMockWrite(*req) }; SpdyPriority spdy_prio = 0; - EXPECT_TRUE(GetSpdyPriority(2, *req, &spdy_prio)); + EXPECT_TRUE(GetSpdyPriority(SPDY2, *req, &spdy_prio)); // this repeats the RequestPriority-->SpdyPriority mapping from // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make // sure it's being done right. @@ -1846,7 +1846,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, NullPost) { // expected to be 0. scoped_ptr req(ConstructSpdyPost(kRequestUrl, 0, NULL, 0)); // Set the FIN bit since there will be no body. - test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion2); + test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, SPDY2); MockWrite writes[] = { CreateMockWrite(*req), }; @@ -1887,7 +1887,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, EmptyPost) { scoped_ptr req( ConstructSpdyPost(kRequestUrl, kContentLength, NULL, 0)); // Set the FIN bit since there will be no body. - test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion2); + test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, SPDY2); MockWrite writes[] = { CreateMockWrite(*req), }; @@ -3578,10 +3578,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, CorruptFrameSessionError) { scoped_ptr syn_reply_wrong_length( ConstructSpdyGetSynReply(NULL, 0, 1)); size_t wrong_size = syn_reply_wrong_length->size() - 4; - BufferedSpdyFramer framer(kSpdyVersion2, false); + BufferedSpdyFramer framer(SPDY2, false); test::SetFrameLength(syn_reply_wrong_length.get(), wrong_size - framer.GetControlFrameHeaderSize(), - kSpdyVersion2); + SPDY2); struct SynReplyTests { const SpdyFrame* syn_reply; @@ -3779,7 +3779,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, NetLog) { // on the network, but issued a Read for only 5 of those bytes) that the data // flow still works correctly. TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -3872,7 +3872,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { // at the same time, ensure that we don't notify a read completion for // each data frame individually. TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -3966,7 +3966,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { // Verify the case where we buffer data but read it after it has been buffered. TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -3975,7 +3975,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { scoped_ptr syn_reply( ConstructSpdyGetSynReply(NULL, 0, 1)); // turn off FIN bit - test::SetFrameFlags(syn_reply.get(), CONTROL_FLAG_NONE, kSpdyVersion2); + test::SetFrameFlags(syn_reply.get(), CONTROL_FLAG_NONE, SPDY2); scoped_ptr data_frame( framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); scoped_ptr data_frame_fin( @@ -4058,7 +4058,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { // Verify the case where we buffer data and close the connection. TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedClosed) { - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -4148,7 +4148,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedClosed) { // Verify the case where we buffer data and cancel the transaction. TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedCancelled) { - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc index f17fe54..948f16f 100644 --- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc @@ -666,7 +666,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, GetAtEachPriority) { MockWrite writes[] = { CreateMockWrite(*req) }; SpdyPriority spdy_prio = 0; - EXPECT_TRUE(GetSpdyPriority(3, *req, &spdy_prio)); + EXPECT_TRUE(GetSpdyPriority(SPDY3, *req, &spdy_prio)); // this repeats the RequestPriority-->SpdyPriority mapping from // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make // sure it's being done right. @@ -1853,7 +1853,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, NullPost) { scoped_ptr req( ConstructSpdyPost(kRequestUrl, 1, 0, LOWEST, NULL, 0)); // Set the FIN bit since there will be no body. - test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); + test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, SPDY3); MockWrite writes[] = { CreateMockWrite(*req), }; @@ -1894,7 +1894,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, EmptyPost) { scoped_ptr req( ConstructSpdyPost(kRequestUrl, 1, kContentLength, LOWEST, NULL, 0)); // Set the FIN bit since there will be no body. - test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, kSpdyVersion3); + test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, SPDY3); MockWrite writes[] = { CreateMockWrite(*req), }; @@ -4165,10 +4165,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, CorruptFrameSessionError) { scoped_ptr syn_reply_wrong_length( ConstructSpdyGetSynReply(NULL, 0, 1)); size_t wrong_size = syn_reply_wrong_length->size() - 4; - BufferedSpdyFramer framer(kSpdyVersion3, false); + BufferedSpdyFramer framer(SPDY3, false); test::SetFrameLength(syn_reply_wrong_length.get(), wrong_size - framer.GetControlFrameHeaderSize(), - kSpdyVersion3); + SPDY3); struct SynReplyTests { const SpdyFrame* syn_reply; @@ -4366,7 +4366,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, NetLog) { // on the network, but issued a Read for only 5 of those bytes) that the data // flow still works correctly. TEST_P(SpdyNetworkTransactionSpdy3Test, BufferFull) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -4459,7 +4459,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, BufferFull) { // at the same time, ensure that we don't notify a read completion for // each data frame individually. TEST_P(SpdyNetworkTransactionSpdy3Test, Buffering) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -4553,7 +4553,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, Buffering) { // Verify the case where we buffer data but read it after it has been buffered. TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedAll) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -4562,7 +4562,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedAll) { scoped_ptr syn_reply( ConstructSpdyGetSynReply(NULL, 0, 1)); // turn off FIN bit - test::SetFrameFlags(syn_reply.get(), CONTROL_FLAG_NONE, kSpdyVersion3); + test::SetFrameFlags(syn_reply.get(), CONTROL_FLAG_NONE, SPDY3); scoped_ptr data_frame( framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); scoped_ptr data_frame_fin( @@ -4645,7 +4645,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedAll) { // Verify the case where we buffer data and close the connection. TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedClosed) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; @@ -4735,7 +4735,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedClosed) { // Verify the case where we buffer data and cancel the transaction. TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedCancelled) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); MockWrite writes[] = { CreateMockWrite(*req) }; diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h index b47a268..424a7d7 100644 --- a/net/spdy/spdy_protocol.h +++ b/net/spdy/spdy_protocol.h @@ -26,10 +26,17 @@ namespace net { -// TODO(akalin): Convert this to an enum. -const int32 kSpdyVersion2 = 2; -const int32 kSpdyVersion3 = 3; -const int32 kSpdyVersion4 = 4; +// The major versions of SPDY. Major version differences indicate +// framer-layer incompatibility, as opposed to minor version numbers +// which indicate application-layer incompatibility. It is guaranteed +// that the enum value SPDYn maps to the integer n. +enum SpdyMajorVersion { + SPDY2 = 2, + SPDY_MIN_VERSION = SPDY2, + SPDY3 = 3, + SPDY4 = 4, + SPDY_MAX_VERSION = SPDY4 +}; // A SPDY stream id is a 31 bit entity. typedef uint32 SpdyStreamId; diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index f143607..b2b02c3 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -54,19 +54,19 @@ const SpdyStreamId kFirstStreamId = 1; // Minimum seconds that unclaimed pushed streams will be kept in memory. const int kMinPushedStreamLifetimeSeconds = 300; -int NPNToSpdyVersion(NextProto next_proto) { +SpdyMajorVersion NPNToSpdyVersion(NextProto next_proto) { switch (next_proto) { case kProtoSPDY2: - return kSpdyVersion2; + return SPDY2; case kProtoSPDY3: case kProtoSPDY31: - return kSpdyVersion3; + return SPDY3; case kProtoSPDY4a2: - return kSpdyVersion4; + return SPDY4; default: NOTREACHED(); } - return kSpdyVersion2; + return SPDY2; } base::Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers, diff --git a/net/spdy/spdy_session_spdy2_unittest.cc b/net/spdy/spdy_session_spdy2_unittest.cc index d579a3f..988c104 100644 --- a/net/spdy/spdy_session_spdy2_unittest.cc +++ b/net/spdy/spdy_session_spdy2_unittest.cc @@ -323,7 +323,7 @@ TEST_F(SpdySessionSpdy2Test, DeleteExpiredPushStreams) { scoped_refptr session = GetSession(pair_); // Give the session a SPDY2 framer. - session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(2, false)); + session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(SPDY2, false)); // Create the associated stream and add to active streams. scoped_ptr request_headers(new SpdyHeaderBlock); @@ -616,7 +616,7 @@ TEST_F(SpdySessionSpdy2Test, ClearSettings) { scoped_ptr settings_frame( spdy_util_.ConstructSpdySettings(new_settings)); uint8 flags = SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS; - test::SetFrameFlags(settings_frame.get(), flags, kSpdyVersion3); + test::SetFrameFlags(settings_frame.get(), flags, SPDY3); MockRead reads[] = { CreateMockRead(*settings_frame), MockRead(SYNCHRONOUS, 0, 0) // EOF @@ -1763,7 +1763,7 @@ TEST_F(SpdySessionSpdy2Test, NeedsCredentials) { // then verifies that it has read all the available data without yielding. TEST_F(SpdySessionSpdy2Test, ReadDataWithoutYielding) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -1856,7 +1856,7 @@ TEST_F(SpdySessionSpdy2Test, ReadDataWithoutYielding) { // (i.e, socket()->Read didn't return ERR_IO_PENDING during socket reads). TEST_F(SpdySessionSpdy2Test, TestYieldingDuringReadData) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -1957,7 +1957,7 @@ TEST_F(SpdySessionSpdy2Test, TestYieldingDuringReadData) { // synchronously. TEST_F(SpdySessionSpdy2Test, TestYieldingDuringAsyncReadData) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2066,7 +2066,7 @@ TEST_F(SpdySessionSpdy2Test, TestYieldingDuringAsyncReadData) { // reference to SpdySession. TEST_F(SpdySessionSpdy2Test, GoAwayWhileInDoLoop) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2158,7 +2158,7 @@ TEST_F(SpdySessionSpdy2Test, ProtocolNegotiation) { http_session_.get(), session.get(), test_host_port_pair_); EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); - EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); + EXPECT_EQ(SPDY2, session->buffered_spdy_framer_->protocol_version()); EXPECT_EQ(0, session->session_send_window_size_); EXPECT_EQ(0, session->session_recv_window_size_); EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc index 4284ff6..fb50ec9 100644 --- a/net/spdy/spdy_session_spdy3_unittest.cc +++ b/net/spdy/spdy_session_spdy3_unittest.cc @@ -405,7 +405,7 @@ TEST_F(SpdySessionSpdy3Test, DeleteExpiredPushStreams) { scoped_refptr session = GetSession(pair_); // Give the session a SPDY3 framer. - session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(3, false)); + session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(SPDY3, false)); // Create the associated stream and add to active streams. scoped_ptr request_headers(new SpdyHeaderBlock); @@ -703,7 +703,7 @@ TEST_F(SpdySessionSpdy3Test, ClearSettings) { scoped_ptr settings_frame( spdy_util_.ConstructSpdySettings(new_settings)); uint8 flags = SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS; - test::SetFrameFlags(settings_frame.get(), flags, kSpdyVersion3); + test::SetFrameFlags(settings_frame.get(), flags, SPDY3); MockRead reads[] = { CreateMockRead(*settings_frame), MockRead(SYNCHRONOUS, 0, 0) // EOF @@ -1995,7 +1995,7 @@ TEST_F(SpdySessionSpdy3Test, UpdateStreamsSendWindowSize) { // then verifies that it has read all the available data without yielding. TEST_F(SpdySessionSpdy3Test, ReadDataWithoutYielding) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2082,7 +2082,7 @@ TEST_F(SpdySessionSpdy3Test, ReadDataWithoutYielding) { // (i.e, socket()->Read didn't return ERR_IO_PENDING during socket reads). TEST_F(SpdySessionSpdy3Test, TestYieldingDuringReadData) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2178,7 +2178,7 @@ TEST_F(SpdySessionSpdy3Test, TestYieldingDuringReadData) { // synchronously. TEST_F(SpdySessionSpdy3Test, TestYieldingDuringAsyncReadData) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2281,7 +2281,7 @@ TEST_F(SpdySessionSpdy3Test, TestYieldingDuringAsyncReadData) { // reference to SpdySession. TEST_F(SpdySessionSpdy3Test, GoAwayWhileInDoLoop) { MockConnect connect_data(SYNCHRONOUS, OK); - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); scoped_ptr req1(ConstructSpdyGet(NULL, 0, false, 1, MEDIUM)); MockWrite writes[] = { @@ -2368,7 +2368,7 @@ TEST_F(SpdySessionSpdy3Test, ProtocolNegotiation) { http_session_.get(), session.get(), test_host_port_pair_); EXPECT_EQ(SpdySession::FLOW_CONTROL_STREAM, session->flow_control_state()); - EXPECT_EQ(kSpdyVersion3, session->GetProtocolVersion()); + EXPECT_EQ(SPDY3, session->GetProtocolVersion()); EXPECT_EQ(0, session->session_send_window_size_); EXPECT_EQ(0, session->session_recv_window_size_); EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); @@ -2403,7 +2403,7 @@ TEST_F(SpdySessionSpdy3Test, ProtocolNegotiation31) { EXPECT_EQ(SpdySession::FLOW_CONTROL_STREAM_AND_SESSION, session->flow_control_state()); - EXPECT_EQ(kSpdyVersion3, session->GetProtocolVersion()); + EXPECT_EQ(SPDY3, session->GetProtocolVersion()); EXPECT_EQ(kSpdySessionInitialWindowSize, session->session_send_window_size_); EXPECT_EQ(kDefaultInitialRecvWindowSize, session->session_recv_window_size_); EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); @@ -2441,7 +2441,7 @@ TEST_F(SpdySessionSpdy3Test, ProtocolNegotiation4) { EXPECT_EQ(SpdySession::FLOW_CONTROL_STREAM_AND_SESSION, session->flow_control_state()); - EXPECT_EQ(kSpdyVersion4, session->GetProtocolVersion()); + EXPECT_EQ(SPDY4, session->GetProtocolVersion()); EXPECT_EQ(kSpdySessionInitialWindowSize, session->session_send_window_size_); EXPECT_EQ(kDefaultInitialRecvWindowSize, session->session_recv_window_size_); EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc index 25007aa..4087863 100644 --- a/net/spdy/spdy_test_util_common.cc +++ b/net/spdy/spdy_test_util_common.cc @@ -265,7 +265,7 @@ class PriorityGetter : public BufferedSpdyFramerVisitorInterface { } // namespace -bool GetSpdyPriority(int version, +bool GetSpdyPriority(SpdyMajorVersion version, const SpdyFrame& frame, SpdyPriority* priority) { BufferedSpdyFramer framer(version, false); @@ -512,13 +512,13 @@ void SpdySessionPoolPeer::EnableSendingInitialSettings(bool enabled) { pool_->enable_sending_initial_settings_ = enabled; } -NextProto NextProtoFromSpdyVersion(int spdy_version) { +NextProto NextProtoFromSpdyVersion(SpdyMajorVersion spdy_version) { switch (spdy_version) { - case kSpdyVersion2: + case SPDY2: return kProtoSPDY2; - case kSpdyVersion3: + case SPDY3: return kProtoSPDY3; - case kSpdyVersion4: + case SPDY4: return kProtoSPDY4a2; default: NOTREACHED(); @@ -526,19 +526,19 @@ NextProto NextProtoFromSpdyVersion(int spdy_version) { } } -int SpdyVersionFromNextProto(NextProto next_proto) { +SpdyMajorVersion SpdyVersionFromNextProto(NextProto next_proto) { switch (next_proto) { case kProtoSPDY2: case kProtoSPDY21: - return kSpdyVersion2; + return SPDY2; case kProtoSPDY3: case kProtoSPDY31: - return kSpdyVersion3; + return SPDY3; case kProtoSPDY4a2: - return kSpdyVersion4; + return SPDY4; default: NOTREACHED(); - return 0; + return SPDY2; } } diff --git a/net/spdy/spdy_test_util_common.h b/net/spdy/spdy_test_util_common.h index 8cbb334..1a12bf4 100644 --- a/net/spdy/spdy_test_util_common.h +++ b/net/spdy/spdy_test_util_common.h @@ -125,7 +125,7 @@ int CombineFrames(const SpdyFrame** frames, int num_frames, // Returns the SpdyPriority embedded in the given frame. Returns true // and fills in |priority| on success. -bool GetSpdyPriority(int version, +bool GetSpdyPriority(SpdyMajorVersion version, const SpdyFrame& frame, SpdyPriority* priority); @@ -269,8 +269,10 @@ class SpdySessionPoolPeer { // TODO(ttuttle): Move these somewhere more widely-accessible; surely this is // not the only place that needs such functions. -NextProto NextProtoFromSpdyVersion(int spdy_version); -int SpdyVersionFromNextProto(NextProto next_proto); +NextProto NextProtoFromSpdyVersion(SpdyMajorVersion spdy_version); +// TODO(akalin): Merge this with NPNToSpdyVersion() in +// spdy_session.cc. +SpdyMajorVersion SpdyVersionFromNextProto(NextProto next_proto); class SpdyTestUtil { public: @@ -351,13 +353,13 @@ class SpdyTestUtil { SpdyRstStreamStatus status) const; NextProto protocol() const { return protocol_; } - int spdy_version() const { return spdy_version_; } + SpdyMajorVersion spdy_version() const { return spdy_version_; } bool is_spdy2() const { return protocol_ < kProtoSPDY3; } scoped_ptr CreateFramer() const; private: const NextProto protocol_; - const int spdy_version_; + const SpdyMajorVersion spdy_version_; }; } // namespace net diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc index 962b9e9..9afc9da 100644 --- a/net/spdy/spdy_test_util_spdy2.cc +++ b/net/spdy/spdy_test_util_spdy2.cc @@ -403,7 +403,7 @@ SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], } SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { - SpdyFramer framer(2); + SpdyFramer framer(SPDY2); return framer.CreateDataFrame( stream_id, kUploadData, kUploadDataSize, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); @@ -411,7 +411,7 @@ SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, uint32 len, bool fin) { - SpdyFramer framer(2); + SpdyFramer framer(SPDY2); return framer.CreateDataFrame( stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); } diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc index d9fb9d9..2c52214 100644 --- a/net/spdy/spdy_test_util_spdy3.cc +++ b/net/spdy/spdy_test_util_spdy3.cc @@ -48,12 +48,11 @@ scoped_ptr ConstructPostHeaderBlock(base::StringPiece url, return util.ConstructPostHeaderBlock(url, content_length); } -// Construct a SPDY frame. |spdy_version| must be kSpdyVersion3 or -// kSpdyVersion4. -SpdyFrame* ConstructSpdyFrameWithVersion(int spdy_version, +// Construct a SPDY frame. |spdy_version| must be SPDY3 or SPDY4. +SpdyFrame* ConstructSpdyFrameWithVersion(SpdyMajorVersion spdy_version, const SpdyHeaderInfo& header_info, scoped_ptr headers) { - DCHECK(spdy_version == kSpdyVersion3 || spdy_version == kSpdyVersion4); + DCHECK(spdy_version == SPDY3 || spdy_version == SPDY4); SpdyTestUtil util(NextProtoFromSpdyVersion(spdy_version)); return util.ConstructSpdyFrame(header_info, headers.Pass()); } @@ -68,7 +67,7 @@ SpdyFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, // Construct a SPDY control frame. |spdy_version| must be // kSpdyVersion3 or kSpdyVersion4. SpdyFrame* ConstructSpdyControlFrameWithVersion( - int spdy_version, + SpdyMajorVersion spdy_verson, const char* const extra_headers[], int extra_header_count, bool compressed, @@ -79,7 +78,7 @@ SpdyFrame* ConstructSpdyControlFrameWithVersion( const char* const* kHeaders, int kHeadersSize, SpdyStreamId associated_stream_id) { - SpdyTestUtil util(NextProtoFromSpdyVersion(spdy_version)); + SpdyTestUtil util(NextProtoFromSpdyVersion(spdy_verson)); return util.ConstructSpdyControlFrame(extra_headers, extra_header_count, compressed, @@ -389,7 +388,7 @@ SpdyFrame* ConstructSpdyPost(const char* url, SYN_STREAM, // Kind = Syn stream_id, // Stream ID 0, // Associated stream ID - ConvertRequestPriorityToSpdyPriority(priority, kSpdyVersion3), + ConvertRequestPriorityToSpdyPriority(priority, SPDY3), // Priority 0, // Credential Slot CONTROL_FLAG_NONE, // Control Flags @@ -404,7 +403,7 @@ SpdyFrame* ConstructSpdyPost(const char* url, } SpdyFrame* ConstructChunkedSpdyPostWithVersion( - int spdy_version, + SpdyMajorVersion spdy_version, const char* const extra_headers[], int extra_header_count) { const char* post_headers[] = { @@ -429,13 +428,13 @@ SpdyFrame* ConstructChunkedSpdyPostWithVersion( SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], int extra_header_count) { - return ConstructChunkedSpdyPostWithVersion(kSpdyVersion3, + return ConstructChunkedSpdyPostWithVersion(SPDY3, extra_headers, extra_header_count); } SpdyFrame* ConstructSpdyPostSynReplyWithVersion( - int spdy_version, + SpdyMajorVersion spdy_version, const char* const extra_headers[], int extra_header_count) { static const char* const kStandardGetHeaders[] = { @@ -460,14 +459,14 @@ SpdyFrame* ConstructSpdyPostSynReplyWithVersion( SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], int extra_header_count) { - return ConstructSpdyPostSynReplyWithVersion(kSpdyVersion3, + return ConstructSpdyPostSynReplyWithVersion(SPDY3, extra_headers, extra_header_count); } // Constructs a single SPDY data frame with the default contents. SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); return framer.CreateDataFrame( stream_id, kUploadData, kUploadDataSize, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); @@ -476,7 +475,7 @@ SpdyFrame* ConstructSpdyBodyFrame(int stream_id, bool fin) { // Constructs a single SPDY data frame with the given content. SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, uint32 len, bool fin) { - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); return framer.CreateDataFrame( stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); } diff --git a/net/spdy/spdy_test_util_spdy3.h b/net/spdy/spdy_test_util_spdy3.h index 6b30541..5204f72 100644 --- a/net/spdy/spdy_test_util_spdy3.h +++ b/net/spdy/spdy_test_util_spdy3.h @@ -152,7 +152,7 @@ SpdyFrame* ConstructSpdyPost(const char* url, int extra_header_count); // Constructs a chunked transfer SPDY POST SYN frame. -// |spdy_version| must be kSpdyVersion3 or kSpdyVersion4. +// |spdy_version| must be SPDY3 or SPDY4. // |extra_headers| are the extra header-value pairs, which typically // will vary the most between calls. // Returns a SpdyFrame. @@ -160,7 +160,7 @@ SpdyFrame* ConstructSpdyPost(const char* url, // TODO(akalin): Move this to a common area once // ConstructSpdyControlFrame() is also moved. SpdyFrame* ConstructChunkedSpdyPostWithVersion( - int spdy_version, + SpdyMajorVersion spdy_version, const char* const extra_headers[], int extra_header_count); @@ -172,7 +172,7 @@ SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], int extra_header_count); // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. -// |spdy_version| must be kSpdyVersion3 or kSpdyVersion4. +// |spdy_version| must be SPDY3 or SPDY4. // |extra_headers| are the extra header-value pairs, which typically // will vary the most between calls. // Returns a SpdyFrame. @@ -180,7 +180,7 @@ SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], // TODO(akalin): Move this to a common area once // ConstructSpdyControlFrame() is also moved. SpdyFrame* ConstructSpdyPostSynReplyWithVersion( - int spdy_version, + SpdyMajorVersion spdy_version, const char* const extra_headers[], int extra_header_count); diff --git a/net/spdy/spdy_websocket_test_util_spdy2.cc b/net/spdy/spdy_websocket_test_util_spdy2.cc index 454d211..e812b5f 100644 --- a/net/spdy/spdy_websocket_test_util_spdy2.cc +++ b/net/spdy/spdy_websocket_test_util_spdy2.cc @@ -160,7 +160,7 @@ SpdyFrame* ConstructSpdyWebSocketDataFrame( bool fin) { // Construct SPDY data frame. - BufferedSpdyFramer framer(2, false); + BufferedSpdyFramer framer(SPDY2, false); return framer.CreateDataFrame( stream_id, data, diff --git a/net/spdy/spdy_websocket_test_util_spdy3.cc b/net/spdy/spdy_websocket_test_util_spdy3.cc index afdc9d8..25b407c 100644 --- a/net/spdy/spdy_websocket_test_util_spdy3.cc +++ b/net/spdy/spdy_websocket_test_util_spdy3.cc @@ -160,7 +160,7 @@ SpdyFrame* ConstructSpdyWebSocketDataFrame( bool fin) { // Construct SPDY data frame. - BufferedSpdyFramer framer(3, false); + BufferedSpdyFramer framer(SPDY3, false); return framer.CreateDataFrame( stream_id, data, -- cgit v1.1