Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: net/quic/quic_write_blocked_list.h

Issue 989523005: Avoid duplicates in SPDY's write blocked list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use hash_map. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 explicit QuicWriteBlockedList(bool avoid_duplicate_streams);
28 ~QuicWriteBlockedList(); 28 ~QuicWriteBlockedList();
29 29
30 bool HasWriteBlockedDataStreams() const { 30 bool HasWriteBlockedDataStreams() const {
31 return base_write_blocked_list_.HasWriteBlockedStreams(); 31 return base_write_blocked_list_.HasWriteBlockedStreams();
32 } 32 }
33 33
34 bool HasWriteBlockedCryptoOrHeadersStream() const { 34 bool HasWriteBlockedCryptoOrHeadersStream() const {
35 return crypto_stream_blocked_ || headers_stream_blocked_; 35 return crypto_stream_blocked_ || headers_stream_blocked_;
36 } 36 }
37 37
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return; 73 return;
74 } 74 }
75 75
76 if (stream_id == kHeadersStreamId) { 76 if (stream_id == kHeadersStreamId) {
77 DCHECK_EQ(kHighestPriority, priority); 77 DCHECK_EQ(kHighestPriority, priority);
78 // TODO(avd) Add DCHECK(!headers_stream_blocked_); 78 // TODO(avd) Add DCHECK(!headers_stream_blocked_);
79 headers_stream_blocked_ = true; 79 headers_stream_blocked_ = true;
80 return; 80 return;
81 } 81 }
82 82
83 if (blocked_streams_.find(stream_id) != blocked_streams_.end()) { 83 if (!base_write_blocked_list_.avoids_inserting_duplicates() &&
84 blocked_streams_.find(stream_id) != blocked_streams_.end()) {
84 DVLOG(1) << "Stream " << stream_id << " already in write blocked list."; 85 DVLOG(1) << "Stream " << stream_id << " already in write blocked list.";
85 return; 86 return;
86 } 87 }
87 88
88 base_write_blocked_list_.PushBack( 89 base_write_blocked_list_.PushBack(
89 stream_id, static_cast<SpdyPriority>(priority)); 90 stream_id, static_cast<SpdyPriority>(priority));
90 blocked_streams_.insert(stream_id); 91 blocked_streams_.insert(stream_id);
91 return; 92 return;
92 } 93 }
93 94
(...skipping 10 matching lines...) Expand all
104 // should mirror the contents of base_write_blocked_list_. 105 // should mirror the contents of base_write_blocked_list_.
105 std::set<QuicStreamId> blocked_streams_; 106 std::set<QuicStreamId> blocked_streams_;
106 107
107 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); 108 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList);
108 }; 109 };
109 110
110 } // namespace net 111 } // namespace net
111 112
112 113
113 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ 114 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698