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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ | 5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ |
6 #define NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ | 6 #define NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 QuicTime ReleaseOldPackets(); | 62 QuicTime ReleaseOldPackets(); |
63 | 63 |
64 void OnCanWrite(); | 64 void OnCanWrite(); |
65 | 65 |
66 // The percent of time a packet is simulated as being lost. | 66 // The percent of time a packet is simulated as being lost. |
67 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) { | 67 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) { |
68 base::AutoLock locked(config_mutex_); | 68 base::AutoLock locked(config_mutex_); |
69 fake_packet_loss_percentage_ = fake_packet_loss_percentage; | 69 fake_packet_loss_percentage_ = fake_packet_loss_percentage; |
70 } | 70 } |
71 | 71 |
| 72 // Simulate dropping the first n packets unconditionally. |
| 73 // Subsequent packets will be lost at fake_packet_loss_percentage_ if set. |
| 74 void set_fake_drop_first_n_packets(int32 fake_drop_first_n_packets) { |
| 75 base::AutoLock locked(config_mutex_); |
| 76 fake_drop_first_n_packets_ = fake_drop_first_n_packets; |
| 77 } |
| 78 |
72 // The percent of time WritePacket will block and set WriteResult's status | 79 // The percent of time WritePacket will block and set WriteResult's status |
73 // to WRITE_STATUS_BLOCKED. | 80 // to WRITE_STATUS_BLOCKED. |
74 void set_fake_blocked_socket_percentage( | 81 void set_fake_blocked_socket_percentage( |
75 int32 fake_blocked_socket_percentage) { | 82 int32 fake_blocked_socket_percentage) { |
76 DCHECK(clock_); | 83 DCHECK(clock_); |
77 base::AutoLock locked(config_mutex_); | 84 base::AutoLock locked(config_mutex_); |
78 fake_blocked_socket_percentage_ = fake_blocked_socket_percentage; | 85 fake_blocked_socket_percentage_ = fake_blocked_socket_percentage; |
79 } | 86 } |
80 | 87 |
81 // The percent of time a packet is simulated as being reordered. | 88 // The percent of time a packet is simulated as being reordered. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 typedef std::list<DelayedWrite> DelayedPacketList; | 141 typedef std::list<DelayedWrite> DelayedPacketList; |
135 | 142 |
136 const QuicClock* clock_; | 143 const QuicClock* clock_; |
137 scoped_ptr<QuicAlarm> write_unblocked_alarm_; | 144 scoped_ptr<QuicAlarm> write_unblocked_alarm_; |
138 scoped_ptr<QuicAlarm> delay_alarm_; | 145 scoped_ptr<QuicAlarm> delay_alarm_; |
139 scoped_ptr<Delegate> on_can_write_; | 146 scoped_ptr<Delegate> on_can_write_; |
140 net::test::SimpleRandom simple_random_; | 147 net::test::SimpleRandom simple_random_; |
141 // Stored packets delayed by fake packet delay or bandwidth restrictions. | 148 // Stored packets delayed by fake packet delay or bandwidth restrictions. |
142 DelayedPacketList delayed_packets_; | 149 DelayedPacketList delayed_packets_; |
143 QuicByteCount cur_buffer_size_; | 150 QuicByteCount cur_buffer_size_; |
| 151 uint64 num_calls_to_write_; |
144 | 152 |
145 base::Lock config_mutex_; | 153 base::Lock config_mutex_; |
146 int32 fake_packet_loss_percentage_; | 154 int32 fake_packet_loss_percentage_; |
| 155 int32 fake_drop_first_n_packets_; |
147 int32 fake_blocked_socket_percentage_; | 156 int32 fake_blocked_socket_percentage_; |
148 int32 fake_packet_reorder_percentage_; | 157 int32 fake_packet_reorder_percentage_; |
149 QuicTime::Delta fake_packet_delay_; | 158 QuicTime::Delta fake_packet_delay_; |
150 QuicBandwidth fake_bandwidth_; | 159 QuicBandwidth fake_bandwidth_; |
151 QuicByteCount buffer_size_; | 160 QuicByteCount buffer_size_; |
152 | 161 |
153 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter); | 162 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter); |
154 }; | 163 }; |
155 | 164 |
156 } // namespace test | 165 } // namespace test |
157 } // namespace tools | 166 } // namespace tools |
158 } // namespace net | 167 } // namespace net |
159 | 168 |
160 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ | 169 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ |
OLD | NEW |