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_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
10 #include "net/quic/quic_ack_notifier.h" | 10 #include "net/quic/quic_ack_notifier.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 queued_frames_.push_back( | 495 queued_frames_.push_back( |
496 queued_retransmittable_frames_->AddNonStreamFrame(frame)); | 496 queued_retransmittable_frames_->AddNonStreamFrame(frame)); |
497 } | 497 } |
498 } else { | 498 } else { |
499 queued_frames_.push_back(frame); | 499 queued_frames_.push_back(frame); |
500 } | 500 } |
501 return true; | 501 return true; |
502 } | 502 } |
503 | 503 |
504 void QuicPacketCreator::MaybeAddPadding() { | 504 void QuicPacketCreator::MaybeAddPadding() { |
| 505 if (queued_retransmittable_frames_.get() == NULL) { |
| 506 return; |
| 507 } |
| 508 if (!queued_retransmittable_frames_->HasCryptoHandshake()) { |
| 509 return; |
| 510 } |
505 if (BytesFree() == 0) { | 511 if (BytesFree() == 0) { |
506 // Don't pad full packets. | 512 // Don't pad full packets. |
507 return; | 513 return; |
508 } | 514 } |
509 | |
510 // If any of the frames in the current packet are on the crypto stream | |
511 // then they contain handshake messagses, and we should pad them. | |
512 bool is_handshake = false; | |
513 for (size_t i = 0; i < queued_frames_.size(); ++i) { | |
514 if (queued_frames_[i].type == STREAM_FRAME && | |
515 queued_frames_[i].stream_frame->stream_id == kCryptoStreamId) { | |
516 is_handshake = true; | |
517 break; | |
518 } | |
519 } | |
520 if (!is_handshake) { | |
521 return; | |
522 } | |
523 | |
524 QuicPaddingFrame padding; | 515 QuicPaddingFrame padding; |
525 bool success = AddFrame(QuicFrame(&padding), false); | 516 bool success = AddFrame(QuicFrame(&padding), false); |
526 DCHECK(success); | 517 DCHECK(success); |
527 } | 518 } |
528 | 519 |
529 } // namespace net | 520 } // namespace net |
OLD | NEW |