| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 NET_SPDY_SPDY_WRITE_QUEUE_H_ | 5 #ifndef NET_SPDY_SPDY_WRITE_QUEUE_H_ |
| 6 #define NET_SPDY_SPDY_WRITE_QUEUE_H_ | 6 #define NET_SPDY_SPDY_WRITE_QUEUE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // non-NULL. | 52 // non-NULL. |
| 53 void RemovePendingWritesForStream(const base::WeakPtr<SpdyStream>& stream); | 53 void RemovePendingWritesForStream(const base::WeakPtr<SpdyStream>& stream); |
| 54 | 54 |
| 55 // Removes all pending writes for streams after |last_good_stream_id| | 55 // Removes all pending writes for streams after |last_good_stream_id| |
| 56 // and streams with no stream id. | 56 // and streams with no stream id. |
| 57 void RemovePendingWritesForStreamsAfter(SpdyStreamId last_good_stream_id); | 57 void RemovePendingWritesForStreamsAfter(SpdyStreamId last_good_stream_id); |
| 58 | 58 |
| 59 // Removes all pending writes. | 59 // Removes all pending writes. |
| 60 void Clear(); | 60 void Clear(); |
| 61 | 61 |
| 62 // Returns the estimate of dynamically allocated memory in bytes. |
| 63 size_t EstimateMemoryUsage() const; |
| 64 |
| 62 private: | 65 private: |
| 63 // A struct holding a frame producer and its associated stream. | 66 // A struct holding a frame producer and its associated stream. |
| 64 struct PendingWrite { | 67 struct PendingWrite { |
| 65 SpdyFrameType frame_type; | 68 SpdyFrameType frame_type; |
| 66 std::unique_ptr<SpdyBufferProducer> frame_producer; | 69 std::unique_ptr<SpdyBufferProducer> frame_producer; |
| 67 base::WeakPtr<SpdyStream> stream; | 70 base::WeakPtr<SpdyStream> stream; |
| 68 // Whether |stream| was non-NULL when enqueued. | 71 // Whether |stream| was non-NULL when enqueued. |
| 69 bool has_stream; | 72 bool has_stream; |
| 70 | 73 |
| 71 PendingWrite(); | 74 PendingWrite(); |
| 72 PendingWrite(SpdyFrameType frame_type, | 75 PendingWrite(SpdyFrameType frame_type, |
| 73 std::unique_ptr<SpdyBufferProducer> frame_producer, | 76 std::unique_ptr<SpdyBufferProducer> frame_producer, |
| 74 const base::WeakPtr<SpdyStream>& stream); | 77 const base::WeakPtr<SpdyStream>& stream); |
| 75 ~PendingWrite(); | 78 ~PendingWrite(); |
| 76 PendingWrite(PendingWrite&& other); | 79 PendingWrite(PendingWrite&& other); |
| 77 PendingWrite& operator=(PendingWrite&& other); | 80 PendingWrite& operator=(PendingWrite&& other); |
| 78 | 81 |
| 82 size_t EstimateMemoryUsage() const; |
| 83 |
| 79 DISALLOW_COPY_AND_ASSIGN(PendingWrite); | 84 DISALLOW_COPY_AND_ASSIGN(PendingWrite); |
| 80 }; | 85 }; |
| 81 | 86 |
| 82 bool removing_writes_; | 87 bool removing_writes_; |
| 83 | 88 |
| 84 // The actual write queue, binned by priority. | 89 // The actual write queue, binned by priority. |
| 85 std::deque<PendingWrite> queue_[NUM_PRIORITIES]; | 90 std::deque<PendingWrite> queue_[NUM_PRIORITIES]; |
| 86 | 91 |
| 87 DISALLOW_COPY_AND_ASSIGN(SpdyWriteQueue); | 92 DISALLOW_COPY_AND_ASSIGN(SpdyWriteQueue); |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 } // namespace net | 95 } // namespace net |
| 91 | 96 |
| 92 #endif // NET_SPDY_SPDY_WRITE_QUEUE_H_ | 97 #endif // NET_SPDY_SPDY_WRITE_QUEUE_H_ |
| OLD | NEW |