Chromium Code Reviews| 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 // NOTE: This code is not shared between Google and Chrome. | 5 // NOTE: This code is not shared between Google and Chrome. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ | 7 #ifndef NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ |
| 8 #define NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ | 8 #define NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 150 |
| 151 // Constucts a new Handle for |stream| with |delegate| set to receive | 151 // Constucts a new Handle for |stream| with |delegate| set to receive |
| 152 // up calls on various events. | 152 // up calls on various events. |
| 153 Handle(QuicChromiumClientStream* stream, Delegate* delegate); | 153 Handle(QuicChromiumClientStream* stream, Delegate* delegate); |
| 154 | 154 |
| 155 // Methods invoked by the stream. | 155 // Methods invoked by the stream. |
| 156 void OnInitialHeadersAvailable(); | 156 void OnInitialHeadersAvailable(); |
| 157 void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, | 157 void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, |
| 158 size_t frame_len); | 158 size_t frame_len); |
| 159 void OnDataAvailable(); | 159 void OnDataAvailable(); |
| 160 void OnCanWrite(); | |
| 160 void OnClose(); | 161 void OnClose(); |
| 161 void OnError(int error); | 162 void OnError(int error); |
| 162 | 163 |
| 163 // Saves various fields from the stream before the stream goes away. | 164 // Saves various fields from the stream before the stream goes away. |
| 164 void SaveState(); | 165 void SaveState(); |
| 165 | 166 |
| 166 QuicChromiumClientStream* stream_; // Unowned. | 167 QuicChromiumClientStream* stream_; // Unowned. |
| 167 Delegate* delegate_; // Owns this. | 168 Delegate* delegate_; // Owns this. |
| 168 | 169 |
| 170 // Callback to be invoked when ReadHeaders completes asynchronously. | |
| 169 CompletionCallback read_headers_callback_; | 171 CompletionCallback read_headers_callback_; |
| 170 SpdyHeaderBlock* read_headers_buffer_; | 172 SpdyHeaderBlock* read_headers_buffer_; |
| 171 | 173 |
| 174 // Callback to be invoked when ReadBody completes asynchronously. | |
| 172 CompletionCallback read_body_callback_; | 175 CompletionCallback read_body_callback_; |
| 173 IOBuffer* read_body_buffer_; | 176 IOBuffer* read_body_buffer_; |
| 174 int read_body_buffer_len_; | 177 int read_body_buffer_len_; |
| 175 | 178 |
| 179 // Callback to be invoked when WriteStreamData or WritevStreamData completes | |
| 180 // asynchronously. | |
| 181 CompletionCallback write_callback_; | |
| 182 | |
| 176 QuicStreamId id_; | 183 QuicStreamId id_; |
| 177 QuicErrorCode connection_error_; | 184 QuicErrorCode connection_error_; |
| 178 QuicRstStreamErrorCode stream_error_; | 185 QuicRstStreamErrorCode stream_error_; |
| 179 bool fin_sent_; | 186 bool fin_sent_; |
| 180 bool fin_received_; | 187 bool fin_received_; |
| 181 uint64_t stream_bytes_read_; | 188 uint64_t stream_bytes_read_; |
| 182 uint64_t stream_bytes_written_; | 189 uint64_t stream_bytes_written_; |
| 183 bool is_done_reading_; | 190 bool is_done_reading_; |
| 184 bool is_first_stream_; | 191 bool is_first_stream_; |
| 185 size_t num_bytes_consumed_; | 192 size_t num_bytes_consumed_; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 210 size_t WriteHeaders(SpdyHeaderBlock header_block, | 217 size_t WriteHeaders(SpdyHeaderBlock header_block, |
| 211 bool fin, | 218 bool fin, |
| 212 QuicReferenceCountedPointer<QuicAckListenerInterface> | 219 QuicReferenceCountedPointer<QuicAckListenerInterface> |
| 213 ack_listener) override; | 220 ack_listener) override; |
| 214 SpdyPriority priority() const override; | 221 SpdyPriority priority() const override; |
| 215 | 222 |
| 216 // While the server's set_priority shouldn't be called externally, the creator | 223 // While the server's set_priority shouldn't be called externally, the creator |
| 217 // of client-side streams should be able to set the priority. | 224 // of client-side streams should be able to set the priority. |
| 218 using QuicSpdyStream::SetPriority; | 225 using QuicSpdyStream::SetPriority; |
| 219 | 226 |
| 220 int WriteStreamData(QuicStringPiece data, | 227 // Writes |data| to the peer, loses the write side if |fin| is true and |
|
xunjieli
2017/05/15 15:48:36
minor nit: Maybe break the sentence after "and" or
xunjieli
2017/05/15 15:48:36
nit: loses/closes
Ryan Hamilton
2017/05/20 22:24:54
Done.
Ryan Hamilton
2017/05/20 22:24:54
Done.
| |
| 221 bool fin, | 228 // returns true if the data could actually be written. Returns false |
|
xunjieli
2017/05/15 15:48:37
nit: "could actually be written" isn't as precise.
Ryan Hamilton
2017/05/20 22:24:54
Done.
| |
| 222 const CompletionCallback& callback); | 229 // otherwise. |
| 230 bool WriteStreamData(QuicStringPiece data, bool fin); | |
| 223 // Same as WriteStreamData except it writes data from a vector of IOBuffers, | 231 // Same as WriteStreamData except it writes data from a vector of IOBuffers, |
| 224 // with the length of each buffer at the corresponding index in |lengths|. | 232 // with the length of each buffer at the corresponding index in |lengths|. |
| 225 int WritevStreamData(const std::vector<scoped_refptr<IOBuffer>>& buffers, | 233 bool WritevStreamData(const std::vector<scoped_refptr<IOBuffer>>& buffers, |
| 226 const std::vector<int>& lengths, | 234 const std::vector<int>& lengths, |
| 227 bool fin, | 235 bool fin); |
| 228 const CompletionCallback& callback); | |
| 229 | 236 |
| 230 // Creates a new Handle for this stream and sets |delegate| on the handle. | 237 // Creates a new Handle for this stream and sets |delegate| on the handle. |
| 231 // Must only be called once. | 238 // Must only be called once. |
| 232 std::unique_ptr<QuicChromiumClientStream::Handle> CreateHandle( | 239 std::unique_ptr<QuicChromiumClientStream::Handle> CreateHandle( |
| 233 QuicChromiumClientStream::Delegate* delegate); | 240 QuicChromiumClientStream::Delegate* delegate); |
| 234 | 241 |
| 235 // Clears |handle_| from this stream. | 242 // Clears |handle_| from this stream. |
| 236 void ClearHandle(); | 243 void ClearHandle(); |
| 237 | 244 |
| 238 void OnError(int error); | 245 void OnError(int error); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 267 void NotifyHandleOfDataAvailable(); | 274 void NotifyHandleOfDataAvailable(); |
| 268 | 275 |
| 269 NetLogWithSource net_log_; | 276 NetLogWithSource net_log_; |
| 270 Handle* handle_; | 277 Handle* handle_; |
| 271 | 278 |
| 272 bool headers_delivered_; | 279 bool headers_delivered_; |
| 273 | 280 |
| 274 // True when initial headers have been sent. | 281 // True when initial headers have been sent. |
| 275 bool initial_headers_sent_; | 282 bool initial_headers_sent_; |
| 276 | 283 |
| 277 // Callback to be invoked when WriteStreamData or WritevStreamData completes | |
| 278 // asynchronously. | |
| 279 CompletionCallback write_callback_; | |
| 280 | |
| 281 QuicClientSessionBase* session_; | 284 QuicClientSessionBase* session_; |
| 282 | 285 |
| 283 // Set to false if this stream to not be migrated during connection migration. | 286 // Set to false if this stream to not be migrated during connection migration. |
| 284 bool can_migrate_; | 287 bool can_migrate_; |
| 285 | 288 |
| 286 // Stores the initial header if they arrive before the delegate. | 289 // Stores the initial header if they arrive before the delegate. |
| 287 SpdyHeaderBlock initial_headers_; | 290 SpdyHeaderBlock initial_headers_; |
| 288 // Length of the HEADERS frame containing initial headers. | 291 // Length of the HEADERS frame containing initial headers. |
| 289 size_t initial_headers_frame_len_; | 292 size_t initial_headers_frame_len_; |
| 290 | 293 |
| 291 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; | 294 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; |
| 292 | 295 |
| 293 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); | 296 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); |
| 294 }; | 297 }; |
| 295 | 298 |
| 296 } // namespace net | 299 } // namespace net |
| 297 | 300 |
| 298 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ | 301 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ |
| OLD | NEW |