| 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 <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received. | 64 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received. |
| 65 // Normal streams will receive a SYN_REPLY and optional HEADERS frames. | 65 // Normal streams will receive a SYN_REPLY and optional HEADERS frames. |
| 66 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames. | 66 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames. |
| 67 // Because a stream may have a SYN_* frame and multiple HEADERS frames, | 67 // Because a stream may have a SYN_* frame and multiple HEADERS frames, |
| 68 // this callback may be called multiple times. | 68 // this callback may be called multiple times. |
| 69 // |status| indicates network error. Returns network error code. | 69 // |status| indicates network error. Returns network error code. |
| 70 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 70 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 71 base::Time response_time, | 71 base::Time response_time, |
| 72 int status) = 0; | 72 int status) = 0; |
| 73 | 73 |
| 74 // Called when a HEADERS frame is sent. |
| 75 virtual void OnHeadersSent() = 0; |
| 76 |
| 74 // Called when data is received. | 77 // Called when data is received. |
| 75 // Returns network error code. OK when it successfully receives data. | 78 // Returns network error code. OK when it successfully receives data. |
| 76 virtual int OnDataReceived(const char* data, int length) = 0; | 79 virtual int OnDataReceived(const char* data, int length) = 0; |
| 77 | 80 |
| 78 // Called when data is sent. | 81 // Called when data is sent. |
| 79 virtual void OnDataSent(int length) = 0; | 82 virtual void OnDataSent(int length) = 0; |
| 80 | 83 |
| 81 // Called when SpdyStream is closed. | 84 // Called when SpdyStream is closed. |
| 82 virtual void OnClose(int status) = 0; | 85 virtual void OnClose(int status) = 0; |
| 83 | 86 |
| 84 protected: | 87 protected: |
| 85 friend class base::RefCounted<Delegate>; | 88 friend class base::RefCounted<Delegate>; |
| 86 virtual ~Delegate() {} | 89 virtual ~Delegate() {} |
| 87 | 90 |
| 88 private: | 91 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(Delegate); | 92 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 // Indicates pending frame type. | 95 // Indicates pending frame type. |
| 93 enum PendingFrameType { | 96 enum FrameType { |
| 94 TYPE_HEADER, | 97 TYPE_HEADERS, |
| 95 TYPE_DATA | 98 TYPE_DATA |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 // Structure to contains pending frame information. | 101 // Structure to contains pending frame information. |
| 99 typedef struct { | 102 typedef struct { |
| 100 PendingFrameType type; | 103 FrameType type; |
| 101 union { | 104 union { |
| 102 SpdyHeaderBlock* header_block; | 105 SpdyHeaderBlock* header_block; |
| 103 SpdyDataFrame* data_frame; | 106 SpdyDataFrame* data_frame; |
| 104 }; | 107 }; |
| 105 } PendingFrame; | 108 } PendingFrame; |
| 106 | 109 |
| 107 // SpdyStream constructor | 110 // SpdyStream constructor |
| 108 SpdyStream(SpdySession* session, | 111 SpdyStream(SpdySession* session, |
| 109 bool pushed, | 112 bool pushed, |
| 110 const BoundNetLog& net_log); | 113 const BoundNetLog& net_log); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // The request to send. | 361 // The request to send. |
| 359 scoped_ptr<SpdyHeaderBlock> request_; | 362 scoped_ptr<SpdyHeaderBlock> request_; |
| 360 | 363 |
| 361 // The time at which the request was made that resulted in this response. | 364 // The time at which the request was made that resulted in this response. |
| 362 // For cached responses, this time could be "far" in the past. | 365 // For cached responses, this time could be "far" in the past. |
| 363 base::Time request_time_; | 366 base::Time request_time_; |
| 364 | 367 |
| 365 scoped_ptr<SpdyHeaderBlock> response_; | 368 scoped_ptr<SpdyHeaderBlock> response_; |
| 366 base::Time response_time_; | 369 base::Time response_time_; |
| 367 | 370 |
| 371 // An in order list of pending frame data that are going to be sent. HEADERS |
| 372 // frames are queued as SpdyHeaderBlock structures because these must be |
| 373 // compressed just before sending. Data frames are queued as SpdyDataFrame. |
| 368 std::list<PendingFrame> pending_frames_; | 374 std::list<PendingFrame> pending_frames_; |
| 369 | 375 |
| 376 // An in order list of sending frame types. It will be used to know which type |
| 377 // of frame is sent and which callback should be invoked in OnOpen(). |
| 378 std::list<FrameType> waiting_completions_; |
| 379 |
| 370 State io_state_; | 380 State io_state_; |
| 371 | 381 |
| 372 // Since we buffer the response, we also buffer the response status. | 382 // Since we buffer the response, we also buffer the response status. |
| 373 // Not valid until the stream is closed. | 383 // Not valid until the stream is closed. |
| 374 int response_status_; | 384 int response_status_; |
| 375 | 385 |
| 376 bool cancelled_; | 386 bool cancelled_; |
| 377 bool has_upload_data_; | 387 bool has_upload_data_; |
| 378 | 388 |
| 379 BoundNetLog net_log_; | 389 BoundNetLog net_log_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 390 std::string domain_bound_private_key_; | 400 std::string domain_bound_private_key_; |
| 391 std::string domain_bound_cert_; | 401 std::string domain_bound_cert_; |
| 392 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 402 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; |
| 393 | 403 |
| 394 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 404 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
| 395 }; | 405 }; |
| 396 | 406 |
| 397 } // namespace net | 407 } // namespace net |
| 398 | 408 |
| 399 #endif // NET_SPDY_SPDY_STREAM_H_ | 409 #endif // NET_SPDY_SPDY_STREAM_H_ |
| OLD | NEW |