OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SPDY_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_STREAM_H_ |
6 #define NET_SPDY_SPDY_STREAM_H_ | 6 #define NET_SPDY_SPDY_STREAM_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 }; | 47 }; |
48 | 48 |
49 // Passed to some SpdyStream functions to indicate whether there's | 49 // Passed to some SpdyStream functions to indicate whether there's |
50 // more data to send. | 50 // more data to send. |
51 enum SpdySendStatus { | 51 enum SpdySendStatus { |
52 MORE_DATA_TO_SEND, | 52 MORE_DATA_TO_SEND, |
53 NO_MORE_DATA_TO_SEND | 53 NO_MORE_DATA_TO_SEND |
54 }; | 54 }; |
55 | 55 |
56 // Returned by SpdyStream::OnResponseHeadersUpdated() to indicate | 56 // Returned by SpdyStream::OnResponseHeadersUpdated() to indicate |
57 // whether the current response headers are complete or not. | 57 // whether the current response headers are complete or not, or whether |
58 // trailers have been received. TRAILERS_RECEIVED denotes the state where | |
59 // headers are received after DATA frames, and this state also implies that | |
60 // response headers are complete. | |
Ryan Hamilton
2015/08/10 22:37:38
It looks like (from comments in the .cc file) that
xunjieli
2015/08/11 15:07:14
Done.
| |
58 enum SpdyResponseHeadersStatus { | 61 enum SpdyResponseHeadersStatus { |
59 RESPONSE_HEADERS_ARE_INCOMPLETE, | 62 RESPONSE_HEADERS_ARE_INCOMPLETE, |
60 RESPONSE_HEADERS_ARE_COMPLETE | 63 RESPONSE_HEADERS_ARE_COMPLETE, |
64 TRAILERS_RECEIVED, | |
61 }; | 65 }; |
62 | 66 |
63 // The SpdyStream is used by the SpdySession to represent each stream known | 67 // The SpdyStream is used by the SpdySession to represent each stream known |
64 // on the SpdySession. This class provides interfaces for SpdySession to use. | 68 // on the SpdySession. This class provides interfaces for SpdySession to use. |
65 // Streams can be created either by the client or by the server. When they | 69 // Streams can be created either by the client or by the server. When they |
66 // are initiated by the client, both the SpdySession and client object (such as | 70 // are initiated by the client, both the SpdySession and client object (such as |
67 // a SpdyNetworkTransaction) will maintain a reference to the stream. When | 71 // a SpdyNetworkTransaction) will maintain a reference to the stream. When |
68 // initiated by the server, only the SpdySession will maintain any reference, | 72 // initiated by the server, only the SpdySession will maintain any reference, |
69 // until such a time as a client object requests a stream for the path. | 73 // until such a time as a client object requests a stream for the path. |
70 class NET_EXPORT_PRIVATE SpdyStream { | 74 class NET_EXPORT_PRIVATE SpdyStream { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 // exactly once before data is received, and it is expected | 116 // exactly once before data is received, and it is expected |
113 // that RESPONSE_HEADERS_ARE_COMPLETE is returned. If | 117 // that RESPONSE_HEADERS_ARE_COMPLETE is returned. If |
114 // RESPONSE_HEADERS_ARE_INCOMPLETE is returned, this is | 118 // RESPONSE_HEADERS_ARE_INCOMPLETE is returned, this is |
115 // treated as a protocol error. | 119 // treated as a protocol error. |
116 // | 120 // |
117 // - For push streams, it is expected that this function will be | 121 // - For push streams, it is expected that this function will be |
118 // called until RESPONSE_HEADERS_ARE_COMPLETE is returned | 122 // called until RESPONSE_HEADERS_ARE_COMPLETE is returned |
119 // before any data is received; any deviation from this is | 123 // before any data is received; any deviation from this is |
120 // treated as a protocol error. | 124 // treated as a protocol error. |
121 // | 125 // |
122 // TODO(akalin): Treat headers received after data has been | |
123 // received as a protocol error for non-bidirectional streams. | |
124 // TODO(jgraettinger): This should be at the semantic (HTTP) rather | 126 // TODO(jgraettinger): This should be at the semantic (HTTP) rather |
125 // than stream layer. Streams shouldn't have a notion of header | 127 // than stream layer. Streams shouldn't have a notion of header |
126 // completeness. Move to SpdyHttpStream/SpdyWebsocketStream. | 128 // completeness. Move to SpdyHttpStream/SpdyWebsocketStream. |
127 virtual SpdyResponseHeadersStatus OnResponseHeadersUpdated( | 129 virtual SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
128 const SpdyHeaderBlock& response_headers) = 0; | 130 const SpdyHeaderBlock& response_headers) = 0; |
129 | 131 |
130 // Called when data is received after all required response | 132 // Called when data is received after all required response |
131 // headers have been received. |buffer| may be NULL, which signals | 133 // headers have been received. |buffer| may be NULL, which signals |
132 // EOF. Must return OK if the data was received successfully, or | 134 // EOF. Must return OK if the data was received successfully, or |
133 // a network error code otherwise. | 135 // a network error code otherwise. |
134 // | 136 // |
135 // May cause the stream to be closed. | 137 // May cause the stream to be closed. |
136 virtual void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0; | 138 virtual void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0; |
137 | 139 |
138 // Called when data is sent. Must not cause the stream to be | 140 // Called when data is sent. Must not cause the stream to be |
139 // closed. | 141 // closed. |
140 virtual void OnDataSent() = 0; | 142 virtual void OnDataSent() = 0; |
141 | 143 |
144 // Called when trailers are received. Note that trailers HEADER frame will | |
145 // have END_STREAM flag set according to section 8.1 of the HTTP/2 RFC, | |
146 // so this will be followed by OnClose. | |
147 virtual void OnTrailers(const SpdyHeaderBlock& trailers) = 0; | |
148 | |
142 // Called when SpdyStream is closed. No other delegate functions | 149 // Called when SpdyStream is closed. No other delegate functions |
143 // will be called after this is called, and the delegate must not | 150 // will be called after this is called, and the delegate must not |
144 // access the stream after this is called. Must not cause the | 151 // access the stream after this is called. Must not cause the |
145 // stream to be be (re-)closed. | 152 // stream to be be (re-)closed. |
146 // | 153 // |
147 // TODO(akalin): Allow this function to re-close the stream and | 154 // TODO(akalin): Allow this function to re-close the stream and |
148 // handle it gracefully. | 155 // handle it gracefully. |
149 virtual void OnClose(int status) = 0; | 156 virtual void OnClose(int status) = 0; |
150 | 157 |
151 protected: | 158 protected: |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 bool write_handler_guard_; | 581 bool write_handler_guard_; |
575 | 582 |
576 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; | 583 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; |
577 | 584 |
578 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 585 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
579 }; | 586 }; |
580 | 587 |
581 } // namespace net | 588 } // namespace net |
582 | 589 |
583 #endif // NET_SPDY_SPDY_STREAM_H_ | 590 #endif // NET_SPDY_SPDY_STREAM_H_ |
OLD | NEW |