summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjgraettinger@chromium.org <jgraettinger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 17:55:16 +0000
committerjgraettinger@chromium.org <jgraettinger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 17:55:16 +0000
commit3c4187f3d3eedc60dfe733887c80a82a421b7ddf (patch)
tree2c6dba9e6c4ff8ed48fa73efc4436618b188041e /net
parent90f69904f78bd1584d8f36a140cb2f4a728cc39d (diff)
downloadchromium_src-3c4187f3d3eedc60dfe733887c80a82a421b7ddf.zip
chromium_src-3c4187f3d3eedc60dfe733887c80a82a421b7ddf.tar.gz
chromium_src-3c4187f3d3eedc60dfe733887c80a82a421b7ddf.tar.bz2
Removed SpdyFramer::CreateDataFrame()
SpdyFramer::SerializeData() is to be used instead. This is part of SpdyFramer::Create*() method cleanup. This lands server change 58359100 by mlavan. Removed additional SpdyFramer::Create* methods. GoAway, CreatePingFrame, CreateBlocked and CreateWindowUpdate are removed. Part of cleanup of SpdyFramer::Create*() methods. This lands server change 58551094 by mlavan. Got rid of SpdyFramer::CreateSettings(). Part of SpdyFramer::Create*() method cleanup. This lands server change 58559769 by mlavan. Also modified SpdyTestUtils & BufferedSpdyFramer wrappers around construction and serialization of intermediate representations. Ideally, these conveniences would be removed in preference to direct use of IR's. Review URL: https://codereview.chromium.org/139763002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/spdy/buffered_spdy_framer.cc36
-rw-r--r--net/spdy/buffered_spdy_framer_unittest.cc11
-rw-r--r--net/spdy/spdy_frame_builder_test.cc4
-rw-r--r--net/spdy/spdy_framer.cc48
-rw-r--r--net/spdy/spdy_framer.h28
-rw-r--r--net/spdy/spdy_framer_test.cc148
-rw-r--r--net/spdy/spdy_test_util_common.cc36
7 files changed, 159 insertions, 152 deletions
diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc
index 03a098d..e5a0bd68 100644
--- a/net/spdy/buffered_spdy_framer.cc
+++ b/net/spdy/buffered_spdy_framer.cc
@@ -270,20 +270,35 @@ SpdyFrame* BufferedSpdyFramer::CreateRstStream(
return spdy_framer_.CreateRstStream(stream_id, status);
}
+// TODO(jgraettinger): Eliminate uses of this method (prefer
+// SpdySettingsIR).
SpdyFrame* BufferedSpdyFramer::CreateSettings(
const SettingsMap& values) const {
- return spdy_framer_.CreateSettings(values);
+ SpdySettingsIR settings_ir;
+ for (SettingsMap::const_iterator it = values.begin();
+ it != values.end();
+ ++it) {
+ settings_ir.AddSetting(
+ it->first,
+ (it->second.first & SETTINGS_FLAG_PLEASE_PERSIST) != 0,
+ (it->second.first & SETTINGS_FLAG_PERSISTED) != 0,
+ it->second.second);
+ }
+ return spdy_framer_.SerializeSettings(settings_ir);
}
-SpdyFrame* BufferedSpdyFramer::CreatePingFrame(
- uint32 unique_id) const {
- return spdy_framer_.CreatePingFrame(unique_id);
+// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyPingIR).
+SpdyFrame* BufferedSpdyFramer::CreatePingFrame(uint32 unique_id) const {
+ SpdyPingIR ping_ir(unique_id);
+ return spdy_framer_.SerializePing(ping_ir);
}
+// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyGoAwayIR).
SpdyFrame* BufferedSpdyFramer::CreateGoAway(
SpdyStreamId last_accepted_stream_id,
SpdyGoAwayStatus status) const {
- return spdy_framer_.CreateGoAway(last_accepted_stream_id, status, "go away");
+ SpdyGoAwayIR go_ir(last_accepted_stream_id, status, "");
+ return spdy_framer_.SerializeGoAway(go_ir);
}
SpdyFrame* BufferedSpdyFramer::CreateHeaders(
@@ -293,17 +308,24 @@ SpdyFrame* BufferedSpdyFramer::CreateHeaders(
return spdy_framer_.CreateHeaders(stream_id, flags, headers);
}
+// TODO(jgraettinger): Eliminate uses of this method (prefer
+// SpdyWindowUpdateIR).
SpdyFrame* BufferedSpdyFramer::CreateWindowUpdate(
SpdyStreamId stream_id,
uint32 delta_window_size) const {
- return spdy_framer_.CreateWindowUpdate(stream_id, delta_window_size);
+ SpdyWindowUpdateIR update_ir(stream_id, delta_window_size);
+ return spdy_framer_.SerializeWindowUpdate(update_ir);
}
+// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyDataIR).
SpdyFrame* BufferedSpdyFramer::CreateDataFrame(SpdyStreamId stream_id,
const char* data,
uint32 len,
SpdyDataFlags flags) {
- return spdy_framer_.CreateDataFrame(stream_id, data, len, flags);
+ SpdyDataIR data_ir(stream_id,
+ base::StringPiece(data, len));
+ data_ir.set_fin((flags & DATA_FLAG_FIN) != 0);
+ return spdy_framer_.SerializeData(data_ir);
}
SpdyPriority BufferedSpdyFramer::GetHighestPriority() const {
diff --git a/net/spdy/buffered_spdy_framer_unittest.cc b/net/spdy/buffered_spdy_framer_unittest.cc
index 8441090..229294e 100644
--- a/net/spdy/buffered_spdy_framer_unittest.cc
+++ b/net/spdy/buffered_spdy_framer_unittest.cc
@@ -199,13 +199,10 @@ INSTANTIATE_TEST_CASE_P(
TEST_P(BufferedSpdyFramerTest, OnSetting) {
SpdyFramer framer(spdy_version());
- SettingsMap settings;
- settings[SETTINGS_UPLOAD_BANDWIDTH] =
- SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002);
- settings[SETTINGS_DOWNLOAD_BANDWIDTH] =
- SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000003);
-
- scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ settings_ir.AddSetting(SETTINGS_UPLOAD_BANDWIDTH, false, false, 0x00000002);
+ settings_ir.AddSetting(SETTINGS_DOWNLOAD_BANDWIDTH, false, false, 0x00000003);
+ scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir));
TestBufferedSpdyVisitor visitor(spdy_version());
visitor.SimulateInFramer(
diff --git a/net/spdy/spdy_frame_builder_test.cc b/net/spdy/spdy_frame_builder_test.cc
index 014449b..ef3de07 100644
--- a/net/spdy/spdy_frame_builder_test.cc
+++ b/net/spdy/spdy_frame_builder_test.cc
@@ -43,8 +43,8 @@ TEST_P(SpdyFrameBuilderTest, RewriteLength) {
// The one created via builder is initially given the incorrect length, but
// then is corrected via RewriteLength().
SpdyFramer framer(spdy_version_);
- SettingsMap settings;
- scoped_ptr<SpdyFrame> expected(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ scoped_ptr<SpdyFrame> expected(framer.SerializeSettings(settings_ir));
SpdyFrameBuilder builder(expected->size() + 1);
if (spdy_version_ < 4) {
builder.WriteControlFrameHeader(framer, SETTINGS, 0);
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 0652418..9fca406 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -1705,16 +1705,6 @@ bool SpdyFramer::ParseCredentialData(const char* data, size_t len,
return true;
}
-SpdyFrame* SpdyFramer::CreateDataFrame(SpdyStreamId stream_id,
- const char* data,
- uint32 len, SpdyDataFlags flags) const {
- DCHECK_EQ(0, flags & (!DATA_FLAG_FIN));
-
- SpdyDataIR data_ir(stream_id, base::StringPiece(data, len));
- data_ir.set_fin(flags & DATA_FLAG_FIN);
- return SerializeData(data_ir);
-}
-
SpdySerializedFrame* SpdyFramer::SerializeData(const SpdyDataIR& data) const {
const size_t kSize = GetDataFrameMinimumSize() + data.data().length();
@@ -1903,20 +1893,6 @@ SpdySerializedFrame* SpdyFramer::SerializeRstStream(
return builder.take();
}
-SpdyFrame* SpdyFramer::CreateSettings(
- const SettingsMap& values) const {
- SpdySettingsIR settings;
- for (SettingsMap::const_iterator it = values.begin();
- it != values.end();
- ++it) {
- settings.AddSetting(it->first,
- (it->second.first & SETTINGS_FLAG_PLEASE_PERSIST) != 0,
- (it->second.first & SETTINGS_FLAG_PERSISTED) != 0,
- it->second.second);
- }
- return SerializeSettings(settings);
-}
-
SpdySerializedFrame* SpdyFramer::SerializeSettings(
const SpdySettingsIR& settings) const {
uint8 flags = 0;
@@ -1955,11 +1931,6 @@ SpdySerializedFrame* SpdyFramer::SerializeSettings(
return builder.take();
}
-SpdyFrame* SpdyFramer::CreateBlocked(SpdyStreamId stream_id) {
- SpdyBlockedIR blocked_ir(stream_id);
- return SerializeBlocked(blocked_ir);
-}
-
SpdyFrame* SpdyFramer::SerializeBlocked(const SpdyBlockedIR& blocked) const {
DCHECK_LE(4, protocol_version());
SpdyFrameBuilder builder(GetBlockedSize());
@@ -1967,11 +1938,6 @@ SpdyFrame* SpdyFramer::SerializeBlocked(const SpdyBlockedIR& blocked) const {
return builder.take();
}
-SpdyFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const {
- SpdyPingIR ping(unique_id);
- return SerializePing(ping);
-}
-
SpdySerializedFrame* SpdyFramer::SerializePing(const SpdyPingIR& ping) const {
SpdyFrameBuilder builder(GetPingSize());
if (spdy_version_ < 4) {
@@ -1984,13 +1950,6 @@ SpdySerializedFrame* SpdyFramer::SerializePing(const SpdyPingIR& ping) const {
return builder.take();
}
-SpdyFrame* SpdyFramer::CreateGoAway(
- SpdyStreamId last_accepted_stream_id, SpdyGoAwayStatus status,
- const base::StringPiece& description) const {
- SpdyGoAwayIR goaway(last_accepted_stream_id, status, description);
- return SerializeGoAway(goaway);
-}
-
SpdySerializedFrame* SpdyFramer::SerializeGoAway(
const SpdyGoAwayIR& goaway) const {
@@ -2081,13 +2040,6 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders(
return builder.take();
}
-SpdyFrame* SpdyFramer::CreateWindowUpdate(
- SpdyStreamId stream_id,
- uint32 delta_window_size) const {
- SpdyWindowUpdateIR window_update(stream_id, delta_window_size);
- return SerializeWindowUpdate(window_update);
-}
-
SpdySerializedFrame* SpdyFramer::SerializeWindowUpdate(
const SpdyWindowUpdateIR& window_update) const {
SpdyFrameBuilder builder(GetWindowUpdateSize());
diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h
index 2fc2247..839941d 100644
--- a/net/spdy/spdy_framer.h
+++ b/net/spdy/spdy_framer.h
@@ -364,14 +364,7 @@ class NET_EXPORT_PRIVATE SpdyFramer {
size_t header_length,
SpdyHeaderBlock* block) const;
- // Create a data frame.
- // |stream_id| is the stream for this frame
- // |data| is the data to be included in the frame.
- // |len| is the length of the data
- // |flags| is the flags to use with the data.
- // To mark this frame as the last data frame, enable DATA_FLAG_FIN.
- SpdyFrame* CreateDataFrame(SpdyStreamId stream_id, const char* data,
- uint32 len, SpdyDataFlags flags) const;
+ // Serialize a data frame.
SpdySerializedFrame* SerializeData(const SpdyDataIR& data) const;
// Serializes just the data frame header, excluding actual data payload.
SpdySerializedFrame* SerializeDataFrameHeader(const SpdyDataIR& data) const;
@@ -410,23 +403,18 @@ class NET_EXPORT_PRIVATE SpdyFramer {
SpdySerializedFrame* SerializeRstStream(
const SpdyRstStreamIR& rst_stream) const;
- // Creates and serializes a SETTINGS frame. The SETTINGS frame is
+ // Serializes a SETTINGS frame. The SETTINGS frame is
// used to communicate name/value pairs relevant to the communication channel.
- SpdyFrame* CreateSettings(const SettingsMap& values) const;
SpdySerializedFrame* SerializeSettings(const SpdySettingsIR& settings) const;
- // Creates and serializes a PING frame. The unique_id is used to
+ // Serializes a PING frame. The unique_id is used to
// identify the ping request/response.
- SpdyFrame* CreatePingFrame(uint32 unique_id) const;
SpdySerializedFrame* SerializePing(const SpdyPingIR& ping) const;
- // Creates and serializes a GOAWAY frame. The GOAWAY frame is used
+ // Serializes a GOAWAY frame. The GOAWAY frame is used
// prior to the shutting down of the TCP connection, and includes the
// stream_id of the last stream the sender of the frame is willing to process
// to completion.
- SpdyFrame* CreateGoAway(SpdyStreamId last_accepted_stream_id,
- SpdyGoAwayStatus status,
- const base::StringPiece& description) const;
SpdySerializedFrame* SerializeGoAway(const SpdyGoAwayIR& goaway) const;
// Creates and serializes a HEADERS frame. The HEADERS frame is used
@@ -437,11 +425,8 @@ class NET_EXPORT_PRIVATE SpdyFramer {
const SpdyHeaderBlock* headers);
SpdySerializedFrame* SerializeHeaders(const SpdyHeadersIR& headers);
- // Creates and serializes a WINDOW_UPDATE frame. The WINDOW_UPDATE
+ // Serializes a WINDOW_UPDATE frame. The WINDOW_UPDATE
// frame is used to implement per stream flow control in SPDY.
- SpdyFrame* CreateWindowUpdate(
- SpdyStreamId stream_id,
- uint32 delta_window_size) const;
SpdySerializedFrame* SerializeWindowUpdate(
const SpdyWindowUpdateIR& window_update) const;
@@ -452,11 +437,10 @@ class NET_EXPORT_PRIVATE SpdyFramer {
SpdySerializedFrame* SerializeCredential(
const SpdyCredentialIR& credential) const;
- // Creates and serializes a BLOCKED frame. The BLOCKED frame is used to
+ // Serializes a BLOCKED frame. The BLOCKED frame is used to
// indicate to the remote endpoint that this endpoint believes itself to be
// flow-control blocked but otherwise ready to send data. The BLOCKED frame
// is purely advisory and optional.
- SpdyFrame* CreateBlocked(SpdyStreamId stream_id);
SpdySerializedFrame* SerializeBlocked(const SpdyBlockedIR& blocked) const;
// Creates and serializes a PUSH_PROMISE frame. The PUSH_PROMISE frame is used
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc
index a9ed1c8..6e37989 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -15,6 +15,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
+using base::StringPiece;
using std::string;
using std::max;
using std::min;
@@ -1628,11 +1629,10 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressors) {
&block));
EXPECT_TRUE(syn_frame.get() != NULL);
- const char bytes[] = "this is a test test test test test!";
- scoped_ptr<SpdyFrame> send_frame(
- send_framer.CreateDataFrame(
- 1, bytes, arraysize(bytes),
- static_cast<SpdyDataFlags>(DATA_FLAG_FIN)));
+ StringPiece bytes = "this is a test test test test test!";
+ net::SpdyDataIR data_ir(1, bytes);
+ data_ir.set_fin(true);
+ scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir));
EXPECT_TRUE(send_frame.get() != NULL);
// Run the inputs through the framer.
@@ -1648,7 +1648,7 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressors) {
EXPECT_EQ(1, visitor.syn_frame_count_);
EXPECT_EQ(0, visitor.syn_reply_frame_count_);
EXPECT_EQ(0, visitor.headers_frame_count_);
- EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_));
+ EXPECT_EQ(bytes.size(), static_cast<unsigned>(visitor.data_bytes_));
EXPECT_EQ(0, visitor.fin_frame_count_);
EXPECT_EQ(0, visitor.fin_flag_count_);
EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
@@ -1681,10 +1681,9 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
EXPECT_TRUE(syn_frame.get() != NULL);
const char bytes[] = "this is a test test test test test!";
- scoped_ptr<SpdyFrame> send_frame(
- send_framer.CreateDataFrame(
- 1, bytes, arraysize(bytes),
- static_cast<SpdyDataFlags>(DATA_FLAG_FIN)));
+ net::SpdyDataIR data_ir(1, StringPiece(bytes, arraysize(bytes)));
+ data_ir.set_fin(true);
+ scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir));
EXPECT_TRUE(send_frame.get() != NULL);
// Run the inputs through the framer.
@@ -1715,7 +1714,8 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
TEST_P(SpdyFramerTest, WindowUpdateFrame) {
SpdyFramer framer(spdy_version_);
- scoped_ptr<SpdyFrame> frame(framer.CreateWindowUpdate(1, 0x12345678));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
+ net::SpdyWindowUpdateIR(1, 0x12345678)));
const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678";
const unsigned char kV3FrameData[] = { // Also applies for V2.
@@ -1756,8 +1756,8 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
};
const char bytes[] = "hello";
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 1, bytes, strlen(bytes), DATA_FLAG_NONE));
+ SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes)));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
@@ -1766,9 +1766,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
}
- SpdyDataIR data_ir(1);
- data_ir.SetDataShallow(base::StringPiece(bytes, strlen(bytes)));
- frame.reset(framer.SerializeDataFrameHeader(data_ir));
+ SpdyDataIR data_header_ir(1);
+ data_header_ir.SetDataShallow(base::StringPiece(bytes, strlen(bytes)));
+ frame.reset(framer.SerializeDataFrameHeader(data_header_ir));
CompareCharArraysWithHexError(
kDescription,
reinterpret_cast<const unsigned char*>(frame->data()),
@@ -1789,8 +1789,8 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
0x00, 0x00, 0x00, 0x01,
0xff
};
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 1, "\xff", 1, DATA_FLAG_NONE));
+ net::SpdyDataIR data_ir(1, StringPiece("\xff", 1));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
@@ -1814,8 +1814,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
'h', 'e', 'l', 'l',
'o'
};
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 1, "hello", 5, DATA_FLAG_FIN));
+ net::SpdyDataIR data_ir(1, StringPiece("hello", 5));
+ data_ir.set_fin(true);
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
@@ -1835,8 +1836,8 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
0x00, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 1, "", 0, DATA_FLAG_NONE));
+ net::SpdyDataIR data_ir(1, StringPiece());
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
@@ -1860,8 +1861,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
'h', 'e', 'l', 'l',
'o'
};
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 0x7fffffff, "hello", 5, DATA_FLAG_FIN));
+ net::SpdyDataIR data_ir(0x7fffffff, "hello");
+ data_ir.set_fin(true);
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
@@ -1888,8 +1890,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
memcpy(expected_frame_data.get(), kFrameHeader, arraysize(kFrameHeader));
memset(expected_frame_data.get() + arraysize(kFrameHeader), 'A', kDataSize);
- scoped_ptr<SpdyFrame> frame(framer.CreateDataFrame(
- 1, kData.data(), kData.size(), DATA_FLAG_FIN));
+ net::SpdyDataIR data_ir(1, StringPiece(kData.data(), kData.size()));
+ data_ir.set_fin(true);
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
CompareFrame(kDescription, *frame, expected_frame_data.get(), kFrameSize);
}
}
@@ -2534,7 +2537,12 @@ TEST_P(SpdyFramerTest, CreateSettings) {
0x0a, 0x0b, 0x0c, 0x0d,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ settings_ir.AddSetting(kId,
+ kFlags & SETTINGS_FLAG_PLEASE_PERSIST,
+ kFlags & SETTINGS_FLAG_PERSISTED,
+ kValue);
+ scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
if (IsSpdy2()) {
CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
} else if (IsSpdy3()) {
@@ -2583,7 +2591,16 @@ TEST_P(SpdyFramerTest, CreateSettings) {
0x03, 0x00, 0x00, 0x03, // 4th Setting
0xff, 0x00, 0x00, 0x04,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ for (SettingsMap::const_iterator it = settings.begin();
+ it != settings.end();
+ ++it) {
+ settings_ir.AddSetting(it->first,
+ it->second.first & SETTINGS_FLAG_PLEASE_PERSIST,
+ it->second.first & SETTINGS_FLAG_PERSISTED,
+ it->second.second);
+ }
+ scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -2594,8 +2611,6 @@ TEST_P(SpdyFramerTest, CreateSettings) {
{
const char kDescription[] = "Empty SETTINGS frame";
- SettingsMap settings;
-
const unsigned char kV3FrameData[] = { // Also applies for V2.
0x80, spdy_version_ch_, 0x00, 0x04,
0x00, 0x00, 0x00, 0x04,
@@ -2606,7 +2621,8 @@ TEST_P(SpdyFramerTest, CreateSettings) {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -2630,7 +2646,7 @@ TEST_P(SpdyFramerTest, CreatePingFrame) {
0x00, 0x00, 0x00, 0x00,
0x12, 0x34, 0x56, 0x78,
};
- scoped_ptr<SpdyFrame> frame(framer.CreatePingFrame(0x12345678u));
+ scoped_ptr<SpdyFrame> frame(framer.SerializePing(SpdyPingIR(0x12345678u)));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -2662,7 +2678,8 @@ TEST_P(SpdyFramerTest, CreateGoAway) {
0x00, 0x00, 0x00, 0x00, // Status
0x47, 0x41, // Opaque Description
};
- scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0, GOAWAY_OK, "GA"));
+ SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir));
if (IsSpdy2()) {
CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
} else if (IsSpdy3()) {
@@ -2692,9 +2709,8 @@ TEST_P(SpdyFramerTest, CreateGoAway) {
0x00, 0x00, 0x00, 0x02, // Status
0x47, 0x41, // Opaque Description
};
- scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(0x7FFFFFFF,
- GOAWAY_INTERNAL_ERROR,
- "GA"));
+ SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir));
if (IsSpdy2()) {
CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
} else if (IsSpdy3()) {
@@ -2968,7 +2984,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) {
0x00, 0x00, 0x00, 0x01,
};
scoped_ptr<SpdyFrame> frame(
- framer.CreateWindowUpdate(1, 1));
+ framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1)));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -2989,7 +3005,8 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) {
0x7f, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x01,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateWindowUpdate(0x7FFFFFFF, 1));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
+ net::SpdyWindowUpdateIR(0x7FFFFFFF, 1)));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -3010,7 +3027,8 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) {
0x00, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xff,
};
- scoped_ptr<SpdyFrame> frame(framer.CreateWindowUpdate(1, 0x7FFFFFFF));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
+ net::SpdyWindowUpdateIR(1, 0x7FFFFFFF)));
if (IsSpdy4()) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
} else {
@@ -3047,7 +3065,7 @@ TEST_P(SpdyFramerTest, CreateBlocked) {
const SpdyStreamId kStreamId = 3;
scoped_ptr<SpdySerializedFrame> frame_serialized(
- framer.CreateBlocked(kStreamId));
+ framer.SerializeBlocked(SpdyBlockedIR(kStreamId)));
SpdyBlockedIR blocked_ir(kStreamId);
scoped_ptr<SpdySerializedFrame> frame_created(
framer.SerializeFrame(blocked_ir));
@@ -3427,8 +3445,8 @@ TEST_P(SpdyFramerTest, ControlFrameSizesAreValidated) {
TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) {
SpdyFramer framer(spdy_version_);
- SettingsMap settings;
- scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir));
SetFrameLength(control_frame.get(), 0, spdy_version_);
TestSpdyVisitor visitor(spdy_version_);
visitor.use_compression_ = false;
@@ -3447,7 +3465,12 @@ TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) {
// calling SimulateInFramer() below.
settings[SETTINGS_UPLOAD_BANDWIDTH] =
SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, 0x00000002);
- scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ settings_ir.AddSetting(SETTINGS_UPLOAD_BANDWIDTH,
+ true, // please persist
+ false,
+ 0x00000002);
+ scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir));
const size_t kNewLength = 5;
SetFrameLength(control_frame.get(), kNewLength, spdy_version_);
TestSpdyVisitor visitor(spdy_version_);
@@ -3469,7 +3492,16 @@ TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) {
settings[SETTINGS_DOWNLOAD_BANDWIDTH] =
SettingsFlagsAndValue(flags, 0x00000003);
settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000004);
- scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ for (SettingsMap::const_iterator it = settings.begin();
+ it != settings.end();
+ ++it) {
+ settings_ir.AddSetting(it->first,
+ it->second.first & SETTINGS_FLAG_PLEASE_PERSIST,
+ it->second.first & SETTINGS_FLAG_PERSISTED,
+ it->second.second);
+ }
+ scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir));
EXPECT_LT(SpdyFramer::kControlFrameBufferSize,
control_frame->size());
TestSpdyVisitor visitor(spdy_version_);
@@ -3603,7 +3635,7 @@ TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) {
TEST_P(SpdyFramerTest, ReadWindowUpdate) {
SpdyFramer framer(spdy_version_);
scoped_ptr<SpdyFrame> control_frame(
- framer.CreateWindowUpdate(1, 2));
+ framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 2)));
TestSpdyVisitor visitor(spdy_version_);
visitor.SimulateInFramer(
reinterpret_cast<unsigned char*>(control_frame->data()),
@@ -3780,8 +3812,8 @@ TEST_P(SpdyFramerTest, ReadCredentialFrameFollowedByAnotherFrame) {
visitor.use_compression_ = false;
string multiple_frame_data(credential_frame->data(),
credential_frame->size());
- scoped_ptr<SpdyFrame> goaway_frame(
- framer.CreateGoAway(0, GOAWAY_OK, "test"));
+ SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "test");
+ scoped_ptr<SpdyFrame> goaway_frame(framer.SerializeGoAway(goaway_ir));
multiple_frame_data.append(string(goaway_frame->data(),
goaway_frame->size()));
visitor.SimulateInFramer(
@@ -4033,8 +4065,8 @@ TEST_P(SpdyFramerTest, DataFrameFlags) {
SpdyFramer framer(spdy_version_);
framer.set_visitor(&visitor);
- scoped_ptr<SpdyFrame> frame(
- framer.CreateDataFrame(1, "hello", 5, DATA_FLAG_NONE));
+ net::SpdyDataIR data_ir(1, StringPiece("hello", 5));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
SetFrameFlags(frame.get(), flags, spdy_version_);
if (flags & ~DATA_FLAG_FIN) {
@@ -4209,10 +4241,12 @@ TEST_P(SpdyFramerTest, SettingsFrameFlags) {
SpdyFramer framer(spdy_version_);
framer.set_visitor(&visitor);
- SettingsMap settings;
- settings[SETTINGS_UPLOAD_BANDWIDTH] =
- std::make_pair(SETTINGS_FLAG_NONE, 54321);
- scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings));
+ SpdySettingsIR settings_ir;
+ settings_ir.AddSetting(SETTINGS_UPLOAD_BANDWIDTH,
+ false,
+ false,
+ 54321);
+ scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
SetFrameFlags(frame.get(), flags, spdy_version_);
if (flags & ~SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS) {
@@ -4246,7 +4280,8 @@ TEST_P(SpdyFramerTest, GoawayFrameFlags) {
SpdyFramer framer(spdy_version_);
framer.set_visitor(&visitor);
- scoped_ptr<SpdyFrame> frame(framer.CreateGoAway(97, GOAWAY_OK, "test"));
+ SpdyGoAwayIR goaway_ir(97, GOAWAY_OK, "test");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir));
SetFrameFlags(frame.get(), flags, spdy_version_);
if (flags != 0) {
@@ -4320,7 +4355,7 @@ TEST_P(SpdyFramerTest, PingFrameFlags) {
SpdyFramer framer(spdy_version_);
framer.set_visitor(&visitor);
- scoped_ptr<SpdyFrame> frame(framer.CreatePingFrame(42));
+ scoped_ptr<SpdyFrame> frame(framer.SerializePing(SpdyPingIR(42)));
SetFrameFlags(frame.get(), flags, spdy_version_);
if (flags != 0) {
@@ -4351,7 +4386,8 @@ TEST_P(SpdyFramerTest, WindowUpdateFrameFlags) {
SpdyFramer framer(spdy_version_);
framer.set_visitor(&visitor);
- scoped_ptr<SpdyFrame> frame(framer.CreateWindowUpdate(4, 1024));
+ scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
+ net::SpdyWindowUpdateIR(4, 1024)));
SetFrameFlags(frame.get(), flags, spdy_version_);
if (flags != 0) {
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc
index bc6d5ac..06be34b 100644
--- a/net/spdy/spdy_test_util_common.cc
+++ b/net/spdy/spdy_test_util_common.cc
@@ -854,9 +854,21 @@ std::string SpdyTestUtil::ConstructSpdyReplyString(
return reply_string;
}
+// TODO(jgraettinger): Eliminate uses of this method in tests (prefer
+// SpdySettingsIR).
SpdyFrame* SpdyTestUtil::ConstructSpdySettings(
const SettingsMap& settings) const {
- return CreateFramer()->CreateSettings(settings);
+ SpdySettingsIR settings_ir;
+ for (SettingsMap::const_iterator it = settings.begin();
+ it != settings.end();
+ ++it) {
+ settings_ir.AddSetting(
+ it->first,
+ (it->second.first & SETTINGS_FLAG_PLEASE_PERSIST) != 0,
+ (it->second.first & SETTINGS_FLAG_PERSISTED) != 0,
+ it->second.second);
+ }
+ return CreateFramer()->SerializeSettings(settings_ir);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyCredential(
@@ -865,7 +877,8 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyCredential(
}
SpdyFrame* SpdyTestUtil::ConstructSpdyPing(uint32 ping_id) const {
- return CreateFramer()->CreatePingFrame(ping_id);
+ SpdyPingIR ping_ir(ping_id);
+ return CreateFramer()->SerializePing(ping_ir);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyGoAway() const {
@@ -874,13 +887,14 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyGoAway() const {
SpdyFrame* SpdyTestUtil::ConstructSpdyGoAway(
SpdyStreamId last_good_stream_id) const {
- return CreateFramer()->CreateGoAway(last_good_stream_id, GOAWAY_OK,
- "go away");
+ SpdyGoAwayIR go_ir(last_good_stream_id, GOAWAY_OK, "go away");
+ return CreateFramer()->SerializeGoAway(go_ir);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyWindowUpdate(
const SpdyStreamId stream_id, uint32 delta_window_size) const {
- return CreateFramer()->CreateWindowUpdate(stream_id, delta_window_size);
+ SpdyWindowUpdateIR update_ir(stream_id, delta_window_size);
+ return CreateFramer()->SerializeWindowUpdate(update_ir);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyRstStream(
@@ -1146,9 +1160,10 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply(
SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) {
SpdyFramer framer(spdy_version_);
- return framer.CreateDataFrame(
- stream_id, kUploadData, kUploadDataSize,
- fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
+ SpdyDataIR data_ir(stream_id,
+ base::StringPiece(kUploadData, kUploadDataSize));
+ data_ir.set_fin(fin);
+ return framer.SerializeData(data_ir);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id,
@@ -1156,8 +1171,9 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id,
uint32 len,
bool fin) {
SpdyFramer framer(spdy_version_);
- return framer.CreateDataFrame(
- stream_id, data, len, fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
+ SpdyDataIR data_ir(stream_id, base::StringPiece(data, len));
+ data_ir.set_fin(fin);
+ return framer.SerializeData(data_ir);
}
SpdyFrame* SpdyTestUtil::ConstructWrappedSpdyFrame(