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

Unified Diff: net/tools/quic/test_tools/packet_reordering_writer.cc

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true Created 4 years, 4 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/tools/quic/test_tools/packet_reordering_writer.cc
diff --git a/net/tools/quic/test_tools/packet_reordering_writer.cc b/net/tools/quic/test_tools/packet_reordering_writer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a11f7d8e3931a16dfa3e2751d9b7033414ca9839
--- /dev/null
+++ b/net/tools/quic/test_tools/packet_reordering_writer.cc
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/tools/quic/test_tools/packet_reordering_writer.h"
+
+namespace net {
+namespace test {
+
+PacketReorderingWriter::PacketReorderingWriter() {}
+
+PacketReorderingWriter::~PacketReorderingWriter() {}
+
+WriteResult PacketReorderingWriter::WritePacket(const char* buffer,
+ size_t buf_len,
+ const IPAddress& self_address,
+ const IPEndPoint& peer_address,
+ PerPacketOptions* options) {
+ if (!delay_next_) {
+ WriteResult wr = QuicPacketWriterWrapper::WritePacket(
+ buffer, buf_len, self_address, peer_address, options);
+ --num_packets_to_wait_;
+ if (num_packets_to_wait_ == 0) {
+ // It's time to write the delayed packet.
+ QuicPacketWriterWrapper::WritePacket(
+ delayed_data_.data(), delayed_data_.length(), delayed_self_address_,
+ delayed_peer_address_, delayed_options_.get());
+ }
+ return wr;
+ }
+ // Still have packet to wait.
+ DCHECK_LT(0u, num_packets_to_wait_) << "Only allow one packet to be delayed";
+ delayed_data_ = std::string(buffer, buf_len);
+ delayed_self_address_ = self_address;
+ delayed_peer_address_ = peer_address;
+ if (options != nullptr) {
+ delayed_options_.reset(options->Clone());
+ }
+ delay_next_ = false;
+ return WriteResult(WRITE_STATUS_OK, buf_len);
+}
+
+void PacketReorderingWriter::SetDelay(size_t num_packets_to_wait) {
+ DCHECK_GT(num_packets_to_wait, 0u);
+ num_packets_to_wait_ = num_packets_to_wait;
+ delay_next_ = true;
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/tools/quic/test_tools/packet_reordering_writer.h ('k') | net/tools/quic/test_tools/quic_dispatcher_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698