OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_CORE_WRITE_SCHEDULER_H_ | 5 #ifndef NET_SPDY_CORE_WRITE_SCHEDULER_H_ |
6 #define NET_SPDY_CORE_WRITE_SCHEDULER_H_ | 6 #define NET_SPDY_CORE_WRITE_SCHEDULER_H_ |
7 | 7 |
8 #include <tuple> | 8 #include <tuple> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "net/base/net_export.h" | |
12 #include "net/spdy/core/spdy_protocol.h" | 11 #include "net/spdy/core/spdy_protocol.h" |
| 12 #include "net/spdy/platform/api/spdy_export.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 // Abstract superclass for classes that decide which SPDY or HTTP/2 stream to | 16 // Abstract superclass for classes that decide which SPDY or HTTP/2 stream to |
17 // write next. Concrete subclasses implement various scheduling policies: | 17 // write next. Concrete subclasses implement various scheduling policies: |
18 // | 18 // |
19 // PriorityWriteScheduler: implements SPDY priority-based stream scheduling, | 19 // PriorityWriteScheduler: implements SPDY priority-based stream scheduling, |
20 // where (writable) higher-priority streams are always given precedence | 20 // where (writable) higher-priority streams are always given precedence |
21 // over lower-priority streams. | 21 // over lower-priority streams. |
22 // | 22 // |
23 // Http2PriorityWriteScheduler: implements SPDY priority-based stream | 23 // Http2PriorityWriteScheduler: implements SPDY priority-based stream |
24 // scheduling coupled with the HTTP/2 stream dependency model. This is only | 24 // scheduling coupled with the HTTP/2 stream dependency model. This is only |
25 // intended as a transitional step towards Http2WeightedWriteScheduler. | 25 // intended as a transitional step towards Http2WeightedWriteScheduler. |
26 // | 26 // |
27 // Http2WeightedWriteScheduler (coming soon): implements the HTTP/2 stream | 27 // Http2WeightedWriteScheduler (coming soon): implements the HTTP/2 stream |
28 // dependency model with weighted stream scheduling, fully conforming to | 28 // dependency model with weighted stream scheduling, fully conforming to |
29 // RFC 7540. | 29 // RFC 7540. |
30 // | 30 // |
31 // The type used to represent stream IDs (StreamIdType) is templated in order | 31 // The type used to represent stream IDs (StreamIdType) is templated in order |
32 // to allow for use by both SPDY and QUIC codebases. It must be a POD that | 32 // to allow for use by both SPDY and QUIC codebases. It must be a POD that |
33 // supports comparison (i.e., a numeric type). | 33 // supports comparison (i.e., a numeric type). |
34 // | 34 // |
35 // Each stream can be in one of two states: ready or not ready (for writing). | 35 // Each stream can be in one of two states: ready or not ready (for writing). |
36 // Ready state is changed by calling the MarkStreamReady() and | 36 // Ready state is changed by calling the MarkStreamReady() and |
37 // MarkStreamNotReady() methods. Only streams in the ready state can be | 37 // MarkStreamNotReady() methods. Only streams in the ready state can be |
38 // returned by PopNextReadyStream(); when returned by that method, the stream's | 38 // returned by PopNextReadyStream(); when returned by that method, the stream's |
39 // state changes to not ready. | 39 // state changes to not ready. |
40 template <typename StreamIdType> | 40 template <typename StreamIdType> |
41 class NET_EXPORT_PRIVATE WriteScheduler { | 41 class SPDY_EXPORT_PRIVATE WriteScheduler { |
42 public: | 42 public: |
43 typedef StreamPrecedence<StreamIdType> StreamPrecedenceType; | 43 typedef StreamPrecedence<StreamIdType> StreamPrecedenceType; |
44 | 44 |
45 virtual ~WriteScheduler() {} | 45 virtual ~WriteScheduler() {} |
46 | 46 |
47 // Registers new stream |stream_id| with the scheduler, assigning it the | 47 // Registers new stream |stream_id| with the scheduler, assigning it the |
48 // given precedence. If the scheduler supports stream dependencies, the | 48 // given precedence. If the scheduler supports stream dependencies, the |
49 // stream is inserted into the dependency tree under | 49 // stream is inserted into the dependency tree under |
50 // |precedence.parent_id()|. | 50 // |precedence.parent_id()|. |
51 // | 51 // |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Returns true iff the scheduler has any ready streams. | 142 // Returns true iff the scheduler has any ready streams. |
143 virtual bool HasReadyStreams() const = 0; | 143 virtual bool HasReadyStreams() const = 0; |
144 | 144 |
145 // Returns the number of streams currently marked ready. | 145 // Returns the number of streams currently marked ready. |
146 virtual size_t NumReadyStreams() const = 0; | 146 virtual size_t NumReadyStreams() const = 0; |
147 }; | 147 }; |
148 | 148 |
149 } // namespace net | 149 } // namespace net |
150 | 150 |
151 #endif // NET_SPDY_CORE_WRITE_SCHEDULER_H_ | 151 #endif // NET_SPDY_CORE_WRITE_SCHEDULER_H_ |
OLD | NEW |