| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "net/quic/core/quic_flags.h" | 13 #include "net/quic/core/quic_flags.h" |
| 14 #include "net/quic/core/quic_utils.h" | 14 #include "net/quic/core/quic_utils.h" |
| 15 #include "net/quic/core/spdy_utils.h" | 15 #include "net/quic/core/spdy_utils.h" |
| 16 #include "net/quic/platform/api/quic_bug_tracker.h" | 16 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 17 #include "net/quic/platform/api/quic_logging.h" |
| 17 #include "net/quic/platform/api/quic_str_cat.h" | 18 #include "net/quic/platform/api/quic_str_cat.h" |
| 18 #include "net/quic/test_tools/quic_connection_peer.h" | 19 #include "net/quic/test_tools/quic_connection_peer.h" |
| 19 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 20 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 20 #include "net/quic/test_tools/quic_stream_peer.h" | 21 #include "net/quic/test_tools/quic_stream_peer.h" |
| 21 #include "net/quic/test_tools/quic_test_utils.h" | 22 #include "net/quic/test_tools/quic_test_utils.h" |
| 22 #include "net/spdy/spdy_alt_svc_wire_format.h" | 23 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 23 #include "net/spdy/spdy_flags.h" | 24 #include "net/spdy/spdy_flags.h" |
| 24 #include "net/spdy/spdy_protocol.h" | 25 #include "net/spdy/spdy_protocol.h" |
| 25 #include "net/spdy/spdy_test_utils.h" | 26 #include "net/spdy/spdy_test_utils.h" |
| 26 #include "net/test/gtest_util.h" | 27 #include "net/test/gtest_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 switch (hpack_decoder) { | 194 switch (hpack_decoder) { |
| 194 case HPACK_DECODER_SPDY: | 195 case HPACK_DECODER_SPDY: |
| 195 FLAGS_spdy_use_hpack_decoder2 = false; | 196 FLAGS_spdy_use_hpack_decoder2 = false; |
| 196 break; | 197 break; |
| 197 case HPACK_DECODER_NEW: | 198 case HPACK_DECODER_NEW: |
| 198 FLAGS_spdy_use_hpack_decoder2 = true; | 199 FLAGS_spdy_use_hpack_decoder2 = true; |
| 199 // Needs new header methods to be used. | 200 // Needs new header methods to be used. |
| 200 FLAGS_spdy_framer_use_new_methods4 = true; | 201 FLAGS_spdy_framer_use_new_methods4 = true; |
| 201 break; | 202 break; |
| 202 } | 203 } |
| 203 VLOG(1) << "TestParams: version: " << QuicVersionToString(version) | 204 QUIC_LOG(INFO) << "TestParams: version: " << QuicVersionToString(version) |
| 204 << ", perspective: " << perspective | 205 << ", perspective: " << perspective |
| 205 << ", http2_decoder: " << http2_decoder | 206 << ", http2_decoder: " << http2_decoder |
| 206 << ", hpack_decoder: " << hpack_decoder; | 207 << ", hpack_decoder: " << hpack_decoder; |
| 207 } | 208 } |
| 208 | 209 |
| 209 QuicVersion version; | 210 QuicVersion version; |
| 210 Perspective perspective; | 211 Perspective perspective; |
| 211 Http2DecoderChoice http2_decoder; | 212 Http2DecoderChoice http2_decoder; |
| 212 HpackDecoderChoice hpack_decoder; | 213 HpackDecoderChoice hpack_decoder; |
| 213 }; | 214 }; |
| 214 | 215 |
| 215 class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParamsTuple> { | 216 class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParamsTuple> { |
| 216 public: | 217 public: |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 EXPECT_CALL(session_, OnStreamHeadersPriority(stream_id, 0)).Times(1); | 603 EXPECT_CALL(session_, OnStreamHeadersPriority(stream_id, 0)).Times(1); |
| 603 } else { | 604 } else { |
| 604 SpdyHeadersIR headers_frame(stream_id, headers_.Clone()); | 605 SpdyHeadersIR headers_frame(stream_id, headers_.Clone()); |
| 605 headers_frame.set_fin(fin); | 606 headers_frame.set_fin(fin); |
| 606 frames[stream_num] = framer_->SerializeFrame(headers_frame); | 607 frames[stream_num] = framer_->SerializeFrame(headers_frame); |
| 607 } | 608 } |
| 608 stream_frames[stream_num].stream_id = stream_frame_.stream_id; | 609 stream_frames[stream_num].stream_id = stream_frame_.stream_id; |
| 609 stream_frames[stream_num].offset = stream_frame_.offset; | 610 stream_frames[stream_num].offset = stream_frame_.offset; |
| 610 stream_frames[stream_num].data_buffer = frames[stream_num].data(); | 611 stream_frames[stream_num].data_buffer = frames[stream_num].data(); |
| 611 stream_frames[stream_num].data_length = frames[stream_num].size(); | 612 stream_frames[stream_num].data_length = frames[stream_num].size(); |
| 612 DVLOG(1) << "make frame for stream " << stream_num << " offset " | 613 QUIC_DVLOG(1) << "make frame for stream " << stream_num << " offset " |
| 613 << stream_frames[stream_num].offset; | 614 << stream_frames[stream_num].offset; |
| 614 stream_frame_.offset += frames[stream_num].size(); | 615 stream_frame_.offset += frames[stream_num].size(); |
| 615 EXPECT_CALL(session_, OnStreamHeaderList(stream_id, fin, _, _)).Times(1); | 616 EXPECT_CALL(session_, OnStreamHeaderList(stream_id, fin, _, _)).Times(1); |
| 616 } | 617 } |
| 617 } | 618 } |
| 618 | 619 |
| 619 // Actually writing the frames in reverse order will cause HOL blocking. | 620 // Actually writing the frames in reverse order will cause HOL blocking. |
| 620 EXPECT_CALL(session_, OnHeadersHeadOfLineBlocking(_)).Times(9); | 621 EXPECT_CALL(session_, OnHeadersHeadOfLineBlocking(_)).Times(9); |
| 621 | 622 |
| 622 for (int stream_num = 9; stream_num >= 0; --stream_num) { | 623 for (int stream_num = 9; stream_num >= 0; --stream_num) { |
| 623 DVLOG(1) << "OnStreamFrame for stream " << stream_num << " offset " | 624 QUIC_DVLOG(1) << "OnStreamFrame for stream " << stream_num << " offset " |
| 624 << stream_frames[stream_num].offset; | 625 << stream_frames[stream_num].offset; |
| 625 headers_stream_->OnStreamFrame(stream_frames[stream_num]); | 626 headers_stream_->OnStreamFrame(stream_frames[stream_num]); |
| 626 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 627 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 627 } | 628 } |
| 628 } | 629 } |
| 629 | 630 |
| 630 TEST_P(QuicHeadersStreamTest, ProcessLargeRawData) { | 631 TEST_P(QuicHeadersStreamTest, ProcessLargeRawData) { |
| 631 QuicSpdySessionPeer::SetMaxUncompressedHeaderBytes(&session_, 256 * 1024); | 632 QuicSpdySessionPeer::SetMaxUncompressedHeaderBytes(&session_, 256 * 1024); |
| 632 // We want to create a frame that is more than the SPDY Framer's max control | 633 // We want to create a frame that is more than the SPDY Framer's max control |
| 633 // frame size, which is 16K, but less than the HPACK decoders max decode | 634 // frame size, which is 16K, but less than the HPACK decoders max decode |
| 634 // buffer size, which is 32K. | 635 // buffer size, which is 32K. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov), | 1044 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov), |
| 1044 offset, fin, nullptr); | 1045 offset, fin, nullptr); |
| 1045 | 1046 |
| 1046 EXPECT_EQ(consumed_data.bytes_consumed, 0u); | 1047 EXPECT_EQ(consumed_data.bytes_consumed, 0u); |
| 1047 EXPECT_EQ(consumed_data.fin_consumed, false); | 1048 EXPECT_EQ(consumed_data.fin_consumed, false); |
| 1048 } | 1049 } |
| 1049 | 1050 |
| 1050 } // namespace | 1051 } // namespace |
| 1051 } // namespace test | 1052 } // namespace test |
| 1052 } // namespace net | 1053 } // namespace net |
| OLD | NEW |