OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_SPDY_SPDY_WRITE_QUEUE_H_ |
| 6 #define NET_SPDY_SPDY_WRITE_QUEUE_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/net_export.h" |
| 14 #include "net/base/request_priority.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 class SpdyFrameProducer; |
| 19 class SpdyStream; |
| 20 |
| 21 // A queue of SpdyFrameProducers to produce frames to write. Ordered |
| 22 // by priority, and then FIFO. |
| 23 class NET_EXPORT_PRIVATE SpdyWriteQueue { |
| 24 public: |
| 25 SpdyWriteQueue(); |
| 26 ~SpdyWriteQueue(); |
| 27 |
| 28 // Enqueues the given frame producer at the given priority |
| 29 // associated with the given stream, which may be NULL if the frame |
| 30 // producer is not associated with a stream. If |stream| is |
| 31 // non-NULL, its priority must be equal to |priority|. |
| 32 void Enqueue(RequestPriority priority, |
| 33 scoped_ptr<SpdyFrameProducer> frame_producer, |
| 34 const scoped_refptr<SpdyStream>& stream); |
| 35 |
| 36 // Dequeues the frame producer with the highest priority that was |
| 37 // enqueued the earliest and its associated stream. Returns true and |
| 38 // fills in |frame_producer| and |stream| if successful -- |
| 39 // otherwise, just returns false. |
| 40 bool Dequeue(scoped_ptr<SpdyFrameProducer>* frame_producer, |
| 41 scoped_refptr<SpdyStream>* stream); |
| 42 |
| 43 // Removes all pending writes for the given stream, which must be |
| 44 // non-NULL. |
| 45 void RemovePendingWritesForStream(const scoped_refptr<SpdyStream>& stream); |
| 46 |
| 47 // Removes all pending writes. |
| 48 void Clear(); |
| 49 |
| 50 private: |
| 51 // A struct holding a frame producer and its associated stream. |
| 52 struct PendingWrite { |
| 53 // This has to be a raw pointer since we store this in an STL |
| 54 // container. |
| 55 SpdyFrameProducer* frame_producer; |
| 56 scoped_refptr<SpdyStream> stream; |
| 57 |
| 58 PendingWrite(); |
| 59 PendingWrite(SpdyFrameProducer* frame_producer, |
| 60 const scoped_refptr<SpdyStream>& stream); |
| 61 ~PendingWrite(); |
| 62 }; |
| 63 |
| 64 // The actual write queue, binned by priority. |
| 65 std::deque<PendingWrite> queue_[NUM_PRIORITIES]; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(SpdyWriteQueue); |
| 68 }; |
| 69 |
| 70 } // namespace net |
| 71 |
| 72 #endif // NET_SPDY_SPDY_WRITE_QUEUE_H_ |
OLD | NEW |