Chromium Code Reviews| 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 #include "net/quic/congestion_control/send_algorithm_simulator.h" | 5 #include "net/quic/congestion_control/send_algorithm_simulator.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 11 #include "net/quic/crypto/quic_random.h" | 12 #include "net/quic/crypto/quic_random.h" |
| 12 | 13 |
| 13 using std::list; | 14 using std::list; |
| 14 using std::make_pair; | 15 using std::make_pair; |
| 15 using std::max; | 16 using std::max; |
| 16 using std::min; | 17 using std::min; |
| 17 using std::vector; | 18 using std::vector; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 40 max_cwnd(0), | 41 max_cwnd(0), |
| 41 min_cwnd(100000), | 42 min_cwnd(100000), |
| 42 max_cwnd_drop(0), | 43 max_cwnd_drop(0), |
| 43 last_cwnd(0), | 44 last_cwnd(0), |
| 44 last_transfer_bandwidth(QuicBandwidth::Zero()), | 45 last_transfer_bandwidth(QuicBandwidth::Zero()), |
| 45 last_transfer_loss_rate(0) {} | 46 last_transfer_loss_rate(0) {} |
| 46 | 47 |
| 47 SendAlgorithmSimulator::Transfer::Transfer(Sender* sender, | 48 SendAlgorithmSimulator::Transfer::Transfer(Sender* sender, |
| 48 QuicByteCount num_bytes, | 49 QuicByteCount num_bytes, |
| 49 QuicTime start_time, | 50 QuicTime start_time, |
| 50 string name) | 51 std::string name) |
|
ramant (doing other things)
2014/12/02 04:14:43
We share net/quic and net/tools/quic code with int
haltonhuo
2014/12/02 04:57:07
Does that make sense that adding "using std::strin
ramant (doing other things)
2014/12/03 01:10:09
We use "std::" in the header files (we don't speci
| |
| 51 : sender(sender), | 52 : sender(sender), |
| 52 num_bytes(num_bytes), | 53 num_bytes(num_bytes), |
| 53 bytes_acked(0), | 54 bytes_acked(0), |
| 54 bytes_lost(0), | 55 bytes_lost(0), |
| 55 bytes_in_flight(0), | 56 bytes_in_flight(0), |
| 56 start_time(start_time), | 57 start_time(start_time), |
| 57 name(name) {} | 58 name(name) {} |
| 58 | 59 |
| 59 SendAlgorithmSimulator::SendAlgorithmSimulator( | 60 SendAlgorithmSimulator::SendAlgorithmSimulator( |
| 60 MockClock* clock, | 61 MockClock* clock, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 75 } | 76 } |
| 76 | 77 |
| 77 SendAlgorithmSimulator::~SendAlgorithmSimulator() {} | 78 SendAlgorithmSimulator::~SendAlgorithmSimulator() {} |
| 78 | 79 |
| 79 void SendAlgorithmSimulator::AddTransfer(Sender* sender, size_t num_bytes) { | 80 void SendAlgorithmSimulator::AddTransfer(Sender* sender, size_t num_bytes) { |
| 80 AddTransfer(sender, num_bytes, clock_->Now(), | 81 AddTransfer(sender, num_bytes, clock_->Now(), |
| 81 StringPrintf("#%zu", pending_transfers_.size())); | 82 StringPrintf("#%zu", pending_transfers_.size())); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void SendAlgorithmSimulator::AddTransfer( | 85 void SendAlgorithmSimulator::AddTransfer( |
| 85 Sender* sender, size_t num_bytes, QuicTime start_time, string name) { | 86 Sender* sender, size_t num_bytes, QuicTime start_time, std::string name) { |
| 86 pending_transfers_.push_back(Transfer(sender, num_bytes, start_time, name)); | 87 pending_transfers_.push_back(Transfer(sender, num_bytes, start_time, name)); |
| 87 // Record initial stats from when the transfer begins. | 88 // Record initial stats from when the transfer begins. |
| 88 pending_transfers_.back().sender->RecordStats(); | 89 pending_transfers_.back().sender->RecordStats(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void SendAlgorithmSimulator::TransferBytes() { | 92 void SendAlgorithmSimulator::TransferBytes() { |
| 92 TransferBytes(kuint64max, QuicTime::Delta::Infinite()); | 93 TransferBytes(kuint64max, QuicTime::Delta::Infinite()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes, | 96 void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 } | 387 } |
| 387 transfer->bytes_in_flight += kPacketSize; | 388 transfer->bytes_in_flight += kPacketSize; |
| 388 } | 389 } |
| 389 | 390 |
| 390 // Advance the time by |delta| without sending anything. | 391 // Advance the time by |delta| without sending anything. |
| 391 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { | 392 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { |
| 392 clock_->AdvanceTime(delta); | 393 clock_->AdvanceTime(delta); |
| 393 } | 394 } |
| 394 | 395 |
| 395 } // namespace net | 396 } // namespace net |
| OLD | NEW |