Commit a136ffb8 authored by bnc's avatar bnc Committed by Commit bot

Remove HpackDecoder2.

Also remove associated flag FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2.

HpackDecoder2 (an adapter to //gfe/http2/hpack/decoder) was superseded by
HpackDecoder3, and has not been used in production.

This CL lands server change 149561590 by jamessynge.

BUG=488484

Review-Url: https://codereview.chromium.org/2750853008
Cr-Commit-Position: refs/heads/master@{#457474}
parent b857e84f
......@@ -1470,8 +1470,6 @@ component("net") {
"spdy/hpack/hpack_constants.h",
"spdy/hpack/hpack_decoder.cc",
"spdy/hpack/hpack_decoder.h",
"spdy/hpack/hpack_decoder2.cc",
"spdy/hpack/hpack_decoder2.h",
"spdy/hpack/hpack_decoder3.cc",
"spdy/hpack/hpack_decoder3.h",
"spdy/hpack/hpack_decoder_interface.h",
......@@ -4611,7 +4609,6 @@ test("net_unittests") {
"spdy/buffered_spdy_framer_unittest.cc",
"spdy/fuzzing/hpack_fuzz_util_test.cc",
"spdy/header_coalescer_test.cc",
"spdy/hpack/hpack_decoder2_test.cc",
"spdy/hpack/hpack_decoder3_test.cc",
"spdy/hpack/hpack_decoder_test.cc",
"spdy/hpack/hpack_encoder_test.cc",
......
......@@ -150,13 +150,11 @@ std::ostream& operator<<(std::ostream& os, Http2DecoderChoice v) {
return os;
}
enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3 };
enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER3 };
std::ostream& operator<<(std::ostream& os, HpackDecoderChoice v) {
switch (v) {
case HPACK_DECODER_SPDY:
return os << "SPDY";
case HPACK_DECODER2:
return os << "HPACK_DECODER2";
case HPACK_DECODER3:
return os << "HPACK_DECODER3";
}
......@@ -191,15 +189,9 @@ struct TestParams {
}
switch (hpack_decoder) {
case HPACK_DECODER_SPDY:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
break;
case HPACK_DECODER2:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = true;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
break;
case HPACK_DECODER3:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true;
break;
}
......@@ -407,13 +399,13 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParamsTuple> {
INSTANTIATE_TEST_CASE_P(
Tests,
QuicHeadersStreamTest,
::testing::Combine(
::testing::ValuesIn(AllSupportedVersions()),
::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER),
::testing::Combine(::testing::ValuesIn(AllSupportedVersions()),
::testing::Values(Perspective::IS_CLIENT,
Perspective::IS_SERVER),
::testing::Values(HTTP2_DECODER_SPDY,
HTTP2_DECODER_NESTED_SPDY,
HTTP2_DECODER_NEW),
::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3)));
::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER3)));
TEST_P(QuicHeadersStreamTest, StreamId) {
EXPECT_EQ(3u, headers_stream_->id());
......@@ -755,8 +747,7 @@ TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameSupportedFields) {
stream_frame_.data_buffer = frame.data();
stream_frame_.data_length = frame.size();
headers_stream_->OnStreamFrame(stream_frame_);
EXPECT_EQ(kTestHeaderTableSize,
QuicSpdySessionPeer::GetSpdyFramer(&session_)
EXPECT_EQ(kTestHeaderTableSize, QuicSpdySessionPeer::GetSpdyFramer(&session_)
.header_encoder_table_size());
}
......
This diff is collapsed.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_SPDY_HPACK_HPACK_DECODER2_H_
#define NET_SPDY_HPACK_HPACK_DECODER2_H_
// HpackDecoder2
// An HpackDecoder decodes header sets as outlined in
// http://tools.ietf.org/html/rfc7541. This implementation uses the
// new HpackBlockDecoder in //net/http2/hpack/
#include <stddef.h>
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
#include "net/http2/hpack/decoder/hpack_block_decoder.h"
#include "net/http2/hpack/decoder/hpack_decoder_string_buffer.h"
#include "net/http2/hpack/decoder/hpack_entry_decoder_listener.h"
#include "net/http2/hpack/http2_hpack_constants.h"
#include "net/http2/hpack/huffman/http2_hpack_huffman_decoder.h"
#include "net/spdy/hpack/hpack_constants.h"
#include "net/spdy/hpack/hpack_decoder_interface.h"
#include "net/spdy/hpack/hpack_header_table.h"
#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_headers_handler_interface.h"
namespace net {
namespace test {
class HpackDecoder2Peer;
} // namespace test
class NET_EXPORT_PRIVATE HpackDecoder2 : public HpackDecoderInterface,
HpackEntryDecoderListener {
public:
friend test::HpackDecoder2Peer;
HpackDecoder2();
~HpackDecoder2() override;
// Override the interface methods:
void ApplyHeaderTableSizeSetting(size_t size_setting) override;
void HandleControlFrameHeadersStart(
SpdyHeadersHandlerInterface* handler) override;
bool HandleControlFrameHeadersData(const char* headers_data,
size_t headers_data_length) override;
bool HandleControlFrameHeadersComplete(size_t* compressed_len) override;
const SpdyHeaderBlock& decoded_block() const override;
void SetHeaderTableDebugVisitor(
std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor)
override;
void set_max_decode_buffer_size_bytes(
size_t max_decode_buffer_size_bytes) override;
size_t EstimateMemoryUsage() const override;
protected:
// Override the HpackEntryDecoderListener methods:
void OnIndexedHeader(size_t index) override;
void OnStartLiteralHeader(HpackEntryType entry_type,
size_t maybe_name_index) override;
void OnNameStart(bool huffman_encoded, size_t len) override;
void OnNameData(const char* data, size_t len) override;
void OnNameEnd() override;
void OnValueStart(bool huffman_encoded, size_t len) override;
void OnValueData(const char* data, size_t len) override;
void OnValueEnd() override;
void OnDynamicTableSizeUpdate(size_t size) override;
private:
// Called when a complete header entry has been decoded, with the name and
// value of the entry. If check_header_order_ is true, confirms that
// pseudo-headers don't appear after normal headers, else it treats the
// headers as malformed, as per sections 8.1.2.3. of the HTTP2 specification.
// Calls handler_->OnHeader() if there is a handler, else adds the header
// to decoded_block_.
void HandleHeaderRepresentation(base::StringPiece name,
base::StringPiece value);
// Reset state in preparation for decoding a new HPACK block. Does not reset
// the dynamic table.
void Reset();
// Called when an error is detected while decoding. Replaces the listener
// in the HpackBlockDecoder with the no-op listener.
void SetErrorDetected();
// Enforce the limit on the maximum size of strings that can be buffered.
// It happens that this test is made after the strings have been buffered,
// but that isn't a problem because we don't pass enormous buffers into
// HandleControlFrameHeadersData.
bool EnforceMaxDecodeBufferSize();
HpackHeaderTable header_table_;
SpdyHeaderBlock decoded_block_;
// Scratch space for storing decoded literals.
HpackDecoderStringBuffer name_, value_;
// If non-NULL, handles decoded headers.
SpdyHeadersHandlerInterface* handler_;
HpackEntryDecoderNoOpListener no_op_listener_;
// Total bytes that have been received as input (i.e. HPACK encoded).
size_t total_hpack_bytes_;
// Total bytes of the name and value strings in the current HPACK block.
size_t total_header_bytes_;
// How much encoded data this decoder is willing to buffer.
size_t max_decode_buffer_size_bytes_ = 32 * 1024; // 32 KB
HpackBlockDecoder hpack_block_decoder_;
// Count of Dynamic Table Size Updates seen in the current HPACK block.
uint32_t size_update_count_;
// The type of the current header entry (with literals) that is being decoded.
HpackEntryType entry_type_;
// Has a header been seen in the current HPACK block?
bool header_seen_;
// Did the HpackBlockDecoder stop in the middle of an entry?
bool in_progress_;
// Has an error been detected while decoding the HPACK block?
bool error_detected_;
// Flag to keep track of having seen the header block start. Needed at the
// moment because HandleControlFrameHeadersStart won't be called if a handler
// is not being provided by the caller.
// TODO(jamessynge): Consider collapsing several of these bools into a single
// enum representing the state of the decoding process.
bool header_block_started_;
DISALLOW_COPY_AND_ASSIGN(HpackDecoder2);
};
} // namespace net
#endif // NET_SPDY_HPACK_HPACK_DECODER2_H_
This diff is collapsed.
......@@ -12,9 +12,6 @@ bool FLAGS_chromium_http2_flag_log_compressed_size = true;
// If true, remove use of SpdyFrameBuilder::OverwriteLength().
bool FLAGS_chromium_http2_flag_remove_rewritelength = true;
// Use //net/http2/hpack/decoder as HPACK entry decoder.
bool FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
// Use //net/http2/hpack/decoder as complete HPACK decoder.
bool FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true;
......
......@@ -11,8 +11,6 @@ namespace net {
NET_EXPORT_PRIVATE extern bool FLAGS_chromium_http2_flag_log_compressed_size;
NET_EXPORT_PRIVATE extern bool FLAGS_chromium_http2_flag_remove_rewritelength;
NET_EXPORT_PRIVATE extern bool
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2;
NET_EXPORT_PRIVATE extern bool
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3;
NET_EXPORT_PRIVATE extern bool FLAGS_use_http2_frame_decoder_adapter;
......
......@@ -25,7 +25,6 @@
#include "net/quic/core/quic_flags.h"
#include "net/spdy/hpack/hpack_constants.h"
#include "net/spdy/hpack/hpack_decoder.h"
#include "net/spdy/hpack/hpack_decoder2.h"
#include "net/spdy/hpack/hpack_decoder3.h"
#include "net/spdy/http2_frame_decoder_adapter.h"
#include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
......@@ -2403,11 +2402,7 @@ HpackEncoder* SpdyFramer::GetHpackEncoder() {
HpackDecoderInterface* SpdyFramer::GetHpackDecoder() {
if (hpack_decoder_.get() == nullptr) {
if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3) {
SPDY_BUG_IF(FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2)
<< "Both alternate decoders are enabled.";
hpack_decoder_.reset(new HpackDecoder3());
} else if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2) {
hpack_decoder_.reset(new HpackDecoder2());
} else {
hpack_decoder_.reset(new HpackDecoder());
}
......
......@@ -636,7 +636,7 @@ StringPiece GetSerializedHeaders(const SpdySerializedFrame& frame,
}
enum DecoderChoice { DECODER_SELF, DECODER_NESTED, DECODER_HTTP2 };
enum HpackChoice { HPACK_DECODER_1, HPACK_DECODER_2, HPACK_DECODER_3 };
enum HpackChoice { HPACK_DECODER_1, HPACK_DECODER_3 };
class SpdyFramerTest
: public ::testing::TestWithParam<std::tuple<DecoderChoice, HpackChoice>> {
......@@ -659,15 +659,9 @@ class SpdyFramerTest
}
switch (std::get<1>(param)) {
case HPACK_DECODER_1:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
break;
case HPACK_DECODER_2:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = true;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
break;
case HPACK_DECODER_3:
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true;
break;
}
......@@ -695,12 +689,13 @@ class SpdyFramerTest
}
};
INSTANTIATE_TEST_CASE_P(
SpdyFramerTests,
INSTANTIATE_TEST_CASE_P(SpdyFramerTests,
SpdyFramerTest,
::testing::Combine(
::testing::Values(DECODER_SELF, DECODER_NESTED, DECODER_HTTP2),
::testing::Values(HPACK_DECODER_1, HPACK_DECODER_2, HPACK_DECODER_3)));
::testing::Combine(::testing::Values(DECODER_SELF,
DECODER_NESTED,
DECODER_HTTP2),
::testing::Values(HPACK_DECODER_1,
HPACK_DECODER_3)));
// Test that we can encode and decode a SpdyHeaderBlock in serialized form.
TEST_P(SpdyFramerTest, HeaderBlockInBuffer) {
......
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