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

Side by Side Diff: net/quic/quic_protocol.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_protocol.h ('k') | no next file » | 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_protocol.h" 5 #include "net/quic/quic_protocol.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 byte_offset(bytes_written) { 259 byte_offset(bytes_written) {
260 DCHECK_LE(error_code, numeric_limits<uint8>::max()); 260 DCHECK_LE(error_code, numeric_limits<uint8>::max());
261 } 261 }
262 262
263 QuicConnectionCloseFrame::QuicConnectionCloseFrame() 263 QuicConnectionCloseFrame::QuicConnectionCloseFrame()
264 : error_code(QUIC_NO_ERROR) { 264 : error_code(QUIC_NO_ERROR) {
265 } 265 }
266 266
267 QuicFrame::QuicFrame() {} 267 QuicFrame::QuicFrame() {}
268 268
269 QuicFrame::QuicFrame(QuicPaddingFrame* padding_frame) 269 QuicFrame::QuicFrame(QuicPaddingFrame padding_frame)
270 : type(PADDING_FRAME), 270 : type(PADDING_FRAME), padding_frame(padding_frame) {}
271 padding_frame(padding_frame) {
272 }
273 271
274 QuicFrame::QuicFrame(QuicStreamFrame* stream_frame) 272 QuicFrame::QuicFrame(QuicStreamFrame* stream_frame)
275 : type(STREAM_FRAME), 273 : type(STREAM_FRAME), stream_frame(stream_frame) {}
276 stream_frame(stream_frame) {
277 }
278 274
279 QuicFrame::QuicFrame(QuicAckFrame* frame) 275 QuicFrame::QuicFrame(QuicAckFrame* frame) : type(ACK_FRAME), ack_frame(frame) {}
280 : type(ACK_FRAME),
281 ack_frame(frame) {
282 }
283 276
284 QuicFrame::QuicFrame(QuicMtuDiscoveryFrame* frame) 277 QuicFrame::QuicFrame(QuicMtuDiscoveryFrame frame)
285 : type(MTU_DISCOVERY_FRAME), mtu_discovery_frame(frame) { 278 : type(MTU_DISCOVERY_FRAME), mtu_discovery_frame(frame) {}
286 }
287 279
288 QuicFrame::QuicFrame(QuicStopWaitingFrame* frame) 280 QuicFrame::QuicFrame(QuicStopWaitingFrame* frame)
289 : type(STOP_WAITING_FRAME), 281 : type(STOP_WAITING_FRAME), stop_waiting_frame(frame) {}
290 stop_waiting_frame(frame) {
291 }
292 282
293 QuicFrame::QuicFrame(QuicPingFrame* frame) 283 QuicFrame::QuicFrame(QuicPingFrame frame)
294 : type(PING_FRAME), 284 : type(PING_FRAME), ping_frame(frame) {}
295 ping_frame(frame) {
296 }
297 285
298 QuicFrame::QuicFrame(QuicRstStreamFrame* frame) 286 QuicFrame::QuicFrame(QuicRstStreamFrame* frame)
299 : type(RST_STREAM_FRAME), 287 : type(RST_STREAM_FRAME), rst_stream_frame(frame) {}
300 rst_stream_frame(frame) {
301 }
302 288
303 QuicFrame::QuicFrame(QuicConnectionCloseFrame* frame) 289 QuicFrame::QuicFrame(QuicConnectionCloseFrame* frame)
304 : type(CONNECTION_CLOSE_FRAME), 290 : type(CONNECTION_CLOSE_FRAME), connection_close_frame(frame) {}
305 connection_close_frame(frame) {
306 }
307 291
308 QuicFrame::QuicFrame(QuicGoAwayFrame* frame) 292 QuicFrame::QuicFrame(QuicGoAwayFrame* frame)
309 : type(GOAWAY_FRAME), 293 : type(GOAWAY_FRAME), goaway_frame(frame) {}
310 goaway_frame(frame) {
311 }
312 294
313 QuicFrame::QuicFrame(QuicWindowUpdateFrame* frame) 295 QuicFrame::QuicFrame(QuicWindowUpdateFrame* frame)
314 : type(WINDOW_UPDATE_FRAME), 296 : type(WINDOW_UPDATE_FRAME), window_update_frame(frame) {}
315 window_update_frame(frame) {
316 }
317 297
318 QuicFrame::QuicFrame(QuicBlockedFrame* frame) 298 QuicFrame::QuicFrame(QuicBlockedFrame frame)
319 : type(BLOCKED_FRAME), 299 : type(BLOCKED_FRAME), blocked_frame(frame) {}
320 blocked_frame(frame) {
321 }
322 300
323 QuicFecData::QuicFecData() : fec_group(0) {} 301 QuicFecData::QuicFecData() : fec_group(0) {}
324 302
325 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) { 303 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) {
326 os << "entropy_hash: " << static_cast<int>(sent_info.entropy_hash) 304 os << "entropy_hash: " << static_cast<int>(sent_info.entropy_hash)
327 << " least_unacked: " << sent_info.least_unacked; 305 << " least_unacked: " << sent_info.least_unacked;
328 return os; 306 return os;
329 } 307 }
330 308
331 PacketNumberQueue::const_iterator::const_iterator( 309 PacketNumberQueue::const_iterator::const_iterator(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 586 }
609 case GOAWAY_FRAME: { 587 case GOAWAY_FRAME: {
610 os << "type { GOAWAY_FRAME } " << *(frame.goaway_frame); 588 os << "type { GOAWAY_FRAME } " << *(frame.goaway_frame);
611 break; 589 break;
612 } 590 }
613 case WINDOW_UPDATE_FRAME: { 591 case WINDOW_UPDATE_FRAME: {
614 os << "type { WINDOW_UPDATE_FRAME } " << *(frame.window_update_frame); 592 os << "type { WINDOW_UPDATE_FRAME } " << *(frame.window_update_frame);
615 break; 593 break;
616 } 594 }
617 case BLOCKED_FRAME: { 595 case BLOCKED_FRAME: {
618 os << "type { BLOCKED_FRAME } " << *(frame.blocked_frame); 596 os << "type { BLOCKED_FRAME } " << frame.blocked_frame;
619 break; 597 break;
620 } 598 }
621 case STREAM_FRAME: { 599 case STREAM_FRAME: {
622 os << "type { STREAM_FRAME } " << *(frame.stream_frame); 600 os << "type { STREAM_FRAME } " << *(frame.stream_frame);
623 break; 601 break;
624 } 602 }
625 case ACK_FRAME: { 603 case ACK_FRAME: {
626 os << "type { ACK_FRAME } " << *(frame.ack_frame); 604 os << "type { ACK_FRAME } " << *(frame.ack_frame);
627 break; 605 break;
628 } 606 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 length() - start_of_encrypted_data); 759 length() - start_of_encrypted_data);
782 } 760 }
783 761
784 RetransmittableFrames::RetransmittableFrames(EncryptionLevel level) 762 RetransmittableFrames::RetransmittableFrames(EncryptionLevel level)
785 : encryption_level_(level), 763 : encryption_level_(level),
786 has_crypto_handshake_(NOT_HANDSHAKE), 764 has_crypto_handshake_(NOT_HANDSHAKE),
787 needs_padding_(false) { 765 needs_padding_(false) {
788 } 766 }
789 767
790 RetransmittableFrames::~RetransmittableFrames() { 768 RetransmittableFrames::~RetransmittableFrames() {
791 for (QuicFrames::iterator it = frames_.begin(); it != frames_.end(); ++it) { 769 for (QuicFrame& frame : frames_) {
792 switch (it->type) { 770 switch (frame.type) {
771 // Frames smaller than a pointer are inlined, so don't need to be deleted.
793 case PADDING_FRAME: 772 case PADDING_FRAME:
794 delete it->padding_frame; 773 case MTU_DISCOVERY_FRAME:
774 case PING_FRAME:
775 case BLOCKED_FRAME:
795 break; 776 break;
796 case STREAM_FRAME: 777 case STREAM_FRAME:
797 delete it->stream_frame; 778 delete frame.stream_frame;
798 break; 779 break;
799 case ACK_FRAME: 780 case ACK_FRAME:
800 delete it->ack_frame; 781 delete frame.ack_frame;
801 break;
802 case MTU_DISCOVERY_FRAME:
803 delete it->mtu_discovery_frame;
804 break; 782 break;
805 case STOP_WAITING_FRAME: 783 case STOP_WAITING_FRAME:
806 delete it->stop_waiting_frame; 784 delete frame.stop_waiting_frame;
807 break;
808 case PING_FRAME:
809 delete it->ping_frame;
810 break; 785 break;
811 case RST_STREAM_FRAME: 786 case RST_STREAM_FRAME:
812 delete it->rst_stream_frame; 787 delete frame.rst_stream_frame;
813 break; 788 break;
814 case CONNECTION_CLOSE_FRAME: 789 case CONNECTION_CLOSE_FRAME:
815 delete it->connection_close_frame; 790 delete frame.connection_close_frame;
816 break; 791 break;
817 case GOAWAY_FRAME: 792 case GOAWAY_FRAME:
818 delete it->goaway_frame; 793 delete frame.goaway_frame;
819 break; 794 break;
820 case WINDOW_UPDATE_FRAME: 795 case WINDOW_UPDATE_FRAME:
821 delete it->window_update_frame; 796 delete frame.window_update_frame;
822 break;
823 case BLOCKED_FRAME:
824 delete it->blocked_frame;
825 break; 797 break;
826 case NUM_FRAME_TYPES: 798 case NUM_FRAME_TYPES:
827 DCHECK(false) << "Cannot delete type: " << it->type; 799 DCHECK(false) << "Cannot delete type: " << frame.type;
828 } 800 }
829 } 801 }
830 // TODO(rtenneti): Delete the for loop once chrome has c++11 library support 802 // TODO(rtenneti): Delete the for loop once chrome has c++11 library support
831 // for "std::vector<UniqueStreamBuffer> stream_data_;". 803 // for "std::vector<UniqueStreamBuffer> stream_data_;".
832 for (const char* buffer : stream_data_) { 804 for (const char* buffer : stream_data_) {
833 delete[] buffer; 805 delete[] buffer;
834 } 806 }
835 } 807 }
836 808
837 const QuicFrame& RetransmittableFrames::AddFrame(const QuicFrame& frame) { 809 const QuicFrame& RetransmittableFrames::AddFrame(const QuicFrame& frame) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 bytes_sent(bytes_sent), 889 bytes_sent(bytes_sent),
918 nack_count(0), 890 nack_count(0),
919 sent_time(sent_time), 891 sent_time(sent_time),
920 transmission_type(transmission_type), 892 transmission_type(transmission_type),
921 in_flight(false), 893 in_flight(false),
922 is_unackable(false), 894 is_unackable(false),
923 is_fec_packet(is_fec_packet), 895 is_fec_packet(is_fec_packet),
924 all_transmissions(nullptr) {} 896 all_transmissions(nullptr) {}
925 897
926 } // namespace net 898 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698