Commit 98c5e245 authored by thakis@chromium.org's avatar thakis@chromium.org

Deprecate SpdyControlFrame::size in favor of SpdyControlFrame::kHeaderSize

inherited from the base class.

Manual changes only to spdy_protocol.h, the rest of the CL generated by
running and then manually fixing the one 80 col violation:

 perl -pi -e "s/SpdyControlFrame::size\(\)/SpdyControlFrame::kHeaderSize/"  $(git grep -l SpdyControlFrame::size)

This is the same as the google-internal CL 25980588

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/8898003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113865 0039d316-1c4b-4281-b951-d872f2087c98
parent fdd2715c
...@@ -423,12 +423,12 @@ void SpdyFramer::ProcessControlFrameHeader() { ...@@ -423,12 +423,12 @@ void SpdyFramer::ProcessControlFrameHeader() {
switch (current_control_frame.type()) { switch (current_control_frame.type()) {
case SYN_STREAM: case SYN_STREAM:
if (current_control_frame.length() < if (current_control_frame.length() <
SpdySynStreamControlFrame::size() - SpdyControlFrame::size()) SpdySynStreamControlFrame::size() - SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
case SYN_REPLY: case SYN_REPLY:
if (current_control_frame.length() < if (current_control_frame.length() <
SpdySynReplyControlFrame::size() - SpdyControlFrame::size()) SpdySynReplyControlFrame::size() - SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
case RST_STREAM: case RST_STREAM:
...@@ -438,7 +438,7 @@ void SpdyFramer::ProcessControlFrameHeader() { ...@@ -438,7 +438,7 @@ void SpdyFramer::ProcessControlFrameHeader() {
break; break;
case SETTINGS: case SETTINGS:
if (current_control_frame.length() < if (current_control_frame.length() <
SpdySettingsControlFrame::size() - SpdyControlFrame::size()) SpdySettingsControlFrame::size() - SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
case GOAWAY: case GOAWAY:
...@@ -448,17 +448,18 @@ void SpdyFramer::ProcessControlFrameHeader() { ...@@ -448,17 +448,18 @@ void SpdyFramer::ProcessControlFrameHeader() {
break; break;
case HEADERS: case HEADERS:
if (current_control_frame.length() < if (current_control_frame.length() <
SpdyHeadersControlFrame::size() - SpdyControlFrame::size()) SpdyHeadersControlFrame::size() - SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
case WINDOW_UPDATE: case WINDOW_UPDATE:
if (current_control_frame.length() != if (current_control_frame.length() !=
SpdyWindowUpdateControlFrame::size() - SpdyControlFrame::size()) SpdyWindowUpdateControlFrame::size() -
SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
case PING: case PING:
if (current_control_frame.length() != if (current_control_frame.length() !=
SpdyPingControlFrame::size() - SpdyControlFrame::size()) SpdyPingControlFrame::size() - SpdyControlFrame::kHeaderSize)
set_error(SPDY_INVALID_CONTROL_FRAME); set_error(SPDY_INVALID_CONTROL_FRAME);
break; break;
default: default:
......
...@@ -1593,7 +1593,7 @@ TEST_F(SpdyFramerTest, ExpandBuffer_HeapSmash) { ...@@ -1593,7 +1593,7 @@ TEST_F(SpdyFramerTest, ExpandBuffer_HeapSmash) {
TestSpdyVisitor visitor; TestSpdyVisitor visitor;
visitor.SimulateInFramer( visitor.SimulateInFramer(
reinterpret_cast<unsigned char*>(template_frame.get()->data()), reinterpret_cast<unsigned char*>(template_frame.get()->data()),
template_frame.get()->length() + SpdyControlFrame::size()); template_frame.get()->length() + SpdyControlFrame::kHeaderSize);
EXPECT_EQ(1, visitor.syn_frame_count_); EXPECT_EQ(1, visitor.syn_frame_count_);
} }
} }
......
...@@ -470,10 +470,6 @@ class SpdyControlFrame : public SpdyFrame { ...@@ -470,10 +470,6 @@ class SpdyControlFrame : public SpdyFrame {
return type() == SYN_STREAM || type() == SYN_REPLY || type() == HEADERS; return type() == SYN_STREAM || type() == SYN_REPLY || type() == HEADERS;
} }
// Returns the size of the SpdyFrameBlock structure.
// Note: this is not the size of the SpdyControlFrame class.
static size_t size() { return sizeof(SpdyFrameBlock); }
// The size of the 'Number of Name/Value pairs' field in a Name/Value block. // The size of the 'Number of Name/Value pairs' field in a Name/Value block.
static const size_t kNumNameValuePairsSize = 2; static const size_t kNumNameValuePairsSize = 2;
......
...@@ -50,7 +50,7 @@ namespace { ...@@ -50,7 +50,7 @@ namespace {
TEST(SpdyProtocolTest, ProtocolConstants) { TEST(SpdyProtocolTest, ProtocolConstants) {
EXPECT_EQ(8u, SpdyFrame::kHeaderSize); EXPECT_EQ(8u, SpdyFrame::kHeaderSize);
EXPECT_EQ(8u, SpdyDataFrame::size()); EXPECT_EQ(8u, SpdyDataFrame::size());
EXPECT_EQ(8u, SpdyControlFrame::size()); EXPECT_EQ(8u, SpdyControlFrame::kHeaderSize);
EXPECT_EQ(18u, SpdySynStreamControlFrame::size()); EXPECT_EQ(18u, SpdySynStreamControlFrame::size());
EXPECT_EQ(14u, SpdySynReplyControlFrame::size()); EXPECT_EQ(14u, SpdySynReplyControlFrame::size());
EXPECT_EQ(16u, SpdyRstStreamControlFrame::size()); EXPECT_EQ(16u, SpdyRstStreamControlFrame::size());
...@@ -265,7 +265,7 @@ TEST(SpdyProtocolTest, TestSpdySettingsFrame) { ...@@ -265,7 +265,7 @@ TEST(SpdyProtocolTest, TestSpdySettingsFrame) {
} }
TEST(SpdyProtocolTest, HasHeaderBlock) { TEST(SpdyProtocolTest, HasHeaderBlock) {
SpdyControlFrame frame(SpdyControlFrame::size()); SpdyControlFrame frame(SpdyControlFrame::kHeaderSize);
for (SpdyControlType type = SYN_STREAM; for (SpdyControlType type = SYN_STREAM;
type < NUM_CONTROL_FRAME_TYPES; type < NUM_CONTROL_FRAME_TYPES;
type = static_cast<SpdyControlType>(type + 1)) { type = static_cast<SpdyControlType>(type + 1)) {
...@@ -308,7 +308,7 @@ TEST(SpdyProtocolDeathTest, TestDataFrame) { ...@@ -308,7 +308,7 @@ TEST(SpdyProtocolDeathTest, TestDataFrame) {
TEST(SpdyProtocolDeathTest, TestSpdyControlFrameStreamId) { TEST(SpdyProtocolDeathTest, TestSpdyControlFrameStreamId) {
SpdyControlFrame frame_store(SpdySynStreamControlFrame::size()); SpdyControlFrame frame_store(SpdySynStreamControlFrame::size());
memset(frame_store.data(), '1', SpdyControlFrame::size()); memset(frame_store.data(), '1', SpdyControlFrame::kHeaderSize);
SpdySynStreamControlFrame* frame = SpdySynStreamControlFrame* frame =
reinterpret_cast<SpdySynStreamControlFrame*>(&frame_store); reinterpret_cast<SpdySynStreamControlFrame*>(&frame_store);
...@@ -324,7 +324,7 @@ TEST(SpdyProtocolDeathTest, TestSpdyControlFrameStreamId) { ...@@ -324,7 +324,7 @@ TEST(SpdyProtocolDeathTest, TestSpdyControlFrameStreamId) {
TEST(SpdyProtocolDeathTest, TestSpdyControlFrameVersion) { TEST(SpdyProtocolDeathTest, TestSpdyControlFrameVersion) {
const unsigned int kVersionMask = 0x7fff; const unsigned int kVersionMask = 0x7fff;
SpdyControlFrame frame(SpdySynStreamControlFrame::size()); SpdyControlFrame frame(SpdySynStreamControlFrame::size());
memset(frame.data(), '1', SpdyControlFrame::size()); memset(frame.data(), '1', SpdyControlFrame::kHeaderSize);
// Set the version to various values, and make sure it does not affect the // Set the version to various values, and make sure it does not affect the
// type. // type.
...@@ -343,8 +343,8 @@ TEST(SpdyProtocolDeathTest, TestSpdyControlFrameVersion) { ...@@ -343,8 +343,8 @@ TEST(SpdyProtocolDeathTest, TestSpdyControlFrameVersion) {
} }
TEST(SpdyProtocolDeathTest, TestSpdyControlFrameType) { TEST(SpdyProtocolDeathTest, TestSpdyControlFrameType) {
SpdyControlFrame frame(SpdyControlFrame::size()); SpdyControlFrame frame(SpdyControlFrame::kHeaderSize);
memset(frame.data(), 255, SpdyControlFrame::size()); memset(frame.data(), 255, SpdyControlFrame::kHeaderSize);
// type() should be out of bounds. // type() should be out of bounds.
EXPECT_FALSE(frame.AppearsToBeAValidControlFrame()); EXPECT_FALSE(frame.AppearsToBeAValidControlFrame());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment