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