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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 #include "net/base/bandwidth_metrics.h" | 18 #include "net/base/bandwidth_metrics.h" |
18 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
19 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
20 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
21 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
22 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
23 #include "net/spdy/spdy_framer.h" | 24 #include "net/spdy/spdy_framer.h" |
24 #include "net/spdy/spdy_header_block.h" | 25 #include "net/spdy/spdy_header_block.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Because a stream may have a SYN_* frame and multiple HEADERS frames, | 77 // Because a stream may have a SYN_* frame and multiple HEADERS frames, |
77 // this callback may be called multiple times. | 78 // this callback may be called multiple times. |
78 // |status| indicates network error. Returns network error code. | 79 // |status| indicates network error. Returns network error code. |
79 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 80 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
80 base::Time response_time, | 81 base::Time response_time, |
81 int status) = 0; | 82 int status) = 0; |
82 | 83 |
83 // Called when a HEADERS frame is sent. | 84 // Called when a HEADERS frame is sent. |
84 virtual void OnHeadersSent() = 0; | 85 virtual void OnHeadersSent() = 0; |
85 | 86 |
86 // Called when data is received. | 87 // Called when data is received. |buffer| may be NULL, which |
87 // Returns network error code. OK when it successfully receives data. | 88 // signals EOF. Must return OK if the data was received |
88 virtual int OnDataReceived(const char* data, int length) = 0; | 89 // successfully, or a network error code otherwise. |
| 90 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0; |
89 | 91 |
90 // Called when data is sent. | 92 // Called when data is sent. |
91 virtual void OnDataSent(size_t bytes_sent) = 0; | 93 virtual void OnDataSent(size_t bytes_sent) = 0; |
92 | 94 |
93 // Called when SpdyStream is closed. No other delegate functions | 95 // Called when SpdyStream is closed. No other delegate functions |
94 // will be called after this is called, and the delegate must not | 96 // will be called after this is called, and the delegate must not |
95 // access the stream after this is called. | 97 // access the stream after this is called. |
96 virtual void OnClose(int status) = 0; | 98 virtual void OnClose(int status) = 0; |
97 | 99 |
98 protected: | 100 protected: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Called by the SpdySession when response data has been received for this | 213 // Called by the SpdySession when response data has been received for this |
212 // stream. This callback may be called multiple times as data arrives | 214 // stream. This callback may be called multiple times as data arrives |
213 // from the network, and will never be called prior to OnResponseReceived. | 215 // from the network, and will never be called prior to OnResponseReceived. |
214 // | 216 // |
215 // |buffer| contains the data received, or NULL if the stream is | 217 // |buffer| contains the data received, or NULL if the stream is |
216 // being closed. The stream must copy any data from this | 218 // being closed. The stream must copy any data from this |
217 // buffer before returning from this callback. | 219 // buffer before returning from this callback. |
218 // | 220 // |
219 // |length| is the number of bytes received (at most 2^24 - 1) or 0 if | 221 // |length| is the number of bytes received (at most 2^24 - 1) or 0 if |
220 // the stream is being closed. | 222 // the stream is being closed. |
221 void OnDataReceived(const char* buffer, size_t length); | 223 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer); |
222 | 224 |
223 // Called by the SpdySession when a frame has been successfully and | 225 // Called by the SpdySession when a frame has been successfully and |
224 // completely written. |frame_size| is the total size of the frame | 226 // completely written. |frame_size| is the total size of the frame |
225 // in bytes, including framing overhead. | 227 // in bytes, including framing overhead. |
226 void OnFrameWriteComplete(SpdyFrameType frame_type, size_t frame_size); | 228 void OnFrameWriteComplete(SpdyFrameType frame_type, size_t frame_size); |
227 | 229 |
228 // Called by the SpdySession when the request is finished. This callback | 230 // Called by the SpdySession when the request is finished. This callback |
229 // will always be called at the end of the request and signals to the | 231 // will always be called at the end of the request and signals to the |
230 // stream that the stream has no more network events. No further callbacks | 232 // stream that the stream has no more network events. No further callbacks |
231 // to the stream will be made after this call. | 233 // to the stream will be made after this call. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // Returns true if the URL for this stream is known. | 284 // Returns true if the URL for this stream is known. |
283 bool HasUrl() const; | 285 bool HasUrl() const; |
284 | 286 |
285 // Get the URL associated with this stream. Only valid when has_url() is | 287 // Get the URL associated with this stream. Only valid when has_url() is |
286 // true. | 288 // true. |
287 GURL GetUrl() const; | 289 GURL GetUrl() const; |
288 | 290 |
289 int GetProtocolVersion() const; | 291 int GetProtocolVersion() const; |
290 | 292 |
291 private: | 293 private: |
292 class SynStreamFrameProducer; | 294 class SynStreamBufferProducer; |
293 class HeaderFrameProducer; | 295 class HeaderBufferProducer; |
294 | 296 |
295 enum State { | 297 enum State { |
296 STATE_NONE, | 298 STATE_NONE, |
297 STATE_GET_DOMAIN_BOUND_CERT, | 299 STATE_GET_DOMAIN_BOUND_CERT, |
298 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, | 300 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, |
299 STATE_SEND_DOMAIN_BOUND_CERT, | 301 STATE_SEND_DOMAIN_BOUND_CERT, |
300 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, | 302 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, |
301 STATE_SEND_HEADERS, | 303 STATE_SEND_HEADERS, |
302 STATE_SEND_HEADERS_COMPLETE, | 304 STATE_SEND_HEADERS_COMPLETE, |
303 STATE_SEND_BODY, | 305 STATE_SEND_BODY, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 base::TimeTicks send_time_; | 406 base::TimeTicks send_time_; |
405 base::TimeTicks recv_first_byte_time_; | 407 base::TimeTicks recv_first_byte_time_; |
406 base::TimeTicks recv_last_byte_time_; | 408 base::TimeTicks recv_last_byte_time_; |
407 | 409 |
408 // Number of data bytes that have been sent/received on this stream, not | 410 // Number of data bytes that have been sent/received on this stream, not |
409 // including frame overhead. Note that this does not count headers. | 411 // including frame overhead. Note that this does not count headers. |
410 int send_bytes_; | 412 int send_bytes_; |
411 int recv_bytes_; | 413 int recv_bytes_; |
412 | 414 |
413 // Data received before delegate is attached. | 415 // Data received before delegate is attached. |
414 std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_; | 416 ScopedVector<SpdyBuffer> pending_buffers_; |
415 | 417 |
416 SSLClientCertType domain_bound_cert_type_; | 418 SSLClientCertType domain_bound_cert_type_; |
417 std::string domain_bound_private_key_; | 419 std::string domain_bound_private_key_; |
418 std::string domain_bound_cert_; | 420 std::string domain_bound_cert_; |
419 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 421 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; |
420 | 422 |
421 // When OnFrameWriteComplete() is called, these variables are set. | 423 // When OnFrameWriteComplete() is called, these variables are set. |
422 SpdyFrameType just_completed_frame_type_; | 424 SpdyFrameType just_completed_frame_type_; |
423 size_t just_completed_frame_size_; | 425 size_t just_completed_frame_size_; |
424 | 426 |
425 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 427 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
426 }; | 428 }; |
427 | 429 |
428 } // namespace net | 430 } // namespace net |
429 | 431 |
430 #endif // NET_SPDY_SPDY_STREAM_H_ | 432 #endif // NET_SPDY_SPDY_STREAM_H_ |
OLD | NEW |