| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/platform/api/quic_logging.h" |
| 5 #include "net/quic/test_tools/simulator/queue.h" | 6 #include "net/quic/test_tools/simulator/queue.h" |
| 6 | 7 |
| 7 using std::string; | 8 using std::string; |
| 8 | 9 |
| 9 namespace net { | 10 namespace net { |
| 10 namespace simulator { | 11 namespace simulator { |
| 11 | 12 |
| 12 Queue::ListenerInterface::~ListenerInterface() {} | 13 Queue::ListenerInterface::~ListenerInterface() {} |
| 13 | 14 |
| 14 Queue::Queue(Simulator* simulator, string name, QuicByteCount capacity) | 15 Queue::Queue(Simulator* simulator, string name, QuicByteCount capacity) |
| 15 : Actor(simulator, name), | 16 : Actor(simulator, name), |
| 16 capacity_(capacity), | 17 capacity_(capacity), |
| 17 bytes_queued_(0), | 18 bytes_queued_(0), |
| 18 listener_(nullptr) {} | 19 listener_(nullptr) {} |
| 19 | 20 |
| 20 Queue::~Queue() {} | 21 Queue::~Queue() {} |
| 21 | 22 |
| 22 void Queue::set_tx_port(ConstrainedPortInterface* port) { | 23 void Queue::set_tx_port(ConstrainedPortInterface* port) { |
| 23 tx_port_ = port; | 24 tx_port_ = port; |
| 24 } | 25 } |
| 25 | 26 |
| 26 void Queue::AcceptPacket(std::unique_ptr<Packet> packet) { | 27 void Queue::AcceptPacket(std::unique_ptr<Packet> packet) { |
| 27 if (packet->size + bytes_queued_ > capacity_) { | 28 if (packet->size + bytes_queued_ > capacity_) { |
| 28 DVLOG(1) << "Queue [" << name() << "] has received a packet from [" | 29 QUIC_DVLOG(1) << "Queue [" << name() << "] has received a packet from [" |
| 29 << packet->source << "] to [" << packet->destination | 30 << packet->source << "] to [" << packet->destination |
| 30 << "] which is over capacity. Dropping it."; | 31 << "] which is over capacity. Dropping it."; |
| 31 DVLOG(1) << "Queue size: " << bytes_queued_ << " out of " << capacity_ | 32 QUIC_DVLOG(1) << "Queue size: " << bytes_queued_ << " out of " << capacity_ |
| 32 << ". Packet size: " << packet->size; | 33 << ". Packet size: " << packet->size; |
| 33 return; | 34 return; |
| 34 } | 35 } |
| 35 | 36 |
| 36 bytes_queued_ += packet->size; | 37 bytes_queued_ += packet->size; |
| 37 queue_.emplace(std::move(packet)); | 38 queue_.emplace(std::move(packet)); |
| 38 ScheduleNextPacketDequeue(); | 39 ScheduleNextPacketDequeue(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void Queue::Act() { | 42 void Queue::Act() { |
| 42 DCHECK(!queue_.empty()); | 43 DCHECK(!queue_.empty()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 if (queue_.empty()) { | 59 if (queue_.empty()) { |
| 59 DCHECK_EQ(bytes_queued_, 0u); | 60 DCHECK_EQ(bytes_queued_, 0u); |
| 60 return; | 61 return; |
| 61 } | 62 } |
| 62 | 63 |
| 63 Schedule(clock_->Now() + tx_port_->TimeUntilAvailable()); | 64 Schedule(clock_->Now() + tx_port_->TimeUntilAvailable()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace simulator | 67 } // namespace simulator |
| 67 } // namespace net | 68 } // namespace net |
| OLD | NEW |