diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-11 04:49:16 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-11 04:49:16 +0000 |
commit | 016baed77943b258c720b8e354765239b28b4881 (patch) | |
tree | bc08a33612d890492c0fc057b1f24a3b7acb4044 | |
parent | 152ea305aa6528244310077cac67afc8df71bb5a (diff) | |
download | chromium_src-016baed77943b258c720b8e354765239b28b4881.zip chromium_src-016baed77943b258c720b8e354765239b28b4881.tar.gz chromium_src-016baed77943b258c720b8e354765239b28b4881.tar.bz2 |
Add DCHECK for these-should-never-be-hit SpdyFrameBuilder error conditions.
This lands server change 40892968.
Review URL: https://chromiumcodereview.appspot.com/12225074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181664 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/spdy/spdy_frame_builder.cc | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/net/spdy/spdy_frame_builder.cc b/net/spdy/spdy_frame_builder.cc index ba7071f..314dd12 100644 --- a/net/spdy/spdy_frame_builder.cc +++ b/net/spdy/spdy_frame_builder.cc @@ -63,41 +63,34 @@ SpdyFrameBuilder::SpdyFrameBuilder(SpdyStreamId stream_id, SpdyFrameBuilder::~SpdyFrameBuilder() { } -char* SpdyFrameBuilder::BeginWrite(size_t length) { - size_t offset = length_; - size_t needed_size = length_ + length; - if (needed_size > capacity_) - return NULL; - -#ifdef ARCH_CPU_64_BITS - DCHECK_LE(length, std::numeric_limits<uint32>::max()); -#endif - - return buffer_.get() + offset; -} - -void SpdyFrameBuilder::EndWrite(char* dest, int length) { -} - bool SpdyFrameBuilder::WriteBytes(const void* data, uint32 data_len) { if (data_len > kLengthMask) { + DCHECK(false); return false; } - char* dest = BeginWrite(data_len); - if (!dest) + size_t offset = length_; + size_t needed_size = length_ + data_len; + if (needed_size > capacity_) { + DCHECK(false); return false; + } - memcpy(dest, data, data_len); +#ifdef ARCH_CPU_64_BITS + DCHECK_LE(data_len, std::numeric_limits<uint32>::max()); +#endif - EndWrite(dest, data_len); + char* dest = buffer_.get() + offset; + memcpy(dest, data, data_len); length_ += data_len; return true; } bool SpdyFrameBuilder::WriteString(const std::string& value) { - if (value.size() > 0xffff) + if (value.size() > 0xffff) { + DCHECK(false) << "Tried to write string with length > 16bit."; return false; + } if (!WriteUInt16(static_cast<int>(value.size()))) return false; |