summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 23:42:18 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 23:42:18 +0000
commiteb566e515885a255f1b69962e9590e5cff0e6e4f (patch)
tree7aac9a23bacb8a43cb1cb7135e08eebc4af847ec
parent99777cb474959a77eab84e9b24feda3f613c3b18 (diff)
downloadchromium_src-eb566e515885a255f1b69962e9590e5cff0e6e4f.zip
chromium_src-eb566e515885a255f1b69962e9590e5cff0e6e4f.tar.gz
chromium_src-eb566e515885a255f1b69962e9590e5cff0e6e4f.tar.bz2
Overhaul of how SPDY frame headers are written, useful for SPDY 4 development.
Also gets rid of SpdyFrame::kHeaderSize. This lands server change 42903918. Review URL: https://codereview.chromium.org/12313087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184773 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/spdy/spdy_frame_builder.cc59
-rw-r--r--net/spdy/spdy_frame_builder.h30
-rw-r--r--net/spdy/spdy_frame_builder_test.cc3
-rw-r--r--net/spdy/spdy_framer.cc39
-rw-r--r--net/spdy/spdy_framer_test.cc22
-rw-r--r--net/spdy/spdy_network_transaction_spdy2_unittest.cc3
-rw-r--r--net/spdy/spdy_network_transaction_spdy3_unittest.cc3
-rw-r--r--net/spdy/spdy_protocol.h6
-rw-r--r--net/spdy/spdy_protocol_test.cc1
-rw-r--r--net/spdy/spdy_session.cc6
-rw-r--r--net/spdy/spdy_session.h3
-rw-r--r--net/spdy/spdy_session_spdy2_unittest.cc9
-rw-r--r--net/spdy/spdy_session_spdy3_unittest.cc9
-rw-r--r--net/tools/flip_server/constants.h2
-rw-r--r--net/tools/flip_server/spdy_interface.cc4
15 files changed, 99 insertions, 100 deletions
diff --git a/net/spdy/spdy_frame_builder.cc b/net/spdy/spdy_frame_builder.cc
index 361dede..3c1a91a 100644
--- a/net/spdy/spdy_frame_builder.cc
+++ b/net/spdy/spdy_frame_builder.cc
@@ -32,37 +32,6 @@ SpdyFrameBuilder::SpdyFrameBuilder(size_t size)
length_(0) {
}
-SpdyFrameBuilder::SpdyFrameBuilder(SpdyControlType type,
- uint8 flags,
- int spdy_version,
- size_t size)
- : buffer_(new char[size]),
- capacity_(size),
- length_(0) {
- FlagsAndLength flags_length = CreateFlagsAndLength(
- flags, size - SpdyFrame::kHeaderSize);
- WriteUInt16(kControlFlagMask | spdy_version);
- WriteUInt16(type);
- WriteBytes(&flags_length, sizeof(flags_length));
-}
-
-SpdyFrameBuilder::SpdyFrameBuilder(SpdyStreamId stream_id,
- SpdyDataFlags flags,
- size_t size)
- : buffer_(new char[size]),
- capacity_(size),
- length_(0) {
- DCHECK_EQ(0u, stream_id & ~kStreamIdMask);
- WriteUInt32(stream_id);
- size_t length = size - SpdyFrame::kHeaderSize;
- DCHECK_EQ(0u, length & ~static_cast<size_t>(kLengthMask));
- FlagsAndLength flags_length;
- flags_length.length_ = htonl(length);
- DCHECK_EQ(0, flags & ~kDataFlagsMask);
- flags_length.flags_[0] = flags;
- WriteBytes(&flags_length, sizeof(flags_length));
-}
-
SpdyFrameBuilder::~SpdyFrameBuilder() {
}
@@ -82,6 +51,34 @@ bool SpdyFrameBuilder::Seek(size_t length) {
return true;
}
+bool SpdyFrameBuilder::WriteControlFrameHeader(const SpdyFramer& framer,
+ SpdyControlType type,
+ uint8 flags) {
+ FlagsAndLength flags_length = CreateFlagsAndLength(
+ flags, capacity_ - framer.GetControlFrameMinimumSize());
+ bool success = WriteUInt16(kControlFlagMask | framer.protocol_version());
+ success &= WriteUInt16(type);
+ success &= WriteBytes(&flags_length, sizeof(flags_length));
+ DCHECK_EQ(framer.GetControlFrameMinimumSize(), length());
+ return success;
+}
+
+bool SpdyFrameBuilder::WriteDataFrameHeader(const SpdyFramer& framer,
+ SpdyStreamId stream_id,
+ SpdyDataFlags flags) {
+ DCHECK_EQ(0u, stream_id & ~kStreamIdMask);
+ bool success = WriteUInt32(stream_id);
+ size_t length_field = capacity_ - framer.GetDataFrameMinimumSize();
+ DCHECK_EQ(0u, length_field & ~static_cast<size_t>(kLengthMask));
+ FlagsAndLength flags_length;
+ flags_length.length_ = htonl(length_field);
+ DCHECK_EQ(0, flags & ~kDataFlagsMask);
+ flags_length.flags_[0] = flags;
+ success &= WriteBytes(&flags_length, sizeof(flags_length));
+ DCHECK_EQ(framer.GetDataFrameMinimumSize(), length());
+ return success;
+}
+
bool SpdyFrameBuilder::WriteString(const std::string& value) {
if (value.size() > 0xffff) {
DCHECK(false) << "Tried to write string with length > 16bit.";
diff --git a/net/spdy/spdy_frame_builder.h b/net/spdy/spdy_frame_builder.h
index b45acae..1764beb 100644
--- a/net/spdy/spdy_frame_builder.h
+++ b/net/spdy/spdy_frame_builder.h
@@ -30,19 +30,6 @@ class NET_EXPORT_PRIVATE SpdyFrameBuilder {
// Initializes a SpdyFrameBuilder with a buffer of given size
explicit SpdyFrameBuilder(size_t size);
- // Initializes a SpdyFrameBuilder with a buffer of given size,
- // populate with a SPDY control frame header based on
- // |type|, |flags|, and |spdy_version|.
- //
- // TODO(akalin): Add a typedef for this uint8.
- SpdyFrameBuilder(SpdyControlType type, uint8 flags,
- int spdy_version, size_t size);
-
- // Initiailizes a SpdyFrameBuilder with a buffer of given size,
- // populated with a SPDY data frame header based on
- // |stream_id| and |flags|.
- SpdyFrameBuilder(SpdyStreamId stream_id, SpdyDataFlags flags, size_t size);
-
~SpdyFrameBuilder();
// Returns the size of the SpdyFrameBuilder's data.
@@ -60,6 +47,19 @@ class NET_EXPORT_PRIVATE SpdyFrameBuilder {
// GetWriteableBuffer() above.
bool Seek(size_t length);
+ // Populates this frame with a SPDY control frame header using
+ // version-specific information from the |framer| and length information from
+ // capacity_.
+ bool WriteControlFrameHeader(const SpdyFramer& framer,
+ SpdyControlType type,
+ uint8 flags);
+
+ // Populates this frame with a SPDY data frame header using version-specific
+ // information from the |framer| and length information from capacity_.
+ bool WriteDataFrameHeader(const SpdyFramer& framer,
+ SpdyStreamId stream_id,
+ SpdyDataFlags flags);
+
// Takes the buffer from the SpdyFrameBuilder.
SpdyFrame* take() {
SpdyFrame* rv = new SpdyFrame(buffer_.release(), length_, true);
@@ -110,8 +110,8 @@ class NET_EXPORT_PRIVATE SpdyFrameBuilder {
bool CanWrite(size_t length) const;
scoped_ptr<char[]> buffer_;
- size_t capacity_; // Allocation size of payload (or -1 if buffer is const).
- size_t length_; // current length of the buffer
+ size_t capacity_; // Allocation size of payload, set by constructor.
+ size_t length_; // Current length of the buffer.
};
} // namespace net
diff --git a/net/spdy/spdy_frame_builder_test.cc b/net/spdy/spdy_frame_builder_test.cc
index 23f7a0b..d14f697 100644
--- a/net/spdy/spdy_frame_builder_test.cc
+++ b/net/spdy/spdy_frame_builder_test.cc
@@ -51,7 +51,8 @@ TEST_P(SpdyFrameBuilderTest, RewriteLength) {
SpdyFramer framer(spdy_version_);
SettingsMap settings;
scoped_ptr<SpdyFrame> expected(framer.CreateSettings(settings));
- SpdyFrameBuilder builder(SETTINGS, 0, spdy_version_, expected->size() + 1);
+ SpdyFrameBuilder builder(expected->size() + 1);
+ builder.WriteControlFrameHeader(framer, SETTINGS, 0);
builder.WriteUInt32(0); // Write the number of settings.
EXPECT_TRUE(builder.GetWritableBuffer(1) != NULL);
builder.RewriteLength(framer);
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index e27671f..94f9fb7 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -1455,7 +1455,8 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream(
const size_t size = GetSynStreamMinimumSize()
+ GetSerializedLength(syn_stream.name_value_block());
- SpdyFrameBuilder builder(SYN_STREAM, flags, protocol_version(), size);
+ SpdyFrameBuilder builder(size);
+ builder.WriteControlFrameHeader(*this, SYN_STREAM, flags);
builder.WriteUInt32(syn_stream.stream_id());
builder.WriteUInt32(syn_stream.associated_to_stream_id());
uint8 priority = syn_stream.priority();
@@ -1502,7 +1503,8 @@ SpdySerializedFrame* SpdyFramer::SerializeSynReply(
size_t size = GetSynReplyMinimumSize()
+ GetSerializedLength(syn_reply.name_value_block());
- SpdyFrameBuilder builder(SYN_REPLY, flags, protocol_version(), size);
+ SpdyFrameBuilder builder(size);
+ builder.WriteControlFrameHeader(*this, SYN_REPLY, flags);
builder.WriteUInt32(syn_reply.stream_id());
if (protocol_version() < 3) {
builder.WriteUInt16(0); // Unused.
@@ -1522,10 +1524,8 @@ SpdyFrame* SpdyFramer::CreateRstStream(
SpdySerializedFrame* SpdyFramer::SerializeRstStream(
const SpdyRstStreamIR& rst_stream) const {
- SpdyFrameBuilder builder(RST_STREAM,
- kNoFlags,
- protocol_version(),
- GetRstStreamSize());
+ SpdyFrameBuilder builder(GetRstStreamSize());
+ builder.WriteControlFrameHeader(*this, RST_STREAM, 0);
builder.WriteUInt32(rst_stream.stream_id());
builder.WriteUInt32(rst_stream.status());
DCHECK_EQ(GetRstStreamSize(), builder.length());
@@ -1557,7 +1557,8 @@ SpdySerializedFrame* SpdyFramer::SerializeSettings(
// Size, in bytes, of this SETTINGS frame.
const size_t size = GetSettingsMinimumSize() + (values->size() * 8);
- SpdyFrameBuilder builder(SETTINGS, flags, protocol_version(), size);
+ SpdyFrameBuilder builder(size);
+ builder.WriteControlFrameHeader(*this, SETTINGS, flags);
builder.WriteUInt32(values->size());
DCHECK_EQ(GetSettingsMinimumSize(), builder.length());
for (SpdySettingsIR::ValueMap::const_iterator it = values->begin();
@@ -1585,7 +1586,8 @@ SpdyFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const {
}
SpdySerializedFrame* SpdyFramer::SerializePing(const SpdyPingIR& ping) const {
- SpdyFrameBuilder builder(PING, 0, protocol_version(), GetPingSize());
+ SpdyFrameBuilder builder(GetPingSize());
+ builder.WriteControlFrameHeader(*this, PING, 0);
builder.WriteUInt32(ping.id());
DCHECK_EQ(GetPingSize(), builder.length());
return builder.take();
@@ -1600,7 +1602,8 @@ SpdyFrame* SpdyFramer::CreateGoAway(
SpdySerializedFrame* SpdyFramer::SerializeGoAway(
const SpdyGoAwayIR& goaway) const {
- SpdyFrameBuilder builder(GOAWAY, 0, protocol_version(), GetGoAwaySize());
+ SpdyFrameBuilder builder(GetGoAwaySize());
+ builder.WriteControlFrameHeader(*this, GOAWAY, 0);
builder.WriteUInt32(goaway.last_good_stream_id());
if (protocol_version() >= 3) {
builder.WriteUInt32(goaway.status());
@@ -1638,7 +1641,8 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders(
size_t size = GetHeadersMinimumSize()
+ GetSerializedLength(headers.name_value_block());
- SpdyFrameBuilder builder(HEADERS, flags, protocol_version(), size);
+ SpdyFrameBuilder builder(size);
+ builder.WriteControlFrameHeader(*this, HEADERS, flags);
builder.WriteUInt32(headers.stream_id());
if (protocol_version() < 3) {
builder.WriteUInt16(0); // Unused.
@@ -1659,10 +1663,8 @@ SpdyFrame* SpdyFramer::CreateWindowUpdate(
SpdySerializedFrame* SpdyFramer::SerializeWindowUpdate(
const SpdyWindowUpdateIR& window_update) const {
- SpdyFrameBuilder builder(WINDOW_UPDATE,
- kNoFlags,
- protocol_version(),
- GetWindowUpdateSize());
+ SpdyFrameBuilder builder(GetWindowUpdateSize());
+ builder.WriteControlFrameHeader(*this, WINDOW_UPDATE, kNoFlags);
builder.WriteUInt32(window_update.stream_id());
builder.WriteUInt32(window_update.delta());
DCHECK_EQ(GetWindowUpdateSize(), builder.length());
@@ -1693,7 +1695,8 @@ SpdySerializedFrame* SpdyFramer::SerializeCredential(
size += 4 + it->length(); // Room for certificate.
}
- SpdyFrameBuilder builder(CREDENTIAL, 0, protocol_version(), size);
+ SpdyFrameBuilder builder(size);
+ builder.WriteControlFrameHeader(*this, CREDENTIAL, 0);
builder.WriteUInt16(credential.slot());
DCHECK_EQ(GetCredentialMinimumSize(), builder.length());
builder.WriteStringPiece32(credential.proof());
@@ -1725,7 +1728,8 @@ SpdySerializedFrame* SpdyFramer::SerializeData(const SpdyDataIR& data) const {
flags = DATA_FLAG_FIN;
}
- SpdyFrameBuilder builder(data.stream_id(), flags, kSize);
+ SpdyFrameBuilder builder(kSize);
+ builder.WriteDataFrameHeader(*this, data.stream_id(), flags);
builder.WriteBytes(data.data().data(), data.data().length());
DCHECK_EQ(kSize, builder.length());
return builder.take();
@@ -1740,7 +1744,8 @@ SpdySerializedFrame* SpdyFramer::SerializeDataFrameHeader(
flags = DATA_FLAG_FIN;
}
- SpdyFrameBuilder builder(data.stream_id(), flags, kSize);
+ SpdyFrameBuilder builder(kSize);
+ builder.WriteDataFrameHeader(*this, data.stream_id(), flags);
builder.OverwriteLength(*this, data.data().length());
DCHECK_EQ(kSize, builder.length());
return builder.take();
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc
index 88baed9..5e2867a 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -87,7 +87,7 @@ class SpdyFramerTestUtil {
CHECK(buffer != NULL);
SpdyFrame* decompressed_frame = new SpdyFrame(buffer, visitor.size(), true);
SetFrameLength(decompressed_frame,
- visitor.size() - SpdyFrame::kHeaderSize,
+ visitor.size() - framer->GetControlFrameMinimumSize(),
framer->protocol_version());
return decompressed_frame;
}
@@ -538,17 +538,6 @@ using net::test::GetSerializedHeaders;
namespace net {
-TEST(SpdyFrameBuilderTest, WriteLimits) {
- SpdyFrameBuilder builder(1, DATA_FLAG_NONE, kLengthMask + 8);
- // Data frame header is 8 bytes
- EXPECT_EQ(8u, builder.length());
- const string kLargeData(kLengthMask, 'A');
- builder.WriteUInt32(kLengthMask);
- EXPECT_EQ(12u, builder.length());
- EXPECT_TRUE(builder.WriteBytes(kLargeData.data(), kLengthMask - 4));
- EXPECT_EQ(kLengthMask + 8u, builder.length());
-}
-
enum SpdyFramerTestTypes {
SPDY2 = 2,
SPDY3 = 3,
@@ -694,7 +683,8 @@ TEST_P(SpdyFramerTest, OutOfOrderHeaders) {
framer.set_enable_compression(false);
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
+ SpdyFrameBuilder frame(1024);
+ frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // Associated stream id
@@ -801,7 +791,8 @@ TEST_P(SpdyFramerTest, ParseCredentialFrameData) {
TEST_P(SpdyFramerTest, DuplicateHeader) {
SpdyFramer framer(spdy_version_);
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
+ SpdyFrameBuilder frame(1024);
+ frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // associated stream id
@@ -837,7 +828,8 @@ TEST_P(SpdyFramerTest, DuplicateHeader) {
TEST_P(SpdyFramerTest, MultiValueHeader) {
SpdyFramer framer(spdy_version_);
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
+ SpdyFrameBuilder frame(1024);
+ frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // associated stream id
diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
index 5ef07c4..910e1a1 100644
--- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
@@ -3518,8 +3518,9 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, CorruptFrameSessionError) {
scoped_ptr<SpdyFrame> syn_reply_wrong_length(
ConstructSpdyGetSynReply(NULL, 0, 1));
size_t wrong_size = syn_reply_wrong_length->size() - 4;
+ BufferedSpdyFramer framer(kSpdyVersion2, false);
test::SetFrameLength(syn_reply_wrong_length.get(),
- wrong_size - SpdyFrame::kHeaderSize,
+ wrong_size - framer.GetControlFrameMinimumSize(),
kSpdyVersion2);
struct SynReplyTests {
diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
index aa777c1..a97cb0a 100644
--- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
@@ -4093,8 +4093,9 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, CorruptFrameSessionError) {
scoped_ptr<SpdyFrame> syn_reply_wrong_length(
ConstructSpdyGetSynReply(NULL, 0, 1));
size_t wrong_size = syn_reply_wrong_length->size() - 4;
+ BufferedSpdyFramer framer(kSpdyVersion3, false);
test::SetFrameLength(syn_reply_wrong_length.get(),
- wrong_size - SpdyFrame::kHeaderSize,
+ wrong_size - framer.GetControlFrameMinimumSize(),
kSpdyVersion3);
struct SynReplyTests {
diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h
index e250015..812295f 100644
--- a/net/spdy/spdy_protocol.h
+++ b/net/spdy/spdy_protocol.h
@@ -847,12 +847,6 @@ class SpdyFrame {
// Returns the actual size of the underlying buffer.
size_t size() const { return size_; }
- // The size of the SpdyFrameBlock structure.
- // Every SpdyFrame* class has a static size() method for accessing
- // the size of the data structure which will be sent over the wire.
- // Note: this is not the same as sizeof(SpdyFrame).
- enum { kHeaderSize = sizeof(struct SpdyFrameBlock) };
-
protected:
SpdyFrameBlock* frame_;
diff --git a/net/spdy/spdy_protocol_test.cc b/net/spdy/spdy_protocol_test.cc
index fff1ae6..63ab455 100644
--- a/net/spdy/spdy_protocol_test.cc
+++ b/net/spdy/spdy_protocol_test.cc
@@ -40,7 +40,6 @@ INSTANTIATE_TEST_CASE_P(SpdyProtocolTests,
// Test our protocol constants
TEST_P(SpdyProtocolTest, ProtocolConstants) {
- EXPECT_EQ(8u, SpdyFrame::kHeaderSize);
EXPECT_EQ(4u, sizeof(FlagsAndLength));
EXPECT_EQ(1, SYN_STREAM);
EXPECT_EQ(2, SYN_REPLY);
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index a3937ee..8f8317d 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -899,8 +899,10 @@ void SpdySession::OnWriteComplete(int result) {
// size.
if (result > 0) {
result = in_flight_write_.buffer()->size();
- DCHECK_GE(result, static_cast<int>(SpdyFrame::kHeaderSize));
- result -= static_cast<int>(SpdyFrame::kHeaderSize);
+ DCHECK_GE(result,
+ static_cast<int>(
+ buffered_spdy_framer_->GetControlFrameMinimumSize()));
+ result -= buffered_spdy_framer_->GetControlFrameMinimumSize();
}
// It is possible that the stream was cancelled while we were writing
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 8926235..750f876 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -38,7 +38,8 @@ namespace net {
// somewhat arbitrary, but is reasonably small and ensures that we elicit
// ACKs quickly from TCP (because TCP tries to only ACK every other packet).
const int kMss = 1430;
-const int kMaxSpdyFrameChunkSize = (2 * kMss) - SpdyFrame::kHeaderSize;
+// The 8 is the size of the SPDY frame header.
+const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8;
// Specifies the maxiumum concurrent streams server could send (via push).
const int kMaxConcurrentPushedStreams = 1000;
diff --git a/net/spdy/spdy_session_spdy2_unittest.cc b/net/spdy/spdy_session_spdy2_unittest.cc
index 6d52838..cd90bef 100644
--- a/net/spdy/spdy_session_spdy2_unittest.cc
+++ b/net/spdy/spdy_session_spdy2_unittest.cc
@@ -1641,7 +1641,8 @@ TEST_F(SpdySessionSpdy2Test, ReadDataWithoutYielding) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
- const int kPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
TestDataStream test_stream;
scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize));
char* payload_data = payload->data();
@@ -1731,7 +1732,8 @@ TEST_F(SpdySessionSpdy2Test, TestYieldingDuringReadData) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
- const int kPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
TestDataStream test_stream;
scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize));
char* payload_data = payload->data();
@@ -1830,7 +1832,8 @@ TEST_F(SpdySessionSpdy2Test, TestYieldingDuringAsyncReadData) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
TestDataStream test_stream;
- const int kEightKPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kEightKPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
scoped_refptr<net::IOBuffer> eightk_payload(
new net::IOBuffer(kEightKPayloadSize));
char* eightk_payload_data = eightk_payload->data();
diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc
index f56b65b..1b4b599 100644
--- a/net/spdy/spdy_session_spdy3_unittest.cc
+++ b/net/spdy/spdy_session_spdy3_unittest.cc
@@ -1770,7 +1770,8 @@ TEST_F(SpdySessionSpdy3Test, ReadDataWithoutYielding) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
- const int kPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
TestDataStream test_stream;
scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize));
char* payload_data = payload->data();
@@ -1860,7 +1861,8 @@ TEST_F(SpdySessionSpdy3Test, TestYieldingDuringReadData) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
- const int kPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
TestDataStream test_stream;
scoped_refptr<net::IOBuffer> payload(new net::IOBuffer(kPayloadSize));
char* payload_data = payload->data();
@@ -1959,7 +1961,8 @@ TEST_F(SpdySessionSpdy3Test, TestYieldingDuringAsyncReadData) {
// Build buffer of size kMaxReadBytes / 4 (-spdy_data_frame_size).
ASSERT_EQ(32 * 1024, kMaxReadBytes);
TestDataStream test_stream;
- const int kEightKPayloadSize = kMaxReadBytes / 4 - SpdyFrame::kHeaderSize;
+ const int kEightKPayloadSize =
+ kMaxReadBytes / 4 - framer.GetControlFrameMinimumSize();
scoped_refptr<net::IOBuffer> eightk_payload(
new net::IOBuffer(kEightKPayloadSize));
char* eightk_payload_data = eightk_payload->data();
diff --git a/net/tools/flip_server/constants.h b/net/tools/flip_server/constants.h
index a9fa3db..8b770a6 100644
--- a/net/tools/flip_server/constants.h
+++ b/net/tools/flip_server/constants.h
@@ -9,7 +9,7 @@
const int kMSS = 1460;
const int kSSLOverhead = 25;
-const int kSpdyOverhead = net::SpdyFrame::kHeaderSize;
+const int kSpdyOverhead = 8;
const int kInitialDataSendersThreshold = (2 * kMSS) - kSpdyOverhead;
const int kSSLSegmentSize = (1 * kMSS) - kSSLOverhead;
const int kSpdySegmentSize = kSSLSegmentSize - kSpdyOverhead;
diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc
index 132544d..7d0edd0 100644
--- a/net/tools/flip_server/spdy_interface.cc
+++ b/net/tools/flip_server/spdy_interface.cc
@@ -10,6 +10,7 @@
#include "net/spdy/spdy_framer.h"
#include "net/spdy/spdy_protocol.h"
#include "net/tools/dump_cache/url_utilities.h"
+#include "net/tools/flip_server/constants.h"
#include "net/tools/flip_server/flip_config.h"
#include "net/tools/flip_server/http_interface.h"
#include "net/tools/flip_server/spdy_util.h"
@@ -488,8 +489,7 @@ void SpdySM::SendDataFrameImpl(uint32 stream_id, const char* data, int64 len,
VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: Sending data frame "
<< stream_id << " [" << size << "] shrunk to "
- << (fdf->size() - SpdyFrame::kHeaderSize)
- << ", flags=" << flags;
+ << (fdf->size() - kSpdyOverhead) << ", flags=" << flags;
data += size;
len -= size;