| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_HTTP2_WRITE_SCHEDULER_H_ | 5 #ifndef NET_SPDY_HTTP2_WRITE_SCHEDULER_H_ |
| 6 #define NET_SPDY_HTTP2_WRITE_SCHEDULER_H_ | 6 #define NET_SPDY_HTTP2_WRITE_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 bool ValidateInvariantsForTests() const; | 161 bool ValidateInvariantsForTests() const; |
| 162 | 162 |
| 163 // Returns true if the parent stream has the given stream in its children. | 163 // Returns true if the parent stream has the given stream in its children. |
| 164 bool StreamHasChild(const StreamInfo& parent_info, | 164 bool StreamHasChild(const StreamInfo& parent_info, |
| 165 const StreamInfo* child_info) const; | 165 const StreamInfo* child_info) const; |
| 166 | 166 |
| 167 // Pointee owned by all_stream_infos_. | 167 // Pointee owned by all_stream_infos_. |
| 168 StreamInfo* root_stream_info_; | 168 StreamInfo* root_stream_info_; |
| 169 // Maps from stream IDs to StreamInfo objects. | 169 // Maps from stream IDs to StreamInfo objects. |
| 170 StreamInfoMap all_stream_infos_; | 170 StreamInfoMap all_stream_infos_; |
| 171 STLValueDeleter<StreamInfoMap> all_stream_infos_deleter_; | 171 base::STLValueDeleter<StreamInfoMap> all_stream_infos_deleter_; |
| 172 // Queue containing all ready streams, ordered with streams of higher | 172 // Queue containing all ready streams, ordered with streams of higher |
| 173 // priority before streams of lower priority, and, among streams of equal | 173 // priority before streams of lower priority, and, among streams of equal |
| 174 // priority, streams with lower ordinal before those with higher | 174 // priority, streams with lower ordinal before those with higher |
| 175 // ordinal. Note that not all streams in scheduling_queue_ are eligible to be | 175 // ordinal. Note that not all streams in scheduling_queue_ are eligible to be |
| 176 // picked as the next stream: some may have ancestor stream(s) that are ready | 176 // picked as the next stream: some may have ancestor stream(s) that are ready |
| 177 // and unblocked. In these situations the occluded child streams are left in | 177 // and unblocked. In these situations the occluded child streams are left in |
| 178 // the queue, to reduce churn. | 178 // the queue, to reduce churn. |
| 179 base::LinkedList<StreamInfo> scheduling_queue_; | 179 base::LinkedList<StreamInfo> scheduling_queue_; |
| 180 // Ordinal value to assign to next node inserted into scheduling_queue_ when | 180 // Ordinal value to assign to next node inserted into scheduling_queue_ when |
| 181 // |add_to_front == true|. Decremented after each assignment. | 181 // |add_to_front == true|. Decremented after each assignment. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 200 } | 200 } |
| 201 | 201 |
| 202 template <typename StreamIdType> | 202 template <typename StreamIdType> |
| 203 int Http2PriorityWriteScheduler<StreamIdType>::num_streams() const { | 203 int Http2PriorityWriteScheduler<StreamIdType>::num_streams() const { |
| 204 return all_stream_infos_.size(); | 204 return all_stream_infos_.size(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 template <typename StreamIdType> | 207 template <typename StreamIdType> |
| 208 bool Http2PriorityWriteScheduler<StreamIdType>::StreamRegistered( | 208 bool Http2PriorityWriteScheduler<StreamIdType>::StreamRegistered( |
| 209 StreamIdType stream_id) const { | 209 StreamIdType stream_id) const { |
| 210 return ContainsKey(all_stream_infos_, stream_id); | 210 return base::ContainsKey(all_stream_infos_, stream_id); |
| 211 } | 211 } |
| 212 | 212 |
| 213 template <typename StreamIdType> | 213 template <typename StreamIdType> |
| 214 void Http2PriorityWriteScheduler<StreamIdType>::RegisterStream( | 214 void Http2PriorityWriteScheduler<StreamIdType>::RegisterStream( |
| 215 StreamIdType stream_id, | 215 StreamIdType stream_id, |
| 216 const StreamPrecedenceType& precedence) { | 216 const StreamPrecedenceType& precedence) { |
| 217 SPDY_BUG_IF(precedence.is_spdy3_priority()) | 217 SPDY_BUG_IF(precedence.is_spdy3_priority()) |
| 218 << "Expected HTTP/2 stream dependency"; | 218 << "Expected HTTP/2 stream dependency"; |
| 219 | 219 |
| 220 if (StreamRegistered(stream_id)) { | 220 if (StreamRegistered(stream_id)) { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 735 } |
| 736 // Validate the validation function; we should have visited each stream twice | 736 // Validate the validation function; we should have visited each stream twice |
| 737 // (except for the root) | 737 // (except for the root) |
| 738 DCHECK(streams_visited == 2 * num_streams() - 1); | 738 DCHECK(streams_visited == 2 * num_streams() - 1); |
| 739 return true; | 739 return true; |
| 740 } | 740 } |
| 741 | 741 |
| 742 } // namespace net | 742 } // namespace net |
| 743 | 743 |
| 744 #endif // NET_SPDY_HTTP2_WRITE_SCHEDULER_H_ | 744 #endif // NET_SPDY_HTTP2_WRITE_SCHEDULER_H_ |
| OLD | NEW |