Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: net/spdy/spdy_framer.cc

Issue 267063006: Allocate HpackDecoder/Encoder only for SpdyFramer > SPDY3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer.cc
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 3d9994013171b787a6bccba0d1e64144b62baecb..73aa53299ce8bc418cd8a4f8909e7e4d861217ee 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -123,8 +123,6 @@ bool SpdyFramerVisitorInterface::OnRstStreamFrameData(
SpdyFramer::SpdyFramer(SpdyMajorVersion version)
: current_frame_buffer_(new char[kControlFrameBufferSize]),
enable_compression_(true),
- hpack_encoder_(ObtainHpackHuffmanTable()),
- hpack_decoder_(ObtainHpackHuffmanTable()),
visitor_(NULL),
debug_visitor_(NULL),
display_protocol_("SPDY"),
@@ -136,6 +134,12 @@ SpdyFramer::SpdyFramer(SpdyMajorVersion version)
DCHECK_GE(spdy_version_, SPDY_MIN_VERSION);
DCHECK_LE(spdy_version_, SPDY_MAX_VERSION);
Reset();
+
+ // SPDY4 and up use HPACK. Allocate instances for these protocol versions.
+ if (spdy_version_ > SPDY3) {
+ hpack_encoder_.reset(new HpackEncoder(ObtainHpackHuffmanTable()));
+ hpack_decoder_.reset(new HpackDecoder(ObtainHpackHuffmanTable()));
+ }
}
SpdyFramer::~SpdyFramer() {
@@ -1477,9 +1481,9 @@ size_t SpdyFramer::ProcessControlFrameHeaderBlock(const char* data,
}
size_t process_bytes = std::min(data_len, remaining_data_length_);
if (is_hpack_header_block) {
- if (!hpack_decoder_.HandleControlFrameHeadersData(current_frame_stream_id_,
- data,
- process_bytes)) {
+ if (!hpack_decoder_->HandleControlFrameHeadersData(current_frame_stream_id_,
+ data,
+ process_bytes)) {
// TODO(jgraettinger): Finer-grained HPACK error codes.
set_error(SPDY_DECOMPRESS_FAILURE);
processed_successfully = false;
@@ -1499,7 +1503,7 @@ size_t SpdyFramer::ProcessControlFrameHeaderBlock(const char* data,
if (remaining_data_length_ == 0 && processed_successfully) {
if (expect_continuation_ == 0) {
if (is_hpack_header_block) {
- if (!hpack_decoder_.HandleControlFrameHeadersComplete(
+ if (!hpack_decoder_->HandleControlFrameHeadersComplete(
current_frame_stream_id_)) {
set_error(SPDY_DECOMPRESS_FAILURE);
processed_successfully = false;
@@ -1595,7 +1599,7 @@ void SpdyFramer::DeliverHpackBlockAsSpdy3Block() {
DCHECK_LT(SPDY3, protocol_version());
DCHECK_EQ(0u, remaining_data_length_);
- const SpdyNameValueBlock& block = hpack_decoder_.decoded_block();
+ const SpdyNameValueBlock& block = hpack_decoder_->decoded_block();
if (block.empty()) {
// Special-case this to make tests happy.
ProcessControlFrameHeaderBlock(NULL, 0, false);
@@ -2144,10 +2148,10 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream(
string hpack_encoding;
if (protocol_version() > SPDY3) {
if (enable_compression_) {
- hpack_encoder_.EncodeHeaderSet(
+ hpack_encoder_->EncodeHeaderSet(
syn_stream.name_value_block(), &hpack_encoding);
} else {
- hpack_encoder_.EncodeHeaderSetWithoutCompression(
+ hpack_encoder_->EncodeHeaderSetWithoutCompression(
syn_stream.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
@@ -2209,10 +2213,10 @@ SpdySerializedFrame* SpdyFramer::SerializeSynReply(
string hpack_encoding;
if (protocol_version() > SPDY3) {
if (enable_compression_) {
- hpack_encoder_.EncodeHeaderSet(
+ hpack_encoder_->EncodeHeaderSet(
syn_reply.name_value_block(), &hpack_encoding);
} else {
- hpack_encoder_.EncodeHeaderSetWithoutCompression(
+ hpack_encoder_->EncodeHeaderSetWithoutCompression(
syn_reply.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
@@ -2429,10 +2433,10 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders(
string hpack_encoding;
if (protocol_version() > SPDY3) {
if (enable_compression_) {
- hpack_encoder_.EncodeHeaderSet(
+ hpack_encoder_->EncodeHeaderSet(
headers.name_value_block(), &hpack_encoding);
} else {
- hpack_encoder_.EncodeHeaderSetWithoutCompression(
+ hpack_encoder_->EncodeHeaderSetWithoutCompression(
headers.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
@@ -2522,10 +2526,10 @@ SpdyFrame* SpdyFramer::SerializePushPromise(
string hpack_encoding;
if (protocol_version() > SPDY3) {
if (enable_compression_) {
- hpack_encoder_.EncodeHeaderSet(
+ hpack_encoder_->EncodeHeaderSet(
push_promise.name_value_block(), &hpack_encoding);
} else {
- hpack_encoder_.EncodeHeaderSetWithoutCompression(
+ hpack_encoder_->EncodeHeaderSetWithoutCompression(
push_promise.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
@@ -2582,10 +2586,10 @@ SpdyFrame* SpdyFramer::SerializeContinuation(
size_t size = GetContinuationMinimumSize();
string hpack_encoding;
if (enable_compression_) {
- hpack_encoder_.EncodeHeaderSet(
+ hpack_encoder_->EncodeHeaderSet(
continuation.name_value_block(), &hpack_encoding);
} else {
- hpack_encoder_.EncodeHeaderSetWithoutCompression(
+ hpack_encoder_->EncodeHeaderSetWithoutCompression(
continuation.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698