| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ | 5 #ifndef NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
| 6 #define NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ | 6 #define NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
| 7 | 7 |
| 8 #include "net/base/net_export.h" | 8 #include "net/base/net_export.h" |
| 9 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
| 10 #include "net/spdy/write_blocked_list.h" | 10 #include "net/spdy/write_blocked_list.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 // Keeps tracks of the QUIC streams that have data to write, sorted by | 14 // Keeps tracks of the QUIC streams that have data to write, sorted by |
| 15 // priority. QUIC stream priority order is: | 15 // priority. QUIC stream priority order is: |
| 16 // Crypto stream > Headers stream > Data streams by requested priority. | 16 // Crypto stream > Headers stream > Data streams by requested priority. |
| 17 class NET_EXPORT_PRIVATE QuicWriteBlockedList { | 17 class NET_EXPORT_PRIVATE QuicWriteBlockedList { |
| 18 private: | 18 private: |
| 19 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; | 19 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; |
| 20 | 20 |
| 21 public: | 21 public: |
| 22 static const QuicPriority kHighestPriority; | 22 static const QuicPriority kHighestPriority; |
| 23 static const QuicPriority kLowestPriority; | 23 static const QuicPriority kLowestPriority; |
| 24 | 24 |
| 25 QuicWriteBlockedList(); | 25 QuicWriteBlockedList(); |
| 26 ~QuicWriteBlockedList(); | 26 ~QuicWriteBlockedList(); |
| 27 | 27 |
| 28 bool HasWriteBlockedStreams() const { | 28 bool HasWriteBlockedStreams() const { |
| 29 return crypto_stream_blocked_ || | 29 return crypto_stream_blocked_ || headers_stream_blocked_ || |
| 30 headers_stream_blocked_ || | 30 base_write_blocked_list_.HasWriteBlockedStreams(); |
| 31 base_write_blocked_list_.HasWriteBlockedStreams(); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 size_t NumBlockedStreams() const { | 33 size_t NumBlockedStreams() const { |
| 35 size_t num_blocked = base_write_blocked_list_.NumBlockedStreams(); | 34 size_t num_blocked = base_write_blocked_list_.NumBlockedStreams(); |
| 36 if (crypto_stream_blocked_) { | 35 if (crypto_stream_blocked_) { |
| 37 ++num_blocked; | 36 ++num_blocked; |
| 38 } | 37 } |
| 39 if (headers_stream_blocked_) { | 38 if (headers_stream_blocked_) { |
| 40 ++num_blocked; | 39 ++num_blocked; |
| 41 } | 40 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 void PushBack(QuicStreamId stream_id, QuicPriority priority) { | 59 void PushBack(QuicStreamId stream_id, QuicPriority priority) { |
| 61 if (stream_id == kCryptoStreamId) { | 60 if (stream_id == kCryptoStreamId) { |
| 62 DCHECK_EQ(kHighestPriority, priority); | 61 DCHECK_EQ(kHighestPriority, priority); |
| 63 // TODO(avd) Add DCHECK(!crypto_stream_blocked_) | 62 // TODO(avd) Add DCHECK(!crypto_stream_blocked_) |
| 64 crypto_stream_blocked_ = true; | 63 crypto_stream_blocked_ = true; |
| 65 } else if (stream_id == kHeadersStreamId) { | 64 } else if (stream_id == kHeadersStreamId) { |
| 66 DCHECK_EQ(kHighestPriority, priority); | 65 DCHECK_EQ(kHighestPriority, priority); |
| 67 // TODO(avd) Add DCHECK(!headers_stream_blocked_); | 66 // TODO(avd) Add DCHECK(!headers_stream_blocked_); |
| 68 headers_stream_blocked_ = true; | 67 headers_stream_blocked_ = true; |
| 69 } else { | 68 } else { |
| 70 base_write_blocked_list_.PushBack( | 69 base_write_blocked_list_.PushBack(stream_id, |
| 71 stream_id, static_cast<SpdyPriority>(priority)); | 70 static_cast<SpdyPriority>(priority)); |
| 72 } | 71 } |
| 73 } | 72 } |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 QuicWriteBlockedListBase base_write_blocked_list_; | 75 QuicWriteBlockedListBase base_write_blocked_list_; |
| 77 bool crypto_stream_blocked_; | 76 bool crypto_stream_blocked_; |
| 78 bool headers_stream_blocked_; | 77 bool headers_stream_blocked_; |
| 79 | 78 |
| 80 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); | 79 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 } // namespace net | 82 } // namespace net |
| 84 | 83 |
| 85 | |
| 86 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ | 84 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
| OLD | NEW |