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

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

Issue 1136553007: Adds support to the PacketDroppingTestWriter for dropping the first N (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Minor_cleanup_93441848
Patch Set: Created 5 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
« no previous file with comments | « net/tools/quic/test_tools/packet_dropping_test_writer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/test_tools/packet_dropping_test_writer.cc
diff --git a/net/tools/quic/test_tools/packet_dropping_test_writer.cc b/net/tools/quic/test_tools/packet_dropping_test_writer.cc
index e31a72826bbbf4de16353bac7135f4c5190b0af4..2ef0ba90bf5f6d8125511ba1eb451d85d2a87032 100644
--- a/net/tools/quic/test_tools/packet_dropping_test_writer.cc
+++ b/net/tools/quic/test_tools/packet_dropping_test_writer.cc
@@ -47,7 +47,9 @@ PacketDroppingTestWriter::PacketDroppingTestWriter()
: clock_(nullptr),
cur_buffer_size_(0),
config_mutex_(),
+ num_calls_to_write_(0),
fake_packet_loss_percentage_(0),
+ fake_drop_first_n_packets_(0),
fake_blocked_socket_percentage_(0),
fake_packet_reorder_percentage_(0),
fake_packet_delay_(QuicTime::Delta::Zero()),
@@ -76,9 +78,16 @@ WriteResult PacketDroppingTestWriter::WritePacket(
size_t buf_len,
const net::IPAddressNumber& self_address,
const net::IPEndPoint& peer_address) {
+ ++num_calls_to_write_;
ReleaseOldPackets();
base::AutoLock locked(config_mutex_);
+ if (fake_drop_first_n_packets_ > 0 &&
+ num_calls_to_write_ <= fake_drop_first_n_packets_) {
+ DVLOG(1) << "Dropping first " << fake_drop_first_n_packets_
+ << " packets (packet number " << num_calls_to_write_ << ")";
+ return WriteResult(WRITE_STATUS_OK, buf_len);
+ }
if (fake_packet_loss_percentage_ > 0 &&
simple_random_.RandUint64() % 100 <
static_cast<uint64>(fake_packet_loss_percentage_)) {
« no previous file with comments | « net/tools/quic/test_tools/packet_dropping_test_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698