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

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

Issue 1138443003: Land Recent QUIC Changes until 05/13/2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile error fixes 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
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..79573803cbeb3441c064449bc7cb490fa6077a42 100644
--- a/net/tools/quic/test_tools/packet_dropping_test_writer.cc
+++ b/net/tools/quic/test_tools/packet_dropping_test_writer.cc
@@ -46,8 +46,10 @@ class DelayAlarm : public QuicAlarm::Delegate {
PacketDroppingTestWriter::PacketDroppingTestWriter()
: clock_(nullptr),
cur_buffer_size_(0),
+ num_calls_to_write_(0),
config_mutex_(),
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_ <= static_cast<uint64>(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') | net/tools/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698