Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 1399893005: relnote: Inline all frames smaller than a pointer into QuicFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Avoid_redundant_recvmmsg_104327020
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection_logger.cc ('k') | net/quic/quic_framer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 connection_.SetMaxPacketLength(1000); 1079 connection_.SetMaxPacketLength(1000);
1080 1080
1081 QuicPacketHeader header; 1081 QuicPacketHeader header;
1082 header.public_header.connection_id = connection_id_; 1082 header.public_header.connection_id = connection_id_;
1083 header.public_header.version_flag = true; 1083 header.public_header.version_flag = true;
1084 header.packet_packet_number = 1; 1084 header.packet_packet_number = 1;
1085 1085
1086 QuicFrames frames; 1086 QuicFrames frames;
1087 QuicPaddingFrame padding; 1087 QuicPaddingFrame padding;
1088 frames.push_back(QuicFrame(&frame1_)); 1088 frames.push_back(QuicFrame(&frame1_));
1089 frames.push_back(QuicFrame(&padding)); 1089 frames.push_back(QuicFrame(padding));
1090 scoped_ptr<QuicPacket> packet(ConstructPacket(header, frames)); 1090 scoped_ptr<QuicPacket> packet(ConstructPacket(header, frames));
1091 char buffer[kMaxPacketSize]; 1091 char buffer[kMaxPacketSize];
1092 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPayload( 1092 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPayload(
1093 ENCRYPTION_NONE, 12, *packet, buffer, kMaxPacketSize)); 1093 ENCRYPTION_NONE, 12, *packet, buffer, kMaxPacketSize));
1094 EXPECT_EQ(kMaxPacketSize, encrypted->length()); 1094 EXPECT_EQ(kMaxPacketSize, encrypted->length());
1095 1095
1096 framer_.set_version(version()); 1096 framer_.set_version(version());
1097 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 1097 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
1098 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted); 1098 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted);
1099 1099
(...skipping 10 matching lines...) Expand all
1110 EXPECT_EQ(1000u, connection_.max_packet_length()); 1110 EXPECT_EQ(1000u, connection_.max_packet_length());
1111 1111
1112 QuicPacketHeader header; 1112 QuicPacketHeader header;
1113 header.public_header.connection_id = connection_id_; 1113 header.public_header.connection_id = connection_id_;
1114 header.public_header.version_flag = true; 1114 header.public_header.version_flag = true;
1115 header.packet_packet_number = 1; 1115 header.packet_packet_number = 1;
1116 1116
1117 QuicFrames frames; 1117 QuicFrames frames;
1118 QuicPaddingFrame padding; 1118 QuicPaddingFrame padding;
1119 frames.push_back(QuicFrame(&frame1_)); 1119 frames.push_back(QuicFrame(&frame1_));
1120 frames.push_back(QuicFrame(&padding)); 1120 frames.push_back(QuicFrame(padding));
1121 scoped_ptr<QuicPacket> packet(ConstructPacket(header, frames)); 1121 scoped_ptr<QuicPacket> packet(ConstructPacket(header, frames));
1122 char buffer[kMaxPacketSize]; 1122 char buffer[kMaxPacketSize];
1123 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPayload( 1123 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPayload(
1124 ENCRYPTION_NONE, 12, *packet, buffer, kMaxPacketSize)); 1124 ENCRYPTION_NONE, 12, *packet, buffer, kMaxPacketSize));
1125 EXPECT_EQ(kMaxPacketSize, encrypted->length()); 1125 EXPECT_EQ(kMaxPacketSize, encrypted->length());
1126 1126
1127 framer_.set_version(version()); 1127 framer_.set_version(version());
1128 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 1128 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
1129 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted); 1129 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted);
1130 1130
(...skipping 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after
4016 EXPECT_CALL(visitor_, OnWindowUpdateFrame(_)); 4016 EXPECT_CALL(visitor_, OnWindowUpdateFrame(_));
4017 ProcessFramePacket(QuicFrame(&window_update)); 4017 ProcessFramePacket(QuicFrame(&window_update));
4018 } 4018 }
4019 4019
4020 TEST_P(QuicConnectionTest, Blocked) { 4020 TEST_P(QuicConnectionTest, Blocked) {
4021 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4021 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4022 4022
4023 QuicBlockedFrame blocked; 4023 QuicBlockedFrame blocked;
4024 blocked.stream_id = 3; 4024 blocked.stream_id = 3;
4025 EXPECT_CALL(visitor_, OnBlockedFrame(_)); 4025 EXPECT_CALL(visitor_, OnBlockedFrame(_));
4026 ProcessFramePacket(QuicFrame(&blocked)); 4026 ProcessFramePacket(QuicFrame(blocked));
4027 } 4027 }
4028 4028
4029 TEST_P(QuicConnectionTest, ZeroBytePacket) { 4029 TEST_P(QuicConnectionTest, ZeroBytePacket) {
4030 // Don't close the connection for zero byte packets. 4030 // Don't close the connection for zero byte packets.
4031 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(0); 4031 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(0);
4032 QuicEncryptedPacket encrypted(nullptr, 0); 4032 QuicEncryptedPacket encrypted(nullptr, 0);
4033 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, encrypted); 4033 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, encrypted);
4034 } 4034 }
4035 4035
4036 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { 4036 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) {
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 4763
4764 // Ensure that this has caused the ACK alarm to be set. 4764 // Ensure that this has caused the ACK alarm to be set.
4765 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 4765 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
4766 EXPECT_TRUE(ack_alarm->IsSet()); 4766 EXPECT_TRUE(ack_alarm->IsSet());
4767 4767
4768 // Cancel alarm, and try again with BLOCKED frame. 4768 // Cancel alarm, and try again with BLOCKED frame.
4769 ack_alarm->Cancel(); 4769 ack_alarm->Cancel();
4770 QuicBlockedFrame blocked; 4770 QuicBlockedFrame blocked;
4771 blocked.stream_id = 3; 4771 blocked.stream_id = 3;
4772 EXPECT_CALL(visitor_, OnBlockedFrame(_)); 4772 EXPECT_CALL(visitor_, OnBlockedFrame(_));
4773 ProcessFramePacket(QuicFrame(&blocked)); 4773 ProcessFramePacket(QuicFrame(blocked));
4774 EXPECT_TRUE(ack_alarm->IsSet()); 4774 EXPECT_TRUE(ack_alarm->IsSet());
4775 } 4775 }
4776 4776
4777 TEST_P(QuicConnectionTest, NoDataNoFin) { 4777 TEST_P(QuicConnectionTest, NoDataNoFin) {
4778 // Make sure that a call to SendStreamWithData, with no data and no FIN, does 4778 // Make sure that a call to SendStreamWithData, with no data and no FIN, does
4779 // not result in a QuicAckNotifier being used-after-free (fail under ASAN). 4779 // not result in a QuicAckNotifier being used-after-free (fail under ASAN).
4780 // Regression test for b/18594622 4780 // Regression test for b/18594622
4781 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 4781 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
4782 EXPECT_DFATAL( 4782 EXPECT_DFATAL(
4783 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), 4783 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4826 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 4826 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
4827 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4827 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4828 EXPECT_TRUE(connection_.goaway_sent()); 4828 EXPECT_TRUE(connection_.goaway_sent());
4829 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 4829 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
4830 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4830 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4831 } 4831 }
4832 4832
4833 } // namespace 4833 } // namespace
4834 } // namespace test 4834 } // namespace test
4835 } // namespace net 4835 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_logger.cc ('k') | net/quic/quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698