| 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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 // Sets the amount of time that the writer should before the actual write. | 363 // Sets the amount of time that the writer should before the actual write. |
| 364 void SetWritePauseTimeDelta(QuicTime::Delta delta) { | 364 void SetWritePauseTimeDelta(QuicTime::Delta delta) { |
| 365 write_pause_time_delta_ = delta; | 365 write_pause_time_delta_ = delta; |
| 366 } | 366 } |
| 367 | 367 |
| 368 const QuicPacketHeader& header() { return framer_.header(); } | 368 const QuicPacketHeader& header() { return framer_.header(); } |
| 369 | 369 |
| 370 size_t frame_count() const { return framer_.num_frames(); } | 370 size_t frame_count() const { return framer_.num_frames(); } |
| 371 | 371 |
| 372 const vector<QuicAckFrame>& ack_frames() const { | 372 const std::vector<QuicAckFrame>& ack_frames() const { |
| 373 return framer_.ack_frames(); | 373 return framer_.ack_frames(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const { | 376 const std::vector<QuicStopWaitingFrame>& stop_waiting_frames() const { |
| 377 return framer_.stop_waiting_frames(); | 377 return framer_.stop_waiting_frames(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { | 380 const std::vector<QuicConnectionCloseFrame>& connection_close_frames() const { |
| 381 return framer_.connection_close_frames(); | 381 return framer_.connection_close_frames(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 const vector<QuicRstStreamFrame>& rst_stream_frames() const { | 384 const std::vector<QuicRstStreamFrame>& rst_stream_frames() const { |
| 385 return framer_.rst_stream_frames(); | 385 return framer_.rst_stream_frames(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 const vector<std::unique_ptr<QuicStreamFrame>>& stream_frames() const { | 388 const std::vector<std::unique_ptr<QuicStreamFrame>>& stream_frames() const { |
| 389 return framer_.stream_frames(); | 389 return framer_.stream_frames(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 const vector<QuicPingFrame>& ping_frames() const { | 392 const std::vector<QuicPingFrame>& ping_frames() const { |
| 393 return framer_.ping_frames(); | 393 return framer_.ping_frames(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 size_t last_packet_size() { return last_packet_size_; } | 396 size_t last_packet_size() { return last_packet_size_; } |
| 397 | 397 |
| 398 const QuicVersionNegotiationPacket* version_negotiation_packet() { | 398 const QuicVersionNegotiationPacket* version_negotiation_packet() { |
| 399 return framer_.version_negotiation_packet(); | 399 return framer_.version_negotiation_packet(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void set_is_write_blocked_data_buffered(bool buffered) { | 402 void set_is_write_blocked_data_buffered(bool buffered) { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 << (p.ack_response == AckResponse::kDefer ? "defer" : "immediate") | 657 << (p.ack_response == AckResponse::kDefer ? "defer" : "immediate") |
| 658 << " }"; | 658 << " }"; |
| 659 return os; | 659 return os; |
| 660 } | 660 } |
| 661 | 661 |
| 662 QuicVersion version; | 662 QuicVersion version; |
| 663 AckResponse ack_response; | 663 AckResponse ack_response; |
| 664 }; | 664 }; |
| 665 | 665 |
| 666 // Constructs various test permutations. | 666 // Constructs various test permutations. |
| 667 vector<TestParams> GetTestParams() { | 667 std::vector<TestParams> GetTestParams() { |
| 668 vector<TestParams> params; | 668 std::vector<TestParams> params; |
| 669 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 669 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
| 670 for (size_t i = 0; i < all_supported_versions.size(); ++i) { | 670 for (size_t i = 0; i < all_supported_versions.size(); ++i) { |
| 671 for (AckResponse ack_response : | 671 for (AckResponse ack_response : |
| 672 {AckResponse::kDefer, AckResponse::kImmediate}) { | 672 {AckResponse::kDefer, AckResponse::kImmediate}) { |
| 673 params.push_back(TestParams(all_supported_versions[i], ack_response)); | 673 params.push_back(TestParams(all_supported_versions[i], ack_response)); |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 return params; | 676 return params; |
| 677 } | 677 } |
| 678 | 678 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 | 1421 |
| 1422 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) { | 1422 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) { |
| 1423 // Process an unencrypted packet from the non-crypto stream. | 1423 // Process an unencrypted packet from the non-crypto stream. |
| 1424 frame1_.stream_id = 3; | 1424 frame1_.stream_id = 3; |
| 1425 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1425 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1426 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, _, | 1426 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, _, |
| 1427 ConnectionCloseSource::FROM_SELF)); | 1427 ConnectionCloseSource::FROM_SELF)); |
| 1428 EXPECT_QUIC_BUG(ProcessDataPacket(kDefaultPathId, 1, !kEntropyFlag), ""); | 1428 EXPECT_QUIC_BUG(ProcessDataPacket(kDefaultPathId, 1, !kEntropyFlag), ""); |
| 1429 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == | 1429 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == |
| 1430 nullptr); | 1430 nullptr); |
| 1431 const vector<QuicConnectionCloseFrame>& connection_close_frames = | 1431 const std::vector<QuicConnectionCloseFrame>& connection_close_frames = |
| 1432 writer_->connection_close_frames(); | 1432 writer_->connection_close_frames(); |
| 1433 EXPECT_EQ(1u, connection_close_frames.size()); | 1433 EXPECT_EQ(1u, connection_close_frames.size()); |
| 1434 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA, | 1434 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA, |
| 1435 connection_close_frames[0].error_code); | 1435 connection_close_frames[0].error_code); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 TEST_P(QuicConnectionTest, TruncatedAck) { | 1438 TEST_P(QuicConnectionTest, TruncatedAck) { |
| 1439 if (GetParam().version > QUIC_VERSION_33) { | 1439 if (GetParam().version > QUIC_VERSION_33) { |
| 1440 return; | 1440 return; |
| 1441 } | 1441 } |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 QuicConnectionPeer::SetPacketsBetweenMtuProbes(&connection_, | 3111 QuicConnectionPeer::SetPacketsBetweenMtuProbes(&connection_, |
| 3112 packets_between_probes_base); | 3112 packets_between_probes_base); |
| 3113 QuicConnectionPeer::SetNextMtuProbeAt(&connection_, | 3113 QuicConnectionPeer::SetNextMtuProbeAt(&connection_, |
| 3114 packets_between_probes_base); | 3114 packets_between_probes_base); |
| 3115 | 3115 |
| 3116 // This tests sends more packets than strictly necessary to make sure that if | 3116 // This tests sends more packets than strictly necessary to make sure that if |
| 3117 // the connection was to send more discovery packets than needed, those would | 3117 // the connection was to send more discovery packets than needed, those would |
| 3118 // get caught as well. | 3118 // get caught as well. |
| 3119 const QuicPacketCount number_of_packets = | 3119 const QuicPacketCount number_of_packets = |
| 3120 packets_between_probes_base * (1 << (kMtuDiscoveryAttempts + 1)); | 3120 packets_between_probes_base * (1 << (kMtuDiscoveryAttempts + 1)); |
| 3121 vector<QuicPacketNumber> mtu_discovery_packets; | 3121 std::vector<QuicPacketNumber> mtu_discovery_packets; |
| 3122 // Called by the first ack. | 3122 // Called by the first ack. |
| 3123 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3123 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3124 // Called on many acks. | 3124 // Called on many acks. |
| 3125 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)) | 3125 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)) |
| 3126 .Times(AnyNumber()); | 3126 .Times(AnyNumber()); |
| 3127 for (QuicPacketCount i = 0; i < number_of_packets; i++) { | 3127 for (QuicPacketCount i = 0; i < number_of_packets; i++) { |
| 3128 SendStreamDataToPeer(3, "!", i, /*fin=*/false, nullptr); | 3128 SendStreamDataToPeer(3, "!", i, /*fin=*/false, nullptr); |
| 3129 clock_.AdvanceTime(rtt); | 3129 clock_.AdvanceTime(rtt); |
| 3130 | 3130 |
| 3131 // Receive an ACK, which marks all data packets as received, and all MTU | 3131 // Receive an ACK, which marks all data packets as received, and all MTU |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5313 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5313 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5314 EXPECT_EQ(1u, writer_->frame_count()); | 5314 EXPECT_EQ(1u, writer_->frame_count()); |
| 5315 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5315 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
| 5316 // Ack frame is not bundled in connection close packet. | 5316 // Ack frame is not bundled in connection close packet. |
| 5317 EXPECT_TRUE(writer_->ack_frames().empty()); | 5317 EXPECT_TRUE(writer_->ack_frames().empty()); |
| 5318 } | 5318 } |
| 5319 | 5319 |
| 5320 } // namespace | 5320 } // namespace |
| 5321 } // namespace test | 5321 } // namespace test |
| 5322 } // namespace net | 5322 } // namespace net |
| OLD | NEW |