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

Unified Diff: net/quic/quic_packet_creator.cc

Issue 932723002: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_creator.cc
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index bd4541ed18b017a83bb0fcbac077bdaabd1f330d..e91efa21b2b037fecf8eca3cd3a1dd8a304ca71f 100644
--- a/net/quic/quic_packet_creator.cc
+++ b/net/quic/quic_packet_creator.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "net/quic/crypto/quic_random.h"
#include "net/quic/quic_ack_notifier.h"
+#include "net/quic/quic_data_writer.h"
#include "net/quic/quic_fec_group.h"
#include "net/quic/quic_utils.h"
@@ -297,8 +298,8 @@ SerializedPacket QuicPacketCreator::SerializeAllFrames(
DCHECK_EQ(0u, queued_frames_.size());
LOG_IF(DFATAL, frames.empty())
<< "Attempt to serialize empty packet";
- for (size_t i = 0; i < frames.size(); ++i) {
- bool success = AddFrame(frames[i], false);
+ for (const QuicFrame& frame : frames) {
+ bool success = AddFrame(frame, false);
DCHECK(success);
}
SerializedPacket packet = SerializePacket();
@@ -372,8 +373,19 @@ SerializedPacket QuicPacketCreator::SerializePacket() {
bool possibly_truncated_by_length = packet_size_ == max_plaintext_size &&
queued_frames_.size() == 1 &&
queued_frames_.back().type == ACK_FRAME;
- scoped_ptr<QuicPacket> packet(
- framer_->BuildDataPacket(header, queued_frames_, packet_size_));
+ char buffer[kMaxPacketSize];
+ scoped_ptr<QuicPacket> packet;
+ // Use the packet_size_ instead of the buffer size to ensure smaller
+ // packet sizes are properly used.
+ scoped_ptr<char[]> large_buffer;
+ if (packet_size_ <= kMaxPacketSize) {
+ packet.reset(
+ framer_->BuildDataPacket(header, queued_frames_, buffer, packet_size_));
+ } else {
+ large_buffer.reset(new char[packet_size_]);
+ packet.reset(framer_->BuildDataPacket(header, queued_frames_,
+ large_buffer.get(), packet_size_));
+ }
LOG_IF(DFATAL, packet == nullptr) << "Failed to serialize "
<< queued_frames_.size() << " frames.";
// Because of possible truncation, we can't be confident that our
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698