| 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 5130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5141 frame1_.stream_id = 10; | 5141 frame1_.stream_id = 10; |
| 5142 frame1_.data_buffer = data->data(); | 5142 frame1_.data_buffer = data->data(); |
| 5143 frame1_.data_length = data->length(); | 5143 frame1_.data_length = data->length(); |
| 5144 | 5144 |
| 5145 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, | 5145 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
| 5146 ConnectionCloseSource::FROM_SELF)); | 5146 ConnectionCloseSource::FROM_SELF)); |
| 5147 ForceProcessFramePacket(QuicFrame(&frame1_)); | 5147 ForceProcessFramePacket(QuicFrame(&frame1_)); |
| 5148 } | 5148 } |
| 5149 | 5149 |
| 5150 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { | 5150 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { |
| 5151 FLAGS_quic_close_connection_on_packet_too_large = true; | |
| 5152 SimulateNextPacketTooLarge(); | 5151 SimulateNextPacketTooLarge(); |
| 5153 // Although the data packet cannot be written, the send packet manager is | 5152 // Although the data packet cannot be written, the send packet manager is |
| 5154 // informed. Also a connection close packet is sent. | 5153 // informed. Also a connection close packet is sent. |
| 5155 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 5154 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
| 5156 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, | 5155 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, |
| 5157 ConnectionCloseSource::FROM_SELF)) | 5156 ConnectionCloseSource::FROM_SELF)) |
| 5158 .Times(1); | 5157 .Times(1); |
| 5159 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5158 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5160 } | 5159 } |
| 5161 | 5160 |
| 5162 TEST_P(QuicConnectionTest, AlwaysGetPacketTooLarge) { | 5161 TEST_P(QuicConnectionTest, AlwaysGetPacketTooLarge) { |
| 5163 // Test even we always get packet too large, we do not infinitely try to send | 5162 // Test even we always get packet too large, we do not infinitely try to send |
| 5164 // close packet. | 5163 // close packet. |
| 5165 FLAGS_quic_close_connection_on_packet_too_large = true; | |
| 5166 AlwaysGetPacketTooLarge(); | 5164 AlwaysGetPacketTooLarge(); |
| 5167 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 5165 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
| 5168 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, | 5166 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, |
| 5169 ConnectionCloseSource::FROM_SELF)) | 5167 ConnectionCloseSource::FROM_SELF)) |
| 5170 .Times(1); | 5168 .Times(1); |
| 5171 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5169 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5172 } | 5170 } |
| 5173 | 5171 |
| 5174 // Verify that if connection has no outstanding data, it notifies the send | 5172 // Verify that if connection has no outstanding data, it notifies the send |
| 5175 // algorithm after the write. | 5173 // algorithm after the write. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5224 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5222 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5225 EXPECT_EQ(1u, writer_->frame_count()); | 5223 EXPECT_EQ(1u, writer_->frame_count()); |
| 5226 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5224 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
| 5227 // Ack frame is not bundled in connection close packet. | 5225 // Ack frame is not bundled in connection close packet. |
| 5228 EXPECT_TRUE(writer_->ack_frames().empty()); | 5226 EXPECT_TRUE(writer_->ack_frames().empty()); |
| 5229 } | 5227 } |
| 5230 | 5228 |
| 5231 } // namespace | 5229 } // namespace |
| 5232 } // namespace test | 5230 } // namespace test |
| 5233 } // namespace net | 5231 } // namespace net |
| OLD | NEW |