| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ | 5 #ifndef REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ |
| 6 #define REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ | 6 #define REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // l = NormalRand(average, stddev) + bytes_buffered / bandwidth . | 46 // l = NormalRand(average, stddev) + bytes_buffered / bandwidth . |
| 47 // | 47 // |
| 48 // Where bytes_buffered is the current level in the leaky bucket used to | 48 // Where bytes_buffered is the current level in the leaky bucket used to |
| 49 // control bandwidth. | 49 // control bandwidth. |
| 50 void SetLatency(base::TimeDelta average, base::TimeDelta stddev); | 50 void SetLatency(base::TimeDelta average, base::TimeDelta stddev); |
| 51 | 51 |
| 52 void set_out_of_order_rate(double out_of_order_rate) { | 52 void set_out_of_order_rate(double out_of_order_rate) { |
| 53 out_of_order_rate_ = out_of_order_rate; | 53 out_of_order_rate_ = out_of_order_rate; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ResetStats(); |
| 57 base::TimeDelta GetAverageDelay(); |
| 58 |
| 56 // rtc::PacketSocketFactory interface. | 59 // rtc::PacketSocketFactory interface. |
| 57 rtc::AsyncPacketSocket* CreateUdpSocket( | 60 rtc::AsyncPacketSocket* CreateUdpSocket( |
| 58 const rtc::SocketAddress& local_address, | 61 const rtc::SocketAddress& local_address, |
| 59 uint16_t min_port, | 62 uint16_t min_port, |
| 60 uint16_t max_port) override; | 63 uint16_t max_port) override; |
| 61 rtc::AsyncPacketSocket* CreateServerTcpSocket( | 64 rtc::AsyncPacketSocket* CreateServerTcpSocket( |
| 62 const rtc::SocketAddress& local_address, | 65 const rtc::SocketAddress& local_address, |
| 63 uint16_t min_port, | 66 uint16_t min_port, |
| 64 uint16_t max_port, | 67 uint16_t max_port, |
| 65 int opts) override; | 68 int opts) override; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 std::unique_ptr<LeakyBucket> leaky_bucket_; | 115 std::unique_ptr<LeakyBucket> leaky_bucket_; |
| 113 base::TimeDelta latency_average_; | 116 base::TimeDelta latency_average_; |
| 114 base::TimeDelta latency_stddev_; | 117 base::TimeDelta latency_stddev_; |
| 115 double out_of_order_rate_; | 118 double out_of_order_rate_; |
| 116 | 119 |
| 117 UdpSocketsMap udp_sockets_; | 120 UdpSocketsMap udp_sockets_; |
| 118 uint16_t next_port_; | 121 uint16_t next_port_; |
| 119 | 122 |
| 120 std::list<PendingPacket> pending_packets_; | 123 std::list<PendingPacket> pending_packets_; |
| 121 | 124 |
| 125 int total_packets_received_ = 0; |
| 126 base::TimeDelta total_delay_; |
| 127 |
| 122 base::WeakPtrFactory<FakePacketSocketFactory> weak_factory_; | 128 base::WeakPtrFactory<FakePacketSocketFactory> weak_factory_; |
| 123 | 129 |
| 124 DISALLOW_COPY_AND_ASSIGN(FakePacketSocketFactory); | 130 DISALLOW_COPY_AND_ASSIGN(FakePacketSocketFactory); |
| 125 }; | 131 }; |
| 126 | 132 |
| 127 } // namespace remoting | 133 } // namespace remoting |
| 128 | 134 |
| 129 #endif // REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ | 135 #endif // REMOTING_TEST_FAKE_SOCKET_FACTORY_H_ |
| OLD | NEW |