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 25 matching lines...) Expand all Loading... |
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. | 42 // Called when trailing headers are available. |
43 virtual void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, | 43 virtual void OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, |
44 size_t frame_len) = 0; | 44 size_t frame_len) = 0; |
45 | 45 |
46 // Called when data is available to be read. | |
47 virtual void OnDataAvailable() = 0; | |
48 | |
49 // Called when the stream is closed by the peer. | 46 // Called when the stream is closed by the peer. |
50 virtual void OnClose() = 0; | 47 virtual void OnClose() = 0; |
51 | 48 |
52 // Called when the stream is closed because of an error. | 49 // Called when the stream is closed because of an error. |
53 virtual void OnError(int error) = 0; | 50 virtual void OnError(int error) = 0; |
54 | 51 |
55 protected: | 52 protected: |
56 virtual ~Delegate() {} | 53 virtual ~Delegate() {} |
57 | 54 |
58 private: | 55 private: |
(...skipping 10 matching lines...) Expand all Loading... |
69 | 66 |
70 // Reads initial headers into |header_block| and returns the length of | 67 // Reads initial headers into |header_block| and returns the length of |
71 // the HEADERS frame which contained them. If headers are not available, | 68 // the HEADERS frame which contained them. If headers are not available, |
72 // returns ERR_IO_PENDING and will invoke |callback| asynchronously when | 69 // returns ERR_IO_PENDING and will invoke |callback| asynchronously when |
73 // the headers arrive. | 70 // the headers arrive. |
74 // TODO(rch): Invoke |callback| when there is a stream or connection error | 71 // TODO(rch): Invoke |callback| when there is a stream or connection error |
75 // instead of calling OnClose() or OnError(). | 72 // instead of calling OnClose() or OnError(). |
76 int ReadInitialHeaders(SpdyHeaderBlock* header_block, | 73 int ReadInitialHeaders(SpdyHeaderBlock* header_block, |
77 const CompletionCallback& callback); | 74 const CompletionCallback& callback); |
78 | 75 |
| 76 // 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 |
| 78 // and will invoke |callback| asynchronously when data arrive. |
| 79 // TODO(rch): Invoke |callback| when there is a stream or connection error |
| 80 // instead of calling OnClose() or OnError(). |
| 81 int ReadBody(IOBuffer* buffer, |
| 82 int buffer_len, |
| 83 const CompletionCallback& callback); |
| 84 |
79 // Writes |header_block| to the peer. Closes the write side if |fin| is | 85 // Writes |header_block| to the peer. Closes the write side if |fin| is |
80 // true. If non-null, |ack_notifier_delegate| will be notified when the | 86 // true. If non-null, |ack_notifier_delegate| will be notified when the |
81 // headers are ACK'd by the peer. | 87 // headers are ACK'd by the peer. |
82 size_t WriteHeaders(SpdyHeaderBlock header_block, | 88 size_t WriteHeaders(SpdyHeaderBlock header_block, |
83 bool fin, | 89 bool fin, |
84 QuicReferenceCountedPointer<QuicAckListenerInterface> | 90 QuicReferenceCountedPointer<QuicAckListenerInterface> |
85 ack_notifier_delegate); | 91 ack_notifier_delegate); |
86 | 92 |
87 // Writes |data| to the peer. Closes the write side if |fin| is true. | 93 // Writes |data| to the peer. Closes the write side if |fin| is true. |
88 // If the data could not be written immediately, returns ERR_IO_PENDING | 94 // If the data could not be written immediately, returns ERR_IO_PENDING |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 162 |
157 // Saves various fields from the stream before the stream goes away. | 163 // Saves various fields from the stream before the stream goes away. |
158 void SaveState(); | 164 void SaveState(); |
159 | 165 |
160 QuicChromiumClientStream* stream_; // Unowned. | 166 QuicChromiumClientStream* stream_; // Unowned. |
161 Delegate* delegate_; // Owns this. | 167 Delegate* delegate_; // Owns this. |
162 | 168 |
163 CompletionCallback read_headers_callback_; | 169 CompletionCallback read_headers_callback_; |
164 SpdyHeaderBlock* read_headers_buffer_; | 170 SpdyHeaderBlock* read_headers_buffer_; |
165 | 171 |
| 172 CompletionCallback read_body_callback_; |
| 173 IOBuffer* read_body_buffer_; |
| 174 int read_body_buffer_len_; |
| 175 |
166 QuicStreamId id_; | 176 QuicStreamId id_; |
167 QuicErrorCode connection_error_; | 177 QuicErrorCode connection_error_; |
168 QuicRstStreamErrorCode stream_error_; | 178 QuicRstStreamErrorCode stream_error_; |
169 bool fin_sent_; | 179 bool fin_sent_; |
170 bool fin_received_; | 180 bool fin_received_; |
171 uint64_t stream_bytes_read_; | 181 uint64_t stream_bytes_read_; |
172 uint64_t stream_bytes_written_; | 182 uint64_t stream_bytes_written_; |
173 bool is_done_reading_; | 183 bool is_done_reading_; |
174 bool is_first_stream_; | 184 bool is_first_stream_; |
175 size_t num_bytes_consumed_; | 185 size_t num_bytes_consumed_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 size_t initial_headers_frame_len_; | 289 size_t initial_headers_frame_len_; |
280 | 290 |
281 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; | 291 base::WeakPtrFactory<QuicChromiumClientStream> weak_factory_; |
282 | 292 |
283 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); | 293 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientStream); |
284 }; | 294 }; |
285 | 295 |
286 } // namespace net | 296 } // namespace net |
287 | 297 |
288 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ | 298 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_STREAM_H_ |
OLD | NEW |