| 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 21 matching lines...) Expand all Loading... |
| 32 // are owned by the QuicClientSession which created them. | 32 // are owned by the QuicClientSession which created them. |
| 33 class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { | 33 class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| 34 public: | 34 public: |
| 35 // TODO(rch): Remove this class completely in favor of async methods | 35 // TODO(rch): Remove this class completely in favor of async methods |
| 36 // on the Handle. | 36 // on the Handle. |
| 37 // Delegate handles protocol specific behavior of a quic stream. | 37 // Delegate handles protocol specific behavior of a quic stream. |
| 38 class NET_EXPORT_PRIVATE Delegate { | 38 class NET_EXPORT_PRIVATE Delegate { |
| 39 public: | 39 public: |
| 40 Delegate() {} | 40 Delegate() {} |
| 41 | 41 |
| 42 // Called when trailing headers are available. | |
| 43 virtual void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, | |
| 44 size_t frame_len) = 0; | |
| 45 | |
| 46 // Called when the stream is closed by the peer. | 42 // Called when the stream is closed by the peer. |
| 47 virtual void OnClose() = 0; | 43 virtual void OnClose() = 0; |
| 48 | 44 |
| 49 // Called when the stream is closed because of an error. | 45 // Called when the stream is closed because of an error. |
| 50 virtual void OnError(int error) = 0; | 46 virtual void OnError(int error) = 0; |
| 51 | 47 |
| 52 protected: | 48 protected: |
| 53 virtual ~Delegate() {} | 49 virtual ~Delegate() {} |
| 54 | 50 |
| 55 private: | 51 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 | 71 |
| 76 // Reads at most |buffer_len| bytes of body into |buffer| and returns the | 72 // Reads at most |buffer_len| bytes of body into |buffer| and returns the |
| 77 // number of bytes read. If body is not available, returns ERR_IO_PENDING | 73 // number of bytes read. If body is not available, returns ERR_IO_PENDING |
| 78 // and will invoke |callback| asynchronously when data arrive. | 74 // and will invoke |callback| asynchronously when data arrive. |
| 79 // TODO(rch): Invoke |callback| when there is a stream or connection error | 75 // TODO(rch): Invoke |callback| when there is a stream or connection error |
| 80 // instead of calling OnClose() or OnError(). | 76 // instead of calling OnClose() or OnError(). |
| 81 int ReadBody(IOBuffer* buffer, | 77 int ReadBody(IOBuffer* buffer, |
| 82 int buffer_len, | 78 int buffer_len, |
| 83 const CompletionCallback& callback); | 79 const CompletionCallback& callback); |
| 84 | 80 |
| 81 // Reads trailing headers into |header_block| and returns the length of |
| 82 // the HEADERS frame which contained them. If headers are not available, |
| 83 // returns ERR_IO_PENDING and will invoke |callback| asynchronously when |
| 84 // the headers arrive. |
| 85 // TODO(rch): Invoke |callback| when there is a stream or connection error |
| 86 // instead of calling OnClose() or OnError(). |
| 87 int ReadTrailingHeaders(SpdyHeaderBlock* header_block, |
| 88 const CompletionCallback& callback); |
| 89 |
| 85 // Writes |header_block| to the peer. Closes the write side if |fin| is | 90 // Writes |header_block| to the peer. Closes the write side if |fin| is |
| 86 // true. If non-null, |ack_notifier_delegate| will be notified when the | 91 // true. If non-null, |ack_notifier_delegate| will be notified when the |
| 87 // headers are ACK'd by the peer. | 92 // headers are ACK'd by the peer. |
| 88 size_t WriteHeaders(SpdyHeaderBlock header_block, | 93 size_t WriteHeaders(SpdyHeaderBlock header_block, |
| 89 bool fin, | 94 bool fin, |
| 90 QuicReferenceCountedPointer<QuicAckListenerInterface> | 95 QuicReferenceCountedPointer<QuicAckListenerInterface> |
| 91 ack_notifier_delegate); | 96 ack_notifier_delegate); |
| 92 | 97 |
| 93 // Writes |data| to the peer. Closes the write side if |fin| is true. | 98 // Writes |data| to the peer. Closes the write side if |fin| is true. |
| 94 // If the data could not be written immediately, returns ERR_IO_PENDING | 99 // If the data could not be written immediately, returns ERR_IO_PENDING |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 152 |
| 148 private: | 153 private: |
| 149 friend class QuicChromiumClientStream; | 154 friend class QuicChromiumClientStream; |
| 150 | 155 |
| 151 // Constucts a new Handle for |stream| with |delegate| set to receive | 156 // Constucts a new Handle for |stream| with |delegate| set to receive |
| 152 // up calls on various events. | 157 // up calls on various events. |
| 153 Handle(QuicChromiumClientStream* stream, Delegate* delegate); | 158 Handle(QuicChromiumClientStream* stream, Delegate* delegate); |
| 154 | 159 |
| 155 // Methods invoked by the stream. | 160 // Methods invoked by the stream. |
| 156 void OnInitialHeadersAvailable(); | 161 void OnInitialHeadersAvailable(); |
| 157 void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, | 162 void OnTrailingHeadersAvailable(); |
| 158 size_t frame_len); | |
| 159 void OnDataAvailable(); | 163 void OnDataAvailable(); |
| 160 void OnCanWrite(); | 164 void OnCanWrite(); |
| 161 void OnClose(); | 165 void OnClose(); |
| 162 void OnError(int error); | 166 void OnError(int error); |
| 163 | 167 |
| 164 // Saves various fields from the stream before the stream goes away. | 168 // Saves various fields from the stream before the stream goes away. |
| 165 void SaveState(); | 169 void SaveState(); |
| 166 | 170 |
| 167 QuicChromiumClientStream* stream_; // Unowned. | 171 QuicChromiumClientStream* stream_; // Unowned. |
| 168 Delegate* delegate_; // Owns this. | 172 Delegate* delegate_; // Owns this. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // concurrent streams within the session to also not migrate. | 257 // concurrent streams within the session to also not migrate. |
| 254 void DisableConnectionMigration(); | 258 void DisableConnectionMigration(); |
| 255 | 259 |
| 256 bool can_migrate() { return can_migrate_; } | 260 bool can_migrate() { return can_migrate_; } |
| 257 | 261 |
| 258 // True if this stream is the first data stream created on this session. | 262 // True if this stream is the first data stream created on this session. |
| 259 bool IsFirstStream(); | 263 bool IsFirstStream(); |
| 260 | 264 |
| 261 bool DeliverInitialHeaders(SpdyHeaderBlock* header_block, int* frame_len); | 265 bool DeliverInitialHeaders(SpdyHeaderBlock* header_block, int* frame_len); |
| 262 | 266 |
| 267 bool DeliverTrailingHeaders(SpdyHeaderBlock* header_block, int* frame_len); |
| 268 |
| 263 using QuicSpdyStream::HasBufferedData; | 269 using QuicSpdyStream::HasBufferedData; |
| 264 using QuicStream::sequencer; | 270 using QuicStream::sequencer; |
| 265 | 271 |
| 266 private: | 272 private: |
| 267 void NotifyHandleOfInitialHeadersAvailableLater(); | 273 void NotifyHandleOfInitialHeadersAvailableLater(); |
| 268 void NotifyHandleOfInitialHeadersAvailable(); | 274 void NotifyHandleOfInitialHeadersAvailable(); |
| 269 void NotifyHandleOfTrailingHeadersAvailableLater(SpdyHeaderBlock headers, | 275 void NotifyHandleOfTrailingHeadersAvailableLater(); |
| 270 size_t frame_len); | 276 void NotifyHandleOfTrailingHeadersAvailable(); |
| 271 void NotifyHandleOfTrailingHeadersAvailable(SpdyHeaderBlock headers, | |
| 272 size_t frame_len); | |
| 273 void NotifyHandleOfDataAvailableLater(); | 277 void NotifyHandleOfDataAvailableLater(); |
| 274 void NotifyHandleOfDataAvailable(); | 278 void NotifyHandleOfDataAvailable(); |
| 275 | 279 |
| 276 NetLogWithSource net_log_; | 280 NetLogWithSource net_log_; |
| 277 Handle* handle_; | 281 Handle* handle_; |
| 278 | 282 |
| 279 bool headers_delivered_; | 283 bool headers_delivered_; |
| 280 | 284 |
| 281 // True when initial headers have been sent. | 285 // True when initial headers have been sent. |
| 282 bool initial_headers_sent_; | 286 bool initial_headers_sent_; |
| 283 | 287 |
| 284 QuicClientSessionBase* session_; | 288 QuicClientSessionBase* session_; |
| 285 | 289 |
| 286 // Set to false if this stream to not be migrated during connection migration. | 290 // Set to false if this stream to not be migrated during connection migration. |
| 287 bool can_migrate_; | 291 bool can_migrate_; |
| 288 | 292 |
| 289 // Stores the initial header if they arrive before the delegate. | 293 // Stores the initial header if they arrive before the delegate. |
| 290 SpdyHeaderBlock initial_headers_; | 294 SpdyHeaderBlock initial_headers_; |
| 291 // Length of the HEADERS frame containing initial headers. | 295 // Length of the HEADERS frame containing initial headers. |
| 292 size_t initial_headers_frame_len_; | 296 size_t initial_headers_frame_len_; |
| 293 | 297 |
| 298 // Length of the HEADERS frame containing trailing headers. |
| 299 size_t trailing_headers_frame_len_; |
| 300 |
| 294 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; | 301 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; |
| 295 | 302 |
| 296 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); | 303 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); |
| 297 }; | 304 }; |
| 298 | 305 |
| 299 } // namespace net | 306 } // namespace net |
| 300 | 307 |
| 301 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ | 308 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ |
| OLD | NEW |