| 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 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // QuicPacketWriter methods: | 36 // QuicPacketWriter methods: |
| 37 virtual WriteResult WritePacket( | 37 virtual WriteResult WritePacket( |
| 38 const char* buffer, size_t buf_len, | 38 const char* buffer, size_t buf_len, |
| 39 const IPAddressNumber& self_address, | 39 const IPAddressNumber& self_address, |
| 40 const IPEndPoint& peer_address, | 40 const IPEndPoint& peer_address, |
| 41 QuicBlockedWriterInterface* blocked_writer) OVERRIDE; | 41 QuicBlockedWriterInterface* blocked_writer) OVERRIDE; |
| 42 | 42 |
| 43 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 43 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
| 44 | 44 |
| 45 // Writes out the next packet to the contained writer and returns the time | 45 // Writes out any packet which should have been sent by now |
| 46 // to the contained writer and returns the time |
| 46 // for the next delayed packet to be written. | 47 // for the next delayed packet to be written. |
| 47 QuicTime ReleaseNextPacket(); | 48 QuicTime ReleaseOldPackets(); |
| 48 | 49 |
| 49 QuicBlockedWriterInterface* blocked_writer() { return blocked_writer_; } | 50 QuicBlockedWriterInterface* blocked_writer() { return blocked_writer_; } |
| 50 | 51 |
| 51 // The percent of time a packet is simulated as being lost. | 52 // The percent of time a packet is simulated as being lost. |
| 52 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) { | 53 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) { |
| 53 base::AutoLock locked(config_mutex_); | 54 base::AutoLock locked(config_mutex_); |
| 54 fake_packet_loss_percentage_ = fake_packet_loss_percentage; | 55 fake_packet_loss_percentage_ = fake_packet_loss_percentage; |
| 55 } | 56 } |
| 56 | 57 |
| 57 // The percent of time WritePacket will block and set WriteResult's status | 58 // The percent of time WritePacket will block and set WriteResult's status |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 base::AutoLock locked(config_mutex_); | 90 base::AutoLock locked(config_mutex_); |
| 90 fake_bandwidth_ = fake_bandwidth; | 91 fake_bandwidth_ = fake_bandwidth; |
| 91 buffer_size_ = buffer_size; | 92 buffer_size_ = buffer_size; |
| 92 } | 93 } |
| 93 | 94 |
| 94 void set_seed(uint64 seed) { | 95 void set_seed(uint64 seed) { |
| 95 simple_random_.set_seed(seed); | 96 simple_random_.set_seed(seed); |
| 96 } | 97 } |
| 97 | 98 |
| 98 private: | 99 private: |
| 100 // Writes out the next packet to the contained writer and returns the time |
| 101 // for the next delayed packet to be written. |
| 102 QuicTime ReleaseNextPacket(); |
| 103 |
| 99 // A single packet which will be sent at the supplied send_time. | 104 // A single packet which will be sent at the supplied send_time. |
| 100 class DelayedWrite { | 105 class DelayedWrite { |
| 101 public: | 106 public: |
| 102 DelayedWrite(const char* buffer, | 107 DelayedWrite(const char* buffer, |
| 103 size_t buf_len, | 108 size_t buf_len, |
| 104 const IPAddressNumber& self_address, | 109 const IPAddressNumber& self_address, |
| 105 const IPEndPoint& peer_address, | 110 const IPEndPoint& peer_address, |
| 106 QuicTime send_time); | 111 QuicTime send_time); |
| 107 ~DelayedWrite(); | 112 ~DelayedWrite(); |
| 108 | 113 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 132 QuicByteCount buffer_size_; | 137 QuicByteCount buffer_size_; |
| 133 | 138 |
| 134 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter); | 139 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter); |
| 135 }; | 140 }; |
| 136 | 141 |
| 137 } // namespace test | 142 } // namespace test |
| 138 } // namespace tools | 143 } // namespace tools |
| 139 } // namespace net | 144 } // namespace net |
| 140 | 145 |
| 141 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ | 146 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ |
| OLD | NEW |