Index: net/quic/core/congestion_control/simulation/queue.h |
diff --git a/net/quic/core/congestion_control/simulation/queue.h b/net/quic/core/congestion_control/simulation/queue.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e76dc0ee96744c91a910f3683f8e97a4dbe8d8c5 |
--- /dev/null |
+++ b/net/quic/core/congestion_control/simulation/queue.h |
@@ -0,0 +1,54 @@ |
+#ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |
+#define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |
+ |
+#include "net/quic/core/congestion_control/simulation/link.h" |
+ |
+namespace net { |
+namespace simulation { |
+ |
+// A finitely sized queue which egresses packets onto a constrained link. The |
+// capacity of the queue is measured in bytes as opposed to packets. |
+class Queue : public Actor, public UnconstrainedPortInterface { |
+ public: |
+ class ListenerInterface { |
+ public: |
+ virtual ~ListenerInterface(); |
+ |
+ // Called whenever a packet is removed from the queue. |
+ virtual void OnPacketDequeued() = 0; |
+ }; |
+ |
+ Queue(Simulator* simulator, std::std::string name, QuicByteCount capacity); |
+ |
+ void set_tx_port(ConstrainedPortInterface* port); |
+ |
+ void AcceptPacket(std::unique_ptr<Packet> packet) override; |
+ |
+ void Act() override; |
+ |
+ inline QuicByteCount capacity() const { return capacity_; } |
+ inline QuicByteCount bytes_queued() const { return bytes_queued_; } |
+ inline QuicPacketCount packets_queued() const { return queue_.size(); } |
+ |
+ inline void set_listener_interface(ListenerInterface* std::listener) { |
+ std::listener_ = std::listener; |
+ } |
+ |
+ private: |
+ void ScheduleNextPacketDequeue(); |
+ |
+ const QuicByteCount capacity_; |
+ QuicByteCount bytes_queued_; |
+ |
+ ConstrainedPortInterface* tx_port_; |
+ std::queue<std::unique_ptr<Packet>> queue_; |
+ |
+ ListenerInterface* std::listener_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Queue); |
+}; |
+ |
+} // namespace simulation |
+} // namespace net |
+ |
+#endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |