OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 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_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
| 6 #define NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
| 7 |
| 8 #include "net/base/net_export.h" |
| 9 #include "net/quic/quic_protocol.h" |
| 10 #include "net/spdy/write_blocked_list.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 // Keeps tracks of the QUIC streams that have data to write, sorted by |
| 15 // priority. QUIC stream priority order is: |
| 16 // Crypto stream > Headers stream > Data streams by requested priority. |
| 17 class NET_EXPORT_PRIVATE QuicWriteBlockedList { |
| 18 private: |
| 19 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; |
| 20 |
| 21 public: |
| 22 static const QuicPriority kHighestPriority; |
| 23 static const QuicPriority kLowestPriority; |
| 24 |
| 25 QuicWriteBlockedList(); |
| 26 ~QuicWriteBlockedList(); |
| 27 |
| 28 bool HasWriteBlockedStreams() const { |
| 29 return crypto_stream_blocked_ || |
| 30 headers_stream_blocked_ || |
| 31 base_write_blocked_list_.HasWriteBlockedStreams(); |
| 32 } |
| 33 |
| 34 size_t NumBlockedStreams() const { |
| 35 int num_blocked = base_write_blocked_list_.NumBlockedStreams(); |
| 36 if (crypto_stream_blocked_) { |
| 37 ++num_blocked; |
| 38 } |
| 39 if (headers_stream_blocked_) { |
| 40 ++num_blocked; |
| 41 } |
| 42 |
| 43 return num_blocked; |
| 44 } |
| 45 |
| 46 QuicStreamId PopFront() { |
| 47 if (crypto_stream_blocked_) { |
| 48 crypto_stream_blocked_ = false; |
| 49 return kCryptoStreamId; |
| 50 } else if (headers_stream_blocked_) { |
| 51 headers_stream_blocked_ = false; |
| 52 return kHeadersStreamId; |
| 53 } else { |
| 54 SpdyPriority priority = |
| 55 base_write_blocked_list_.GetHighestPriorityWriteBlockedList(); |
| 56 return base_write_blocked_list_.PopFront(priority); |
| 57 } |
| 58 } |
| 59 |
| 60 // TODO(avd) Remove version argument when QUIC_VERSION_12 is deprecated. |
| 61 void PushBack(QuicStreamId stream_id, |
| 62 QuicPriority priority, |
| 63 QuicVersion version) { |
| 64 if (stream_id == kCryptoStreamId) { |
| 65 DCHECK_EQ(kHighestPriority, priority); |
| 66 // TODO(avd) Add DCHECK(!crypto_stream_blocked_) |
| 67 crypto_stream_blocked_ = true; |
| 68 } else if (version > QUIC_VERSION_12 && |
| 69 stream_id == kHeadersStreamId) { |
| 70 DCHECK_EQ(kHighestPriority, priority); |
| 71 // TODO(avd) Add DCHECK(!headers_stream_blocked_); |
| 72 headers_stream_blocked_ = true; |
| 73 } else { |
| 74 base_write_blocked_list_.PushBack( |
| 75 stream_id, static_cast<SpdyPriority>(priority)); |
| 76 } |
| 77 } |
| 78 |
| 79 private: |
| 80 QuicWriteBlockedListBase base_write_blocked_list_; |
| 81 bool crypto_stream_blocked_; |
| 82 bool headers_stream_blocked_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); |
| 85 }; |
| 86 |
| 87 } // namespace net |
| 88 |
| 89 |
| 90 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
OLD | NEW |