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 <set> | 8 #include <set> |
9 | 9 |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
11 #include "net/quic/quic_protocol.h" | 11 #include "net/quic/quic_protocol.h" |
12 #include "net/spdy/write_blocked_list.h" | 12 #include "net/spdy/write_blocked_list.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 // Keeps tracks of the QUIC streams that have data to write, sorted by | 16 // Keeps tracks of the QUIC streams that have data to write, sorted by |
17 // priority. QUIC stream priority order is: | 17 // priority. QUIC stream priority order is: |
18 // Crypto stream > Headers stream > Data streams by requested priority. | 18 // Crypto stream > Headers stream > Data streams by requested priority. |
19 class NET_EXPORT_PRIVATE QuicWriteBlockedList { | 19 class NET_EXPORT_PRIVATE QuicWriteBlockedList { |
20 private: | 20 private: |
21 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; | 21 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; |
22 | 22 |
23 public: | 23 public: |
24 static const QuicPriority kHighestPriority; | 24 static const QuicPriority kHighestPriority; |
25 static const QuicPriority kLowestPriority; | 25 static const QuicPriority kLowestPriority; |
26 | 26 |
27 QuicWriteBlockedList(); | 27 QuicWriteBlockedList(); |
28 ~QuicWriteBlockedList(); | 28 ~QuicWriteBlockedList(); |
29 | 29 |
30 bool HasWriteBlockedStreams() const { | 30 bool HasWriteBlockedDataStreams() const { |
31 return crypto_stream_blocked_ || | 31 return base_write_blocked_list_.HasWriteBlockedStreams(); |
32 headers_stream_blocked_ || | 32 } |
33 base_write_blocked_list_.HasWriteBlockedStreams(); | 33 |
| 34 bool HasWriteBlockedCryptoOrHeadersStream() const { |
| 35 return crypto_stream_blocked_ || headers_stream_blocked_; |
34 } | 36 } |
35 | 37 |
36 size_t NumBlockedStreams() const { | 38 size_t NumBlockedStreams() const { |
37 size_t num_blocked = base_write_blocked_list_.NumBlockedStreams(); | 39 size_t num_blocked = base_write_blocked_list_.NumBlockedStreams(); |
38 if (crypto_stream_blocked_) { | 40 if (crypto_stream_blocked_) { |
39 ++num_blocked; | 41 ++num_blocked; |
40 } | 42 } |
41 if (headers_stream_blocked_) { | 43 if (headers_stream_blocked_) { |
42 ++num_blocked; | 44 ++num_blocked; |
43 } | 45 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 DVLOG(1) << "Stream " << stream_id << " already in write blocked list."; | 84 DVLOG(1) << "Stream " << stream_id << " already in write blocked list."; |
83 return; | 85 return; |
84 } | 86 } |
85 | 87 |
86 base_write_blocked_list_.PushBack( | 88 base_write_blocked_list_.PushBack( |
87 stream_id, static_cast<SpdyPriority>(priority)); | 89 stream_id, static_cast<SpdyPriority>(priority)); |
88 blocked_streams_.insert(stream_id); | 90 blocked_streams_.insert(stream_id); |
89 return; | 91 return; |
90 } | 92 } |
91 | 93 |
| 94 bool crypto_stream_blocked() const { return crypto_stream_blocked_; } |
| 95 bool headers_stream_blocked() const { return headers_stream_blocked_; } |
| 96 |
92 private: | 97 private: |
93 QuicWriteBlockedListBase base_write_blocked_list_; | 98 QuicWriteBlockedListBase base_write_blocked_list_; |
94 bool crypto_stream_blocked_; | 99 bool crypto_stream_blocked_; |
95 bool headers_stream_blocked_; | 100 bool headers_stream_blocked_; |
96 | 101 |
97 // Keep track of write blocked streams in a set for faster membership checking | 102 // Keep track of write blocked streams in a set for faster membership checking |
98 // than iterating over the base_write_blocked_list_. The contents of this set | 103 // than iterating over the base_write_blocked_list_. The contents of this set |
99 // should mirror the contents of base_write_blocked_list_. | 104 // should mirror the contents of base_write_blocked_list_. |
100 std::set<QuicStreamId> blocked_streams_; | 105 std::set<QuicStreamId> blocked_streams_; |
101 | 106 |
102 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); | 107 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); |
103 }; | 108 }; |
104 | 109 |
105 } // namespace net | 110 } // namespace net |
106 | 111 |
107 | 112 |
108 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ | 113 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ |
OLD | NEW |