| 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_HTTP_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ | 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 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/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 17 #include "net/base/upload_data.h" |
| 17 #include "net/http/http_request_info.h" | 18 #include "net/http/http_request_info.h" |
| 18 #include "net/http/http_stream.h" | 19 #include "net/http/http_stream.h" |
| 19 #include "net/spdy/spdy_protocol.h" | 20 #include "net/spdy/spdy_protocol.h" |
| 20 #include "net/spdy/spdy_session.h" | 21 #include "net/spdy/spdy_session.h" |
| 21 #include "net/spdy/spdy_stream.h" | 22 #include "net/spdy/spdy_stream.h" |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| 25 class DrainableIOBuffer; | 26 class DrainableIOBuffer; |
| 26 class HttpResponseInfo; | 27 class HttpResponseInfo; |
| 27 class IOBuffer; | 28 class IOBuffer; |
| 28 class SpdySession; | 29 class SpdySession; |
| 29 class UploadData; | 30 class UploadData; |
| 30 class UploadDataStream; | 31 class UploadDataStream; |
| 31 | 32 |
| 32 // The SpdyHttpStream is a HTTP-specific type of stream known to a SpdySession. | 33 // The SpdyHttpStream is a HTTP-specific type of stream known to a SpdySession. |
| 33 class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate, | 34 class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate, |
| 34 public HttpStream { | 35 public HttpStream, |
| 36 public ChunkCallback { |
| 35 public: | 37 public: |
| 36 SpdyHttpStream(SpdySession* spdy_session, bool direct); | 38 SpdyHttpStream(SpdySession* spdy_session, bool direct); |
| 37 virtual ~SpdyHttpStream(); | 39 virtual ~SpdyHttpStream(); |
| 38 | 40 |
| 39 // Initializes this SpdyHttpStream by wrapping an existing SpdyStream. | 41 // Initializes this SpdyHttpStream by wrapping an existing SpdyStream. |
| 40 void InitializeWithExistingStream(SpdyStream* spdy_stream); | 42 void InitializeWithExistingStream(SpdyStream* spdy_stream); |
| 41 | 43 |
| 42 SpdyStream* stream() { return stream_.get(); } | 44 SpdyStream* stream() { return stream_.get(); } |
| 43 | 45 |
| 44 // Cancels any callbacks from being invoked and deletes the stream. | 46 // Cancels any callbacks from being invoked and deletes the stream. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // SpdyStream::Delegate implementation. | 78 // SpdyStream::Delegate implementation. |
| 77 virtual bool OnSendHeadersComplete(int status) OVERRIDE; | 79 virtual bool OnSendHeadersComplete(int status) OVERRIDE; |
| 78 virtual int OnSendBody() OVERRIDE; | 80 virtual int OnSendBody() OVERRIDE; |
| 79 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; | 81 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; |
| 80 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 82 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 81 base::Time response_time, | 83 base::Time response_time, |
| 82 int status) OVERRIDE; | 84 int status) OVERRIDE; |
| 83 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE; | 85 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE; |
| 84 virtual void OnDataSent(int length) OVERRIDE; | 86 virtual void OnDataSent(int length) OVERRIDE; |
| 85 virtual void OnClose(int status) OVERRIDE; | 87 virtual void OnClose(int status) OVERRIDE; |
| 86 virtual void set_chunk_callback(ChunkCallback* callback) OVERRIDE; | 88 |
| 89 // ChunkCallback implementation. |
| 90 virtual void OnChunkAvailable() OVERRIDE; |
| 87 | 91 |
| 88 private: | 92 private: |
| 89 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy2Test, | 93 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy2Test, |
| 90 FlowControlStallResume); | 94 FlowControlStallResume); |
| 91 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, | 95 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, |
| 92 FlowControlStallResume); | 96 FlowControlStallResume); |
| 93 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, | 97 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, |
| 94 FlowControlStallResumeAfterSettings); | 98 FlowControlStallResumeAfterSettings); |
| 95 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, | 99 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionSpdy3Test, |
| 96 FlowControlNegativeSendWindowSize); | 100 FlowControlNegativeSendWindowSize); |
| 97 | 101 |
| 102 // Reads the data from the request body stream and sends the data by calling |
| 103 // SpdyStream::WriteStreamData. In the case of chunked uploads, if data is not |
| 104 // available, returns ERR_IO_PENDING, and the write will be completed at a |
| 105 // later time. |
| 106 int SendData(); |
| 107 |
| 98 // Call the user callback. | 108 // Call the user callback. |
| 99 void DoCallback(int rv); | 109 void DoCallback(int rv); |
| 100 | 110 |
| 101 void ScheduleBufferedReadCallback(); | 111 void ScheduleBufferedReadCallback(); |
| 102 | 112 |
| 103 // Returns true if the callback is invoked. | 113 // Returns true if the callback is invoked. |
| 104 bool DoBufferedReadCallback(); | 114 bool DoBufferedReadCallback(); |
| 105 bool ShouldWaitForMoreBufferedData() const; | 115 bool ShouldWaitForMoreBufferedData() const; |
| 106 | 116 |
| 107 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; | 117 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 150 |
| 141 // Is there a scheduled read callback pending. | 151 // Is there a scheduled read callback pending. |
| 142 bool buffered_read_callback_pending_; | 152 bool buffered_read_callback_pending_; |
| 143 // Has more data been received from the network during the wait for the | 153 // Has more data been received from the network during the wait for the |
| 144 // scheduled read callback. | 154 // scheduled read callback. |
| 145 bool more_read_data_pending_; | 155 bool more_read_data_pending_; |
| 146 | 156 |
| 147 // Is this spdy stream direct to the origin server (or to a proxy). | 157 // Is this spdy stream direct to the origin server (or to a proxy). |
| 148 bool direct_; | 158 bool direct_; |
| 149 | 159 |
| 160 // Is the connection stalled waiting for an upload data chunk. |
| 161 bool waiting_for_chunk_; |
| 162 |
| 150 bool send_last_chunk_; | 163 bool send_last_chunk_; |
| 151 | 164 |
| 152 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 165 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
| 153 }; | 166 }; |
| 154 | 167 |
| 155 } // namespace net | 168 } // namespace net |
| 156 | 169 |
| 157 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 170 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
| OLD | NEW |