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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
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 #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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 25 matching lines...) Expand all
36 36
37 virtual ~PacketDroppingTestWriter(); 37 virtual ~PacketDroppingTestWriter();
38 38
39 // Must be called before blocking, reordering or delaying (loss is OK). May be 39 // Must be called before blocking, reordering or delaying (loss is OK). May be
40 // called after connecting if the helper is not available before. 40 // called after connecting if the helper is not available before.
41 // |on_can_write| will be triggered when fake-unblocking; ownership will be 41 // |on_can_write| will be triggered when fake-unblocking; ownership will be
42 // assumed. 42 // assumed.
43 void Initialize(QuicEpollConnectionHelper* helper, Delegate* on_can_write); 43 void Initialize(QuicEpollConnectionHelper* helper, Delegate* on_can_write);
44 44
45 // QuicPacketWriter methods: 45 // QuicPacketWriter methods:
46 virtual WriteResult WritePacket( 46 virtual WriteResult WritePacket(const char* buffer,
47 const char* buffer, 47 size_t buf_len,
48 size_t buf_len, 48 const IPAddressNumber& self_address,
49 const IPAddressNumber& self_address, 49 const IPEndPoint& peer_address) OVERRIDE;
50 const IPEndPoint& peer_address) OVERRIDE;
51 50
52 virtual bool IsWriteBlocked() const OVERRIDE; 51 virtual bool IsWriteBlocked() const OVERRIDE;
53 52
54 virtual void SetWritable() OVERRIDE; 53 virtual void SetWritable() OVERRIDE;
55 54
56 // Writes out any packet which should have been sent by now 55 // Writes out any packet which should have been sent by now
57 // to the contained writer and returns the time 56 // to the contained writer and returns the time
58 // for the next delayed packet to be written. 57 // for the next delayed packet to be written.
59 QuicTime ReleaseOldPackets(); 58 QuicTime ReleaseOldPackets();
60 59
61 void OnCanWrite(); 60 void OnCanWrite();
62 61
63 // The percent of time a packet is simulated as being lost. 62 // The percent of time a packet is simulated as being lost.
64 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) { 63 void set_fake_packet_loss_percentage(int32 fake_packet_loss_percentage) {
65 base::AutoLock locked(config_mutex_); 64 base::AutoLock locked(config_mutex_);
66 fake_packet_loss_percentage_ = fake_packet_loss_percentage; 65 fake_packet_loss_percentage_ = fake_packet_loss_percentage;
67 } 66 }
68 67
69 // The percent of time WritePacket will block and set WriteResult's status 68 // The percent of time WritePacket will block and set WriteResult's status
70 // to WRITE_STATUS_BLOCKED. 69 // to WRITE_STATUS_BLOCKED.
71 void set_fake_blocked_socket_percentage( 70 void set_fake_blocked_socket_percentage(
72 int32 fake_blocked_socket_percentage) { 71 int32 fake_blocked_socket_percentage) {
73 DCHECK(clock_); 72 DCHECK(clock_);
74 base::AutoLock locked(config_mutex_); 73 base::AutoLock locked(config_mutex_);
75 fake_blocked_socket_percentage_ = fake_blocked_socket_percentage; 74 fake_blocked_socket_percentage_ = fake_blocked_socket_percentage;
76 } 75 }
77 76
78 // The percent of time a packet is simulated as being reordered. 77 // The percent of time a packet is simulated as being reordered.
79 void set_fake_reorder_percentage(int32 fake_packet_reorder_percentage) { 78 void set_fake_reorder_percentage(int32 fake_packet_reorder_percentage) {
80 DCHECK(clock_); 79 DCHECK(clock_);
81 base::AutoLock locked(config_mutex_); 80 base::AutoLock locked(config_mutex_);
82 DCHECK(!fake_packet_delay_.IsZero()); 81 DCHECK(!fake_packet_delay_.IsZero());
83 fake_packet_reorder_percentage_ = fake_packet_reorder_percentage; 82 fake_packet_reorder_percentage_ = fake_packet_reorder_percentage;
84 } 83 }
85 84
86 // The percent of time WritePacket will block and set WriteResult's status 85 // The percent of time WritePacket will block and set WriteResult's status
87 // to WRITE_STATUS_BLOCKED. 86 // to WRITE_STATUS_BLOCKED.
88 void set_fake_packet_delay(QuicTime::Delta fake_packet_delay) { 87 void set_fake_packet_delay(QuicTime::Delta fake_packet_delay) {
89 DCHECK(clock_); 88 DCHECK(clock_);
90 base::AutoLock locked(config_mutex_); 89 base::AutoLock locked(config_mutex_);
91 fake_packet_delay_ = fake_packet_delay; 90 fake_packet_delay_ = fake_packet_delay;
92 } 91 }
93 92
94 // The maximum bandwidth and buffer size of the connection. When these are 93 // The maximum bandwidth and buffer size of the connection. When these are
95 // set, packets will be delayed until a connection with that bandwidth would 94 // set, packets will be delayed until a connection with that bandwidth would
96 // transmit it. Once the |buffer_size| is reached, all new packets are 95 // transmit it. Once the |buffer_size| is reached, all new packets are
97 // dropped. 96 // dropped.
98 void set_max_bandwidth_and_buffer_size(QuicBandwidth fake_bandwidth, 97 void set_max_bandwidth_and_buffer_size(QuicBandwidth fake_bandwidth,
99 QuicByteCount buffer_size) { 98 QuicByteCount buffer_size) {
100 DCHECK(clock_); 99 DCHECK(clock_);
101 base::AutoLock locked(config_mutex_); 100 base::AutoLock locked(config_mutex_);
102 fake_bandwidth_ = fake_bandwidth; 101 fake_bandwidth_ = fake_bandwidth;
103 buffer_size_ = buffer_size; 102 buffer_size_ = buffer_size;
104 } 103 }
105 104
106 void set_seed(uint64 seed) { 105 void set_seed(uint64 seed) { simple_random_.set_seed(seed); }
107 simple_random_.set_seed(seed);
108 }
109 106
110 private: 107 private:
111 // Writes out the next packet to the contained writer and returns the time 108 // Writes out the next packet to the contained writer and returns the time
112 // for the next delayed packet to be written. 109 // for the next delayed packet to be written.
113 QuicTime ReleaseNextPacket(); 110 QuicTime ReleaseNextPacket();
114 111
115 // A single packet which will be sent at the supplied send_time. 112 // A single packet which will be sent at the supplied send_time.
116 struct DelayedWrite { 113 struct DelayedWrite {
117 public: 114 public:
118 DelayedWrite(const char* buffer, 115 DelayedWrite(const char* buffer,
(...skipping 29 matching lines...) Expand all
148 QuicByteCount buffer_size_; 145 QuicByteCount buffer_size_;
149 146
150 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter); 147 DISALLOW_COPY_AND_ASSIGN(PacketDroppingTestWriter);
151 }; 148 };
152 149
153 } // namespace test 150 } // namespace test
154 } // namespace tools 151 } // namespace tools
155 } // namespace net 152 } // namespace net
156 153
157 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_ 154 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_DROPPING_TEST_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698