Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 return maker_.MakeResponseHeadersPacket( | 256 return maker_.MakeResponseHeadersPacket( |
| 257 sequence_number, stream_id_, !kIncludeVersion, fin, response_headers_); | 257 sequence_number, stream_id_, !kIncludeVersion, fin, response_headers_); |
| 258 } | 258 } |
| 259 | 259 |
| 260 scoped_ptr<QuicEncryptedPacket> ConstructRstStreamPacket( | 260 scoped_ptr<QuicEncryptedPacket> ConstructRstStreamPacket( |
| 261 QuicPacketSequenceNumber sequence_number) { | 261 QuicPacketSequenceNumber sequence_number) { |
| 262 return maker_.MakeRstPacket( | 262 return maker_.MakeRstPacket( |
| 263 sequence_number, !kIncludeVersion, stream_id_, QUIC_STREAM_CANCELLED); | 263 sequence_number, !kIncludeVersion, stream_id_, QUIC_STREAM_CANCELLED); |
| 264 } | 264 } |
| 265 | 265 |
| 266 scoped_ptr<QuicEncryptedPacket> ConstructAckAndRstStreamPacket( | |
| 267 QuicPacketSequenceNumber sequence_number, | |
|
Ryan Hamilton
2014/01/29 00:52:52
nit: Since the final 2 args are always 1, I'd remo
ramant (doing other things)
2014/01/29 02:45:38
Done.
| |
| 268 QuicPacketSequenceNumber largest_received, | |
| 269 QuicPacketSequenceNumber least_unacked) { | |
| 270 return maker_.MakeAckAndRstPacket( | |
| 271 sequence_number, !kIncludeVersion, stream_id_, QUIC_STREAM_CANCELLED, | |
| 272 largest_received, least_unacked, !kIncludeCongestionFeedback); | |
| 273 } | |
| 274 | |
| 266 scoped_ptr<QuicEncryptedPacket> ConstructAckPacket( | 275 scoped_ptr<QuicEncryptedPacket> ConstructAckPacket( |
| 267 QuicPacketSequenceNumber sequence_number, | 276 QuicPacketSequenceNumber sequence_number, |
| 268 QuicPacketSequenceNumber largest_received, | 277 QuicPacketSequenceNumber largest_received, |
| 269 QuicPacketSequenceNumber least_unacked) { | 278 QuicPacketSequenceNumber least_unacked) { |
| 270 return maker_.MakeAckPacket(sequence_number, largest_received, | 279 return maker_.MakeAckPacket(sequence_number, largest_received, |
| 271 least_unacked, !kIncludeCongestionFeedback); | 280 least_unacked, !kIncludeCongestionFeedback); |
| 272 } | 281 } |
| 273 | 282 |
| 274 BoundNetLog net_log_; | 283 BoundNetLog net_log_; |
| 275 bool use_closing_stream_; | 284 bool use_closing_stream_; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 EXPECT_TRUE(AtEof()); | 613 EXPECT_TRUE(AtEof()); |
| 605 } | 614 } |
| 606 | 615 |
| 607 TEST_P(QuicHttpStreamTest, DestroyedEarly) { | 616 TEST_P(QuicHttpStreamTest, DestroyedEarly) { |
| 608 SetRequest("GET", "/", DEFAULT_PRIORITY); | 617 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 609 if (GetParam() > QUIC_VERSION_12) { | 618 if (GetParam() > QUIC_VERSION_12) { |
| 610 AddWrite(ConstructRequestHeadersPacket(1, kFin)); | 619 AddWrite(ConstructRequestHeadersPacket(1, kFin)); |
| 611 } else { | 620 } else { |
| 612 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); | 621 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); |
| 613 } | 622 } |
| 614 AddWrite(ConstructRstStreamPacket(2)); | 623 AddWrite(ConstructAckAndRstStreamPacket(2, 1, 1)); |
| 615 use_closing_stream_ = true; | 624 use_closing_stream_ = true; |
| 616 Initialize(); | 625 Initialize(); |
| 617 | 626 |
| 618 request_.method = "GET"; | 627 request_.method = "GET"; |
| 619 request_.url = GURL("http://www.google.com/"); | 628 request_.url = GURL("http://www.google.com/"); |
| 620 | 629 |
| 621 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 630 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 622 net_log_, callback_.callback())); | 631 net_log_, callback_.callback())); |
| 623 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 632 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
| 624 callback_.callback())); | 633 callback_.callback())); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 641 EXPECT_TRUE(AtEof()); | 650 EXPECT_TRUE(AtEof()); |
| 642 } | 651 } |
| 643 | 652 |
| 644 TEST_P(QuicHttpStreamTest, Priority) { | 653 TEST_P(QuicHttpStreamTest, Priority) { |
| 645 SetRequest("GET", "/", MEDIUM); | 654 SetRequest("GET", "/", MEDIUM); |
| 646 if (GetParam() > QUIC_VERSION_12) { | 655 if (GetParam() > QUIC_VERSION_12) { |
| 647 AddWrite(ConstructRequestHeadersPacket(1, kFin)); | 656 AddWrite(ConstructRequestHeadersPacket(1, kFin)); |
| 648 } else { | 657 } else { |
| 649 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); | 658 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); |
| 650 } | 659 } |
| 651 AddWrite(ConstructRstStreamPacket(2)); | 660 AddWrite(ConstructAckAndRstStreamPacket(2, 1, 1)); |
| 652 use_closing_stream_ = true; | 661 use_closing_stream_ = true; |
| 653 Initialize(); | 662 Initialize(); |
| 654 | 663 |
| 655 request_.method = "GET"; | 664 request_.method = "GET"; |
| 656 request_.url = GURL("http://www.google.com/"); | 665 request_.url = GURL("http://www.google.com/"); |
| 657 | 666 |
| 658 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, | 667 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, |
| 659 net_log_, callback_.callback())); | 668 net_log_, callback_.callback())); |
| 660 | 669 |
| 661 // Check that priority is highest. | 670 // Check that priority is highest. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 WillRepeatedly(Return(QuicTime::Delta::Zero())); | 759 WillRepeatedly(Return(QuicTime::Delta::Zero())); |
| 751 | 760 |
| 752 // Data should flush out now. | 761 // Data should flush out now. |
| 753 connection_->OnCanWrite(); | 762 connection_->OnCanWrite(); |
| 754 EXPECT_FALSE(reliable_stream->HasBufferedData()); | 763 EXPECT_FALSE(reliable_stream->HasBufferedData()); |
| 755 EXPECT_TRUE(AtEof()); | 764 EXPECT_TRUE(AtEof()); |
| 756 } | 765 } |
| 757 | 766 |
| 758 } // namespace test | 767 } // namespace test |
| 759 } // namespace net | 768 } // namespace net |
| OLD | NEW |