| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/core/quic_headers_stream.h" | 5 #include "net/quic/core/quic_headers_stream.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 case HTTP2_DECODER_SPDY: | 143 case HTTP2_DECODER_SPDY: |
| 144 return os << "SPDY"; | 144 return os << "SPDY"; |
| 145 case HTTP2_DECODER_NESTED_SPDY: | 145 case HTTP2_DECODER_NESTED_SPDY: |
| 146 return os << "NESTED_SPDY"; | 146 return os << "NESTED_SPDY"; |
| 147 case HTTP2_DECODER_NEW: | 147 case HTTP2_DECODER_NEW: |
| 148 return os << "NEW"; | 148 return os << "NEW"; |
| 149 } | 149 } |
| 150 return os; | 150 return os; |
| 151 } | 151 } |
| 152 | 152 |
| 153 enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3 }; | 153 enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER3 }; |
| 154 std::ostream& operator<<(std::ostream& os, HpackDecoderChoice v) { | 154 std::ostream& operator<<(std::ostream& os, HpackDecoderChoice v) { |
| 155 switch (v) { | 155 switch (v) { |
| 156 case HPACK_DECODER_SPDY: | 156 case HPACK_DECODER_SPDY: |
| 157 return os << "SPDY"; | 157 return os << "SPDY"; |
| 158 case HPACK_DECODER2: | |
| 159 return os << "HPACK_DECODER2"; | |
| 160 case HPACK_DECODER3: | 158 case HPACK_DECODER3: |
| 161 return os << "HPACK_DECODER3"; | 159 return os << "HPACK_DECODER3"; |
| 162 } | 160 } |
| 163 return os; | 161 return os; |
| 164 } | 162 } |
| 165 | 163 |
| 166 typedef testing:: | 164 typedef testing:: |
| 167 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice> | 165 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice> |
| 168 TestParamsTuple; | 166 TestParamsTuple; |
| 169 | 167 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 break; | 182 break; |
| 185 case HTTP2_DECODER_NEW: | 183 case HTTP2_DECODER_NEW: |
| 186 FLAGS_use_nested_spdy_framer_decoder = false; | 184 FLAGS_use_nested_spdy_framer_decoder = false; |
| 187 FLAGS_chromium_http2_flag_spdy_use_http2_frame_decoder_adapter = true; | 185 FLAGS_chromium_http2_flag_spdy_use_http2_frame_decoder_adapter = true; |
| 188 // Http2FrameDecoderAdapter needs the new header methods, else | 186 // Http2FrameDecoderAdapter needs the new header methods, else |
| 189 // --use_http2_frame_decoder_adapter=true will be ignored. | 187 // --use_http2_frame_decoder_adapter=true will be ignored. |
| 190 break; | 188 break; |
| 191 } | 189 } |
| 192 switch (hpack_decoder) { | 190 switch (hpack_decoder) { |
| 193 case HPACK_DECODER_SPDY: | 191 case HPACK_DECODER_SPDY: |
| 194 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false; | |
| 195 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false; | |
| 196 break; | |
| 197 case HPACK_DECODER2: | |
| 198 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = true; | |
| 199 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false; | 192 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false; |
| 200 break; | 193 break; |
| 201 case HPACK_DECODER3: | 194 case HPACK_DECODER3: |
| 202 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false; | |
| 203 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true; | 195 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true; |
| 204 break; | 196 break; |
| 205 } | 197 } |
| 206 QUIC_LOG(INFO) << "TestParams: version: " << QuicVersionToString(version) | 198 QUIC_LOG(INFO) << "TestParams: version: " << QuicVersionToString(version) |
| 207 << ", perspective: " << perspective | 199 << ", perspective: " << perspective |
| 208 << ", http2_decoder: " << http2_decoder | 200 << ", http2_decoder: " << http2_decoder |
| 209 << ", hpack_decoder: " << hpack_decoder; | 201 << ", hpack_decoder: " << hpack_decoder; |
| 210 } | 202 } |
| 211 | 203 |
| 212 QuicVersion version; | 204 QuicVersion version; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 StrictMock<MockVisitor> visitor_; | 392 StrictMock<MockVisitor> visitor_; |
| 401 QuicStreamFrame stream_frame_; | 393 QuicStreamFrame stream_frame_; |
| 402 QuicStreamId next_promised_stream_id_; | 394 QuicStreamId next_promised_stream_id_; |
| 403 }; | 395 }; |
| 404 | 396 |
| 405 // Run all tests with each version, perspective (client or server), | 397 // Run all tests with each version, perspective (client or server), |
| 406 // HTTP/2 and HPACK decoder. | 398 // HTTP/2 and HPACK decoder. |
| 407 INSTANTIATE_TEST_CASE_P( | 399 INSTANTIATE_TEST_CASE_P( |
| 408 Tests, | 400 Tests, |
| 409 QuicHeadersStreamTest, | 401 QuicHeadersStreamTest, |
| 410 ::testing::Combine( | 402 ::testing::Combine(::testing::ValuesIn(AllSupportedVersions()), |
| 411 ::testing::ValuesIn(AllSupportedVersions()), | 403 ::testing::Values(Perspective::IS_CLIENT, |
| 412 ::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER), | 404 Perspective::IS_SERVER), |
| 413 ::testing::Values(HTTP2_DECODER_SPDY, | 405 ::testing::Values(HTTP2_DECODER_SPDY, |
| 414 HTTP2_DECODER_NESTED_SPDY, | 406 HTTP2_DECODER_NESTED_SPDY, |
| 415 HTTP2_DECODER_NEW), | 407 HTTP2_DECODER_NEW), |
| 416 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3))); | 408 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER3))); |
| 417 | 409 |
| 418 TEST_P(QuicHeadersStreamTest, StreamId) { | 410 TEST_P(QuicHeadersStreamTest, StreamId) { |
| 419 EXPECT_EQ(3u, headers_stream_->id()); | 411 EXPECT_EQ(3u, headers_stream_->id()); |
| 420 } | 412 } |
| 421 | 413 |
| 422 TEST_P(QuicHeadersStreamTest, WriteHeaders) { | 414 TEST_P(QuicHeadersStreamTest, WriteHeaders) { |
| 423 for (QuicStreamId stream_id = kClientDataStreamId1; | 415 for (QuicStreamId stream_id = kClientDataStreamId1; |
| 424 stream_id < kClientDataStreamId3; stream_id += 2) { | 416 stream_id < kClientDataStreamId3; stream_id += 2) { |
| 425 for (bool fin : kFins) { | 417 for (bool fin : kFins) { |
| 426 if (perspective() == Perspective::IS_SERVER) { | 418 if (perspective() == Perspective::IS_SERVER) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 const uint32_t kTestHeaderTableSize = 1000; | 740 const uint32_t kTestHeaderTableSize = 1000; |
| 749 SpdySettingsIR data; | 741 SpdySettingsIR data; |
| 750 // Respect supported settings frames SETTINGS_HEADER_TABLE_SIZE, | 742 // Respect supported settings frames SETTINGS_HEADER_TABLE_SIZE, |
| 751 // SETTINGS_MAX_HEADER_LIST_SIZE. | 743 // SETTINGS_MAX_HEADER_LIST_SIZE. |
| 752 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, kTestHeaderTableSize); | 744 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, kTestHeaderTableSize); |
| 753 data.AddSetting(SETTINGS_MAX_HEADER_LIST_SIZE, 2000); | 745 data.AddSetting(SETTINGS_MAX_HEADER_LIST_SIZE, 2000); |
| 754 SpdySerializedFrame frame(framer_->SerializeFrame(data)); | 746 SpdySerializedFrame frame(framer_->SerializeFrame(data)); |
| 755 stream_frame_.data_buffer = frame.data(); | 747 stream_frame_.data_buffer = frame.data(); |
| 756 stream_frame_.data_length = frame.size(); | 748 stream_frame_.data_length = frame.size(); |
| 757 headers_stream_->OnStreamFrame(stream_frame_); | 749 headers_stream_->OnStreamFrame(stream_frame_); |
| 758 EXPECT_EQ(kTestHeaderTableSize, | 750 EXPECT_EQ(kTestHeaderTableSize, QuicSpdySessionPeer::GetSpdyFramer(&session_) |
| 759 QuicSpdySessionPeer::GetSpdyFramer(&session_) | 751 .header_encoder_table_size()); |
| 760 .header_encoder_table_size()); | |
| 761 } | 752 } |
| 762 | 753 |
| 763 TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameUnsupportedFields) { | 754 TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameUnsupportedFields) { |
| 764 FLAGS_quic_reloadable_flag_quic_respect_http2_settings_frame = true; | 755 FLAGS_quic_reloadable_flag_quic_respect_http2_settings_frame = true; |
| 765 FLAGS_quic_reloadable_flag_quic_send_max_header_list_size = true; | 756 FLAGS_quic_reloadable_flag_quic_send_max_header_list_size = true; |
| 766 SpdySettingsIR data; | 757 SpdySettingsIR data; |
| 767 // Does not support SETTINGS_MAX_CONCURRENT_STREAMS, | 758 // Does not support SETTINGS_MAX_CONCURRENT_STREAMS, |
| 768 // SETTINGS_INITIAL_WINDOW_SIZE, SETTINGS_ENABLE_PUSH and | 759 // SETTINGS_INITIAL_WINDOW_SIZE, SETTINGS_ENABLE_PUSH and |
| 769 // SETTINGS_MAX_FRAME_SIZE. | 760 // SETTINGS_MAX_FRAME_SIZE. |
| 770 data.AddSetting(SETTINGS_MAX_CONCURRENT_STREAMS, 100); | 761 data.AddSetting(SETTINGS_MAX_CONCURRENT_STREAMS, 100); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov), | 1032 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov), |
| 1042 offset, fin, nullptr); | 1033 offset, fin, nullptr); |
| 1043 | 1034 |
| 1044 EXPECT_EQ(consumed_data.bytes_consumed, 0u); | 1035 EXPECT_EQ(consumed_data.bytes_consumed, 0u); |
| 1045 EXPECT_EQ(consumed_data.fin_consumed, false); | 1036 EXPECT_EQ(consumed_data.fin_consumed, false); |
| 1046 } | 1037 } |
| 1047 | 1038 |
| 1048 } // namespace | 1039 } // namespace |
| 1049 } // namespace test | 1040 } // namespace test |
| 1050 } // namespace net | 1041 } // namespace net |
| OLD | NEW |