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

Unified Diff: net/quic/quic_packet_creator.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: net/quic/quic_packet_creator.cc
diff --git a/net/quic/quic_packet_creator.cc b/net/quic/quic_packet_creator.cc
index bb243f96d9695ef37659dbc2d9aebf32e7733b6b..9071b7187c3f33bd4e5ba0547f70a12d80d1181d 100644
--- a/net/quic/quic_packet_creator.cc
+++ b/net/quic/quic_packet_creator.cc
@@ -27,9 +27,7 @@ class QuicRandomBoolSource {
public:
// random: Source of entropy. Not owned.
explicit QuicRandomBoolSource(QuicRandom* random)
- : random_(random),
- bit_bucket_(0),
- bit_mask_(0) {}
+ : random_(random), bit_bucket_(0), bit_mask_(0) {}
~QuicRandomBoolSource() {}
@@ -75,7 +73,8 @@ QuicPacketCreator::~QuicPacketCreator() {
}
void QuicPacketCreator::OnBuiltFecProtectedPayload(
- const QuicPacketHeader& header, StringPiece payload) {
+ const QuicPacketHeader& header,
+ StringPiece payload) {
if (fec_group_.get()) {
DCHECK_NE(0u, header.fec_group);
fec_group_->Update(header, payload);
@@ -84,8 +83,9 @@ void QuicPacketCreator::OnBuiltFecProtectedPayload(
bool QuicPacketCreator::ShouldSendFec(bool force_close) const {
return fec_group_.get() != NULL && fec_group_->NumReceivedPackets() > 0 &&
- (force_close ||
- fec_group_->NumReceivedPackets() >= options_.max_packets_per_fec_group);
+ (force_close ||
+ fec_group_->NumReceivedPackets() >=
+ options_.max_packets_per_fec_group);
}
InFecGroup QuicPacketCreator::MaybeStartFEC() {
@@ -111,14 +111,14 @@ void QuicPacketCreator::StopSendingVersion() {
}
void QuicPacketCreator::UpdateSequenceNumberLength(
- QuicPacketSequenceNumber least_packet_awaited_by_peer,
- QuicByteCount congestion_window) {
+ QuicPacketSequenceNumber least_packet_awaited_by_peer,
+ QuicByteCount congestion_window) {
DCHECK_LE(least_packet_awaited_by_peer, sequence_number_ + 1);
// Since the packet creator will not change sequence number length mid FEC
// group, include the size of an FEC group to be safe.
const QuicPacketSequenceNumber current_delta =
- options_.max_packets_per_fec_group + sequence_number_ + 1
- - least_packet_awaited_by_peer;
+ options_.max_packets_per_fec_group + sequence_number_ + 1 -
+ least_packet_awaited_by_peer;
const uint64 congestion_window_packets =
congestion_window / options_.max_packet_length;
const uint64 delta = max(current_delta, congestion_window_packets);
@@ -132,8 +132,8 @@ bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id,
// is_in_fec_group a parameter. Same as with all public methods in
// QuicPacketCreator.
return BytesFree() >
- QuicFramer::GetMinStreamFrameSize(framer_->version(), id, offset, true,
- IsFecEnabled());
+ QuicFramer::GetMinStreamFrameSize(
+ framer_->version(), id, offset, true, IsFecEnabled());
}
// static
@@ -143,10 +143,13 @@ size_t QuicPacketCreator::StreamFramePacketOverhead(
bool include_version,
QuicSequenceNumberLength sequence_number_length,
InFecGroup is_in_fec_group) {
- return GetPacketHeaderSize(connection_id_length, include_version,
- sequence_number_length, is_in_fec_group) +
- // Assumes this is a stream with a single lone packet.
- QuicFramer::GetMinStreamFrameSize(version, 1u, 0u, true, is_in_fec_group);
+ return GetPacketHeaderSize(connection_id_length,
+ include_version,
+ sequence_number_length,
+ is_in_fec_group) +
+ // Assumes this is a stream with a single lone packet.
+ QuicFramer::GetMinStreamFrameSize(
+ version, 1u, 0u, true, is_in_fec_group);
}
size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
@@ -155,35 +158,38 @@ size_t QuicPacketCreator::CreateStreamFrame(QuicStreamId id,
bool fin,
QuicFrame* frame) {
DCHECK_GT(options_.max_packet_length,
- StreamFramePacketOverhead(
- framer_->version(), PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
- PACKET_6BYTE_SEQUENCE_NUMBER, IN_FEC_GROUP));
+ StreamFramePacketOverhead(framer_->version(),
+ PACKET_8BYTE_CONNECTION_ID,
+ kIncludeVersion,
+ PACKET_6BYTE_SEQUENCE_NUMBER,
+ IN_FEC_GROUP));
InFecGroup is_in_fec_group = MaybeStartFEC();
LOG_IF(DFATAL, !HasRoomForStreamFrame(id, offset))
<< "No room for Stream frame, BytesFree: " << BytesFree()
<< " MinStreamFrameSize: "
<< QuicFramer::GetMinStreamFrameSize(
- framer_->version(), id, offset, true, is_in_fec_group);
+ framer_->version(), id, offset, true, is_in_fec_group);
if (data.Empty()) {
- LOG_IF(DFATAL, !fin)
- << "Creating a stream frame with no data or fin.";
+ LOG_IF(DFATAL, !fin) << "Creating a stream frame with no data or fin.";
// Create a new packet for the fin, if necessary.
*frame = QuicFrame(new QuicStreamFrame(id, true, offset, data));
return 0;
}
const size_t data_size = data.TotalBufferSize();
- size_t min_frame_size = QuicFramer::GetMinStreamFrameSize(
- framer_->version(), id, offset, /*last_frame_in_packet=*/ true,
- is_in_fec_group);
+ size_t min_frame_size =
+ QuicFramer::GetMinStreamFrameSize(framer_->version(),
+ id,
+ offset,
+ /*last_frame_in_packet=*/true,
+ is_in_fec_group);
size_t bytes_consumed = min<size_t>(BytesFree() - min_frame_size, data_size);
bool set_fin = fin && bytes_consumed == data_size; // Last frame.
IOVector frame_data;
- frame_data.AppendIovecAtMostBytes(data.iovec(), data.Size(),
- bytes_consumed);
+ frame_data.AppendIovecAtMostBytes(data.iovec(), data.Size(), bytes_consumed);
DCHECK_EQ(frame_data.TotalBufferSize(), bytes_consumed);
*frame = QuicFrame(new QuicStreamFrame(id, set_fin, offset, frame_data));
return bytes_consumed;
@@ -238,8 +244,7 @@ SerializedPacket QuicPacketCreator::SerializeAllFrames(
// frames from SendStreamData()[send_stream_should_flush_ == false &&
// data.empty() == true] and retransmit due to RTO.
DCHECK_EQ(0u, queued_frames_.size());
- LOG_IF(DFATAL, frames.empty())
- << "Attempt to serialize empty packet";
+ 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);
DCHECK(success);
@@ -256,7 +261,7 @@ bool QuicPacketCreator::HasPendingFrames() {
size_t QuicPacketCreator::ExpansionOnNewFrame() const {
// If packet is FEC protected, there's no expansion.
if (fec_group_.get() != NULL) {
- return 0;
+ return 0;
}
// If the last frame in the packet is a stream frame, then it will expand to
// include the stream_length field when a new frame is added.
@@ -269,21 +274,20 @@ size_t QuicPacketCreator::BytesFree() const {
const size_t max_plaintext_size =
framer_->GetMaxPlaintextSize(options_.max_packet_length);
DCHECK_GE(max_plaintext_size, PacketSize());
- return max_plaintext_size - min(max_plaintext_size, PacketSize()
- + ExpansionOnNewFrame());
+ return max_plaintext_size -
+ min(max_plaintext_size, PacketSize() + ExpansionOnNewFrame());
}
InFecGroup QuicPacketCreator::IsFecEnabled() const {
- return (options_.max_packets_per_fec_group == 0) ?
- NOT_IN_FEC_GROUP : IN_FEC_GROUP;
+ return (options_.max_packets_per_fec_group == 0) ? NOT_IN_FEC_GROUP
+ : IN_FEC_GROUP;
}
size_t QuicPacketCreator::PacketSize() const {
if (queued_frames_.empty()) {
// Only adjust the sequence number length when the FEC group is not open,
// to ensure no packets in a group are too large.
- if (fec_group_.get() == NULL ||
- fec_group_->NumReceivedPackets() == 0) {
+ if (fec_group_.get() == NULL || fec_group_->NumReceivedPackets() == 0) {
sequence_number_length_ = options_.send_sequence_number_length;
}
packet_size_ = GetPacketHeaderSize(options_.send_connection_id_length,
@@ -299,8 +303,7 @@ bool QuicPacketCreator::AddSavedFrame(const QuicFrame& frame) {
}
SerializedPacket QuicPacketCreator::SerializePacket() {
- LOG_IF(DFATAL, queued_frames_.empty())
- << "Attempt to serialize empty packet";
+ LOG_IF(DFATAL, queued_frames_.empty()) << "Attempt to serialize empty packet";
QuicPacketHeader header;
FillPacketHeader(fec_group_number_, false, &header);
@@ -313,14 +316,13 @@ SerializedPacket QuicPacketCreator::SerializePacket() {
// the first frame in the packet. If truncation is to occur, then
// GetSerializedFrameLength will have returned all bytes free.
bool possibly_truncated =
- packet_size_ != max_plaintext_size ||
- queued_frames_.size() != 1 ||
+ packet_size_ != max_plaintext_size || queued_frames_.size() != 1 ||
(queued_frames_.back().type == ACK_FRAME ||
queued_frames_.back().type == CONNECTION_CLOSE_FRAME);
SerializedPacket serialized =
framer_->BuildDataPacket(header, queued_frames_, packet_size_);
- LOG_IF(DFATAL, !serialized.packet)
- << "Failed to serialize " << queued_frames_.size() << " frames.";
+ LOG_IF(DFATAL, !serialized.packet) << "Failed to serialize "
+ << queued_frames_.size() << " frames.";
// Because of possible truncation, we can't be confident that our
// packet size calculation worked correctly.
if (!possibly_truncated)
@@ -407,9 +409,13 @@ bool QuicPacketCreator::AddFrame(const QuicFrame& frame,
bool save_retransmittable_frames) {
DVLOG(1) << "Adding frame: " << frame;
InFecGroup is_in_fec_group = MaybeStartFEC();
- size_t frame_len = framer_->GetSerializedFrameLength(
- frame, BytesFree(), queued_frames_.empty(), true, is_in_fec_group,
- options()->send_sequence_number_length);
+ size_t frame_len =
+ framer_->GetSerializedFrameLength(frame,
+ BytesFree(),
+ queued_frames_.empty(),
+ true,
+ is_in_fec_group,
+ options()->send_sequence_number_length);
if (frame_len == 0) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698