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

Unified Diff: net/quic/quic_framer.cc

Issue 1421593004: Change QuicFramer::BuildDataPacket to return a length instead of QuicPacket* in order to reduce mem… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@105596142
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_framer.cc
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index c98a838d1dbad5b101a965f2473fe09949d66da6..41e1498c84d4116f8aef363d130e0cfbce3e2791 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -321,14 +321,14 @@ QuicPacketEntropyHash QuicFramer::GetPacketEntropyHash(
return header.entropy_flag << (header.packet_number % 8);
}
-QuicPacket* QuicFramer::BuildDataPacket(const QuicPacketHeader& header,
- const QuicFrames& frames,
- char* buffer,
- size_t packet_length) {
+size_t QuicFramer::BuildDataPacket(const QuicPacketHeader& header,
+ const QuicFrames& frames,
+ char* buffer,
+ size_t packet_length) {
QuicDataWriter writer(packet_length, buffer);
if (!AppendPacketHeader(header, &writer)) {
LOG(DFATAL) << "AppendPacketHeader failed";
- return nullptr;
+ return 0;
}
size_t i = 0;
@@ -339,7 +339,7 @@ QuicPacket* QuicFramer::BuildDataPacket(const QuicPacketHeader& header,
(i == frames.size() - 1);
if (!AppendTypeByte(frame, no_stream_frame_length, &writer)) {
LOG(DFATAL) << "AppendTypeByte failed";
- return nullptr;
+ return 0;
}
switch (frame.type) {
@@ -350,21 +350,21 @@ QuicPacket* QuicFramer::BuildDataPacket(const QuicPacketHeader& header,
if (!AppendStreamFrame(
*frame.stream_frame, no_stream_frame_length, &writer)) {
LOG(DFATAL) << "AppendStreamFrame failed";
- return nullptr;
+ return 0;
}
break;
case ACK_FRAME:
if (!AppendAckFrameAndTypeByte(
header, *frame.ack_frame, &writer)) {
LOG(DFATAL) << "AppendAckFrameAndTypeByte failed";
- return nullptr;
+ return 0;
}
break;
case STOP_WAITING_FRAME:
if (!AppendStopWaitingFrame(
header, *frame.stop_waiting_frame, &writer)) {
LOG(DFATAL) << "AppendStopWaitingFrame failed";
- return nullptr;
+ return 0;
}
break;
case MTU_DISCOVERY_FRAME:
@@ -375,49 +375,43 @@ QuicPacket* QuicFramer::BuildDataPacket(const QuicPacketHeader& header,
case RST_STREAM_FRAME:
if (!AppendRstStreamFrame(*frame.rst_stream_frame, &writer)) {
LOG(DFATAL) << "AppendRstStreamFrame failed";
- return nullptr;
+ return 0;
}
break;
case CONNECTION_CLOSE_FRAME:
if (!AppendConnectionCloseFrame(
*frame.connection_close_frame, &writer)) {
LOG(DFATAL) << "AppendConnectionCloseFrame failed";
- return nullptr;
+ return 0;
}
break;
case GOAWAY_FRAME:
if (!AppendGoAwayFrame(*frame.goaway_frame, &writer)) {
LOG(DFATAL) << "AppendGoAwayFrame failed";
- return nullptr;
+ return 0;
}
break;
case WINDOW_UPDATE_FRAME:
if (!AppendWindowUpdateFrame(*frame.window_update_frame, &writer)) {
LOG(DFATAL) << "AppendWindowUpdateFrame failed";
- return nullptr;
+ return 0;
}
break;
case BLOCKED_FRAME:
if (!AppendBlockedFrame(*frame.blocked_frame, &writer)) {
LOG(DFATAL) << "AppendBlockedFrame failed";
- return nullptr;
+ return 0;
}
break;
default:
RaiseError(QUIC_INVALID_FRAME_DATA);
LOG(DFATAL) << "QUIC_INVALID_FRAME_DATA";
- return nullptr;
+ return 0;
}
++i;
}
- QuicPacket* packet =
- new QuicPacket(writer.data(), writer.length(), false,
- header.public_header.connection_id_length,
- header.public_header.version_flag,
- header.public_header.packet_number_length);
-
- return packet;
+ return writer.length();
}
QuicPacket* QuicFramer::BuildFecPacket(const QuicPacketHeader& header,
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698