OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 fake_bandwidth_(QuicBandwidth::Zero()), | 59 fake_bandwidth_(QuicBandwidth::Zero()), |
60 buffer_size_(0) { | 60 buffer_size_(0) { |
61 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()); |
62 VLOG(1) << "Seeding packet loss with " << seed; | 62 VLOG(1) << "Seeding packet loss with " << seed; |
63 simple_random_.set_seed(seed); | 63 simple_random_.set_seed(seed); |
64 } | 64 } |
65 | 65 |
66 PacketDroppingTestWriter::~PacketDroppingTestWriter() {} | 66 PacketDroppingTestWriter::~PacketDroppingTestWriter() {} |
67 | 67 |
68 void PacketDroppingTestWriter::Initialize(QuicConnectionHelperInterface* helper, | 68 void PacketDroppingTestWriter::Initialize(QuicConnectionHelperInterface* helper, |
| 69 QuicAlarmFactory* alarm_factory, |
69 Delegate* on_can_write) { | 70 Delegate* on_can_write) { |
70 clock_ = helper->GetClock(); | 71 clock_ = helper->GetClock(); |
71 write_unblocked_alarm_.reset( | 72 write_unblocked_alarm_.reset( |
72 helper->CreateAlarm(new WriteUnblockedAlarm(this))); | 73 alarm_factory->CreateAlarm(new WriteUnblockedAlarm(this))); |
73 delay_alarm_.reset(helper->CreateAlarm(new DelayAlarm(this))); | 74 delay_alarm_.reset(alarm_factory->CreateAlarm(new DelayAlarm(this))); |
74 on_can_write_.reset(on_can_write); | 75 on_can_write_.reset(on_can_write); |
75 } | 76 } |
76 | 77 |
77 WriteResult PacketDroppingTestWriter::WritePacket( | 78 WriteResult PacketDroppingTestWriter::WritePacket( |
78 const char* buffer, | 79 const char* buffer, |
79 size_t buf_len, | 80 size_t buf_len, |
80 const IPAddress& self_address, | 81 const IPAddress& self_address, |
81 const IPEndPoint& peer_address, | 82 const IPEndPoint& peer_address, |
82 PerPacketOptions* options) { | 83 PerPacketOptions* options) { |
83 ++num_calls_to_write_; | 84 ++num_calls_to_write_; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // IPAddress has no move assignment operator. | 237 // IPAddress has no move assignment operator. |
237 // | 238 // |
238 // PacketDroppingTestWriter::DelayedWrite& | 239 // PacketDroppingTestWriter::DelayedWrite& |
239 // PacketDroppingTestWriter::DelayedWrite::operator=( | 240 // PacketDroppingTestWriter::DelayedWrite::operator=( |
240 // PacketDroppingTestWriter::DelayedWrite&& other) = default; | 241 // PacketDroppingTestWriter::DelayedWrite&& other) = default; |
241 | 242 |
242 PacketDroppingTestWriter::DelayedWrite::~DelayedWrite() {} | 243 PacketDroppingTestWriter::DelayedWrite::~DelayedWrite() {} |
243 | 244 |
244 } // namespace test | 245 } // namespace test |
245 } // namespace net | 246 } // namespace net |
OLD | NEW |