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

Side by Side Diff: net/tools/quic/test_tools/packet_dropping_test_writer.cc

Issue 2403193003: Landing Recent QUIC changes until 9:41 AM, Oct 10, 2016 UTC-7 (Closed)
Patch Set: git cl format Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" 5 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "net/tools/quic/quic_epoll_connection_helper.h" 10 #include "net/tools/quic/quic_epoll_connection_helper.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 private: 45 private:
46 PacketDroppingTestWriter* writer_; 46 PacketDroppingTestWriter* writer_;
47 }; 47 };
48 48
49 PacketDroppingTestWriter::PacketDroppingTestWriter() 49 PacketDroppingTestWriter::PacketDroppingTestWriter()
50 : clock_(nullptr), 50 : clock_(nullptr),
51 cur_buffer_size_(0), 51 cur_buffer_size_(0),
52 num_calls_to_write_(0), 52 num_calls_to_write_(0),
53 max_allowed_packet_size_(std::numeric_limits<QuicByteCount>::max()),
54 config_mutex_(), 53 config_mutex_(),
55 fake_packet_loss_percentage_(0), 54 fake_packet_loss_percentage_(0),
56 fake_drop_first_n_packets_(0), 55 fake_drop_first_n_packets_(0),
57 fake_blocked_socket_percentage_(0), 56 fake_blocked_socket_percentage_(0),
58 fake_packet_reorder_percentage_(0), 57 fake_packet_reorder_percentage_(0),
59 fake_packet_delay_(QuicTime::Delta::Zero()), 58 fake_packet_delay_(QuicTime::Delta::Zero()),
60 fake_bandwidth_(QuicBandwidth::Zero()), 59 fake_bandwidth_(QuicBandwidth::Zero()),
61 buffer_size_(0) { 60 buffer_size_(0) {
62 uint32_t seed = base::RandInt(0, std::numeric_limits<int32_t>::max()); 61 uint32_t seed = base::RandInt(0, std::numeric_limits<int32_t>::max());
63 VLOG(1) << "Seeding packet loss with " << seed; 62 VLOG(1) << "Seeding packet loss with " << seed;
(...skipping 11 matching lines...) Expand all
75 delay_alarm_.reset(alarm_factory->CreateAlarm(new DelayAlarm(this))); 74 delay_alarm_.reset(alarm_factory->CreateAlarm(new DelayAlarm(this)));
76 on_can_write_.reset(on_can_write); 75 on_can_write_.reset(on_can_write);
77 } 76 }
78 77
79 WriteResult PacketDroppingTestWriter::WritePacket( 78 WriteResult PacketDroppingTestWriter::WritePacket(
80 const char* buffer, 79 const char* buffer,
81 size_t buf_len, 80 size_t buf_len,
82 const IPAddress& self_address, 81 const IPAddress& self_address,
83 const IPEndPoint& peer_address, 82 const IPEndPoint& peer_address,
84 PerPacketOptions* options) { 83 PerPacketOptions* options) {
85 CHECK_LE(buf_len, max_allowed_packet_size_);
86 ++num_calls_to_write_; 84 ++num_calls_to_write_;
87 ReleaseOldPackets(); 85 ReleaseOldPackets();
88 86
89 base::AutoLock locked(config_mutex_); 87 base::AutoLock locked(config_mutex_);
90 if (fake_drop_first_n_packets_ > 0 && 88 if (fake_drop_first_n_packets_ > 0 &&
91 num_calls_to_write_ <= 89 num_calls_to_write_ <=
92 static_cast<uint64_t>(fake_drop_first_n_packets_)) { 90 static_cast<uint64_t>(fake_drop_first_n_packets_)) {
93 DVLOG(1) << "Dropping first " << fake_drop_first_n_packets_ 91 DVLOG(1) << "Dropping first " << fake_drop_first_n_packets_
94 << " packets (packet number " << num_calls_to_write_ << ")"; 92 << " packets (packet number " << num_calls_to_write_ << ")";
95 return WriteResult(WRITE_STATUS_OK, buf_len); 93 return WriteResult(WRITE_STATUS_OK, buf_len);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // IPAddress has no move assignment operator. 237 // IPAddress has no move assignment operator.
240 // 238 //
241 // PacketDroppingTestWriter::DelayedWrite& 239 // PacketDroppingTestWriter::DelayedWrite&
242 // PacketDroppingTestWriter::DelayedWrite::operator=( 240 // PacketDroppingTestWriter::DelayedWrite::operator=(
243 // PacketDroppingTestWriter::DelayedWrite&& other) = default; 241 // PacketDroppingTestWriter::DelayedWrite&& other) = default;
244 242
245 PacketDroppingTestWriter::DelayedWrite::~DelayedWrite() {} 243 PacketDroppingTestWriter::DelayedWrite::~DelayedWrite() {}
246 244
247 } // namespace test 245 } // namespace test
248 } // namespace net 246 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/packet_dropping_test_writer.h ('k') | net/tools/quic/test_tools/quic_test_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698