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