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 <list> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "net/base/bandwidth_metrics.h" | 16 #include "net/base/bandwidth_metrics.h" |
16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
17 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
18 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
20 #include "net/base/server_bound_cert_service.h" | 21 #include "net/base/server_bound_cert_service.h" |
21 #include "net/base/ssl_client_cert_type.h" | 22 #include "net/base/ssl_client_cert_type.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_protocol.h" | 25 #include "net/spdy/spdy_protocol.h" |
| 26 #include "net/spdy/spdy_session.h" |
25 | 27 |
26 namespace net { | 28 namespace net { |
27 | 29 |
28 class AddressList; | 30 class AddressList; |
29 class IPEndPoint; | 31 class IPEndPoint; |
30 class SpdySession; | |
31 class SSLCertRequestInfo; | 32 class SSLCertRequestInfo; |
32 class SSLInfo; | 33 class SSLInfo; |
33 | 34 |
34 // The SpdyStream is used by the SpdySession to represent each stream known | 35 // The SpdyStream is used by the SpdySession to represent each stream known |
35 // on the SpdySession. This class provides interfaces for SpdySession to use. | 36 // on the SpdySession. This class provides interfaces for SpdySession to use. |
36 // Streams can be created either by the client or by the server. When they | 37 // Streams can be created either by the client or by the server. When they |
37 // are initiated by the client, both the SpdySession and client object (such as | 38 // are initiated by the client, both the SpdySession and client object (such as |
38 // a SpdyNetworkTransaction) will maintain a reference to the stream. When | 39 // a SpdyNetworkTransaction) will maintain a reference to the stream. When |
39 // initiated by the server, only the SpdySession will maintain any reference, | 40 // initiated by the server, only the SpdySession will maintain any reference, |
40 // until such a time as a client object requests a stream for the path. | 41 // until such a time as a client object requests a stream for the path. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 protected: | 83 protected: |
83 friend class base::RefCounted<Delegate>; | 84 friend class base::RefCounted<Delegate>; |
84 virtual ~Delegate() {} | 85 virtual ~Delegate() {} |
85 | 86 |
86 private: | 87 private: |
87 DISALLOW_COPY_AND_ASSIGN(Delegate); | 88 DISALLOW_COPY_AND_ASSIGN(Delegate); |
88 }; | 89 }; |
89 | 90 |
90 // SpdyStream constructor | 91 // SpdyStream constructor |
91 SpdyStream(SpdySession* session, | 92 SpdyStream(SpdySession* session, |
92 SpdyStreamId stream_id, | |
93 bool pushed, | 93 bool pushed, |
94 const BoundNetLog& net_log); | 94 const BoundNetLog& net_log); |
95 | 95 |
96 // Set new |delegate|. |delegate| must not be NULL. | 96 // Set new |delegate|. |delegate| must not be NULL. |
97 // If it already received SYN_REPLY or data, OnResponseReceived() or | 97 // If it already received SYN_REPLY or data, OnResponseReceived() or |
98 // OnDataReceived() will be called. | 98 // OnDataReceived() will be called. |
99 void SetDelegate(Delegate* delegate); | 99 void SetDelegate(Delegate* delegate); |
100 Delegate* GetDelegate() { return delegate_; } | 100 Delegate* GetDelegate() { return delegate_; } |
101 | 101 |
102 // Detach delegate from the stream. It will cancel the stream if it was not | 102 // Detach delegate from the stream. It will cancel the stream if it was not |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // Returns true if the URL for this stream is known. | 244 // Returns true if the URL for this stream is known. |
245 bool HasUrl() const; | 245 bool HasUrl() const; |
246 | 246 |
247 // Get the URL associated with this stream. Only valid when has_url() is | 247 // Get the URL associated with this stream. Only valid when has_url() is |
248 // true. | 248 // true. |
249 GURL GetUrl() const; | 249 GURL GetUrl() const; |
250 | 250 |
251 int GetProtocolVersion() const; | 251 int GetProtocolVersion() const; |
252 | 252 |
253 private: | 253 private: |
| 254 class SpdyStreamIOBufferProducer; |
| 255 |
254 enum State { | 256 enum State { |
255 STATE_NONE, | 257 STATE_NONE, |
256 STATE_GET_DOMAIN_BOUND_CERT, | 258 STATE_GET_DOMAIN_BOUND_CERT, |
257 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, | 259 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, |
258 STATE_SEND_DOMAIN_BOUND_CERT, | 260 STATE_SEND_DOMAIN_BOUND_CERT, |
259 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, | 261 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, |
260 STATE_SEND_HEADERS, | 262 STATE_SEND_HEADERS, |
261 STATE_SEND_HEADERS_COMPLETE, | 263 STATE_SEND_HEADERS_COMPLETE, |
262 STATE_SEND_BODY, | 264 STATE_SEND_BODY, |
263 STATE_SEND_BODY_COMPLETE, | 265 STATE_SEND_BODY_COMPLETE, |
(...skipping 29 matching lines...) Expand all Loading... |
293 int DoOpen(int result); | 295 int DoOpen(int result); |
294 | 296 |
295 // Update the histograms. Can safely be called repeatedly, but should only | 297 // Update the histograms. Can safely be called repeatedly, but should only |
296 // be called after the stream has completed. | 298 // be called after the stream has completed. |
297 void UpdateHistograms(); | 299 void UpdateHistograms(); |
298 | 300 |
299 // When a server pushed stream is first created, this function is posted on | 301 // When a server pushed stream is first created, this function is posted on |
300 // the MessageLoop to replay all the data that the server has already sent. | 302 // the MessageLoop to replay all the data that the server has already sent. |
301 void PushedStreamReplayData(); | 303 void PushedStreamReplayData(); |
302 | 304 |
| 305 // Informs the SpdySession that this stream has a write available. |
| 306 void SetHasWriteAvailable(); |
| 307 |
| 308 // Returns a newly created SPDY frame owned by the called that contains |
| 309 // the next frame to be sent by this frame. May return NULL if this |
| 310 // stream has become stalled on flow control. |
| 311 SpdyFrame* ProduceNextFrame(); |
| 312 |
303 // There is a small period of time between when a server pushed stream is | 313 // There is a small period of time between when a server pushed stream is |
304 // first created, and the pushed data is replayed. Any data received during | 314 // first created, and the pushed data is replayed. Any data received during |
305 // this time should continue to be buffered. | 315 // this time should continue to be buffered. |
306 bool continue_buffering_data_; | 316 bool continue_buffering_data_; |
307 | 317 |
308 SpdyStreamId stream_id_; | 318 SpdyStreamId stream_id_; |
309 std::string path_; | 319 std::string path_; |
310 RequestPriority priority_; | 320 RequestPriority priority_; |
311 size_t slot_; | 321 size_t slot_; |
312 | 322 |
(...skipping 15 matching lines...) Expand all Loading... |
328 // The request to send. | 338 // The request to send. |
329 scoped_ptr<SpdyHeaderBlock> request_; | 339 scoped_ptr<SpdyHeaderBlock> request_; |
330 | 340 |
331 // The time at which the request was made that resulted in this response. | 341 // The time at which the request was made that resulted in this response. |
332 // For cached responses, this time could be "far" in the past. | 342 // For cached responses, this time could be "far" in the past. |
333 base::Time request_time_; | 343 base::Time request_time_; |
334 | 344 |
335 scoped_ptr<SpdyHeaderBlock> response_; | 345 scoped_ptr<SpdyHeaderBlock> response_; |
336 base::Time response_time_; | 346 base::Time response_time_; |
337 | 347 |
| 348 std::list<SpdyFrame*> pending_data_frames_; |
| 349 |
338 State io_state_; | 350 State io_state_; |
339 | 351 |
340 // Since we buffer the response, we also buffer the response status. | 352 // Since we buffer the response, we also buffer the response status. |
341 // Not valid until the stream is closed. | 353 // Not valid until the stream is closed. |
342 int response_status_; | 354 int response_status_; |
343 | 355 |
344 bool cancelled_; | 356 bool cancelled_; |
345 bool has_upload_data_; | 357 bool has_upload_data_; |
346 | 358 |
347 BoundNetLog net_log_; | 359 BoundNetLog net_log_; |
(...skipping 10 matching lines...) Expand all Loading... |
358 std::string domain_bound_private_key_; | 370 std::string domain_bound_private_key_; |
359 std::string domain_bound_cert_; | 371 std::string domain_bound_cert_; |
360 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 372 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; |
361 | 373 |
362 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 374 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
363 }; | 375 }; |
364 | 376 |
365 } // namespace net | 377 } // namespace net |
366 | 378 |
367 #endif // NET_SPDY_SPDY_STREAM_H_ | 379 #endif // NET_SPDY_SPDY_STREAM_H_ |
OLD | NEW |