Chromium Code Reviews| 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 (whether chunked or not) from the request body stream and | |
| 103 // sends the data by calling WriteStreamData on the underlying SpdyStream | |
| 104 // (which always returns ERR_IO_PENDING). In the case of chunked uploads, if | |
|
Ryan Hamilton
2012/07/11 21:08:21
I'm not sure that you need any of this comment aft
Ryan Sleevi
2012/07/11 21:13:46
Sounds good - I agree that we don't want to docume
ramant (doing other things)
2012/07/11 22:02:21
Done.
| |
| 105 // data is not available, returns ERR_IO_PENDING, and the write will be | |
| 106 // completed at a later time. This method always returns ERR_IO_PENDING. | |
| 107 int SendData(); | |
| 108 | |
| 98 // Call the user callback. | 109 // Call the user callback. |
| 99 void DoCallback(int rv); | 110 void DoCallback(int rv); |
| 100 | 111 |
| 101 void ScheduleBufferedReadCallback(); | 112 void ScheduleBufferedReadCallback(); |
| 102 | 113 |
| 103 // Returns true if the callback is invoked. | 114 // Returns true if the callback is invoked. |
| 104 bool DoBufferedReadCallback(); | 115 bool DoBufferedReadCallback(); |
| 105 bool ShouldWaitForMoreBufferedData() const; | 116 bool ShouldWaitForMoreBufferedData() const; |
| 106 | 117 |
| 107 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; | 118 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 151 |
| 141 // Is there a scheduled read callback pending. | 152 // Is there a scheduled read callback pending. |
| 142 bool buffered_read_callback_pending_; | 153 bool buffered_read_callback_pending_; |
| 143 // Has more data been received from the network during the wait for the | 154 // Has more data been received from the network during the wait for the |
| 144 // scheduled read callback. | 155 // scheduled read callback. |
| 145 bool more_read_data_pending_; | 156 bool more_read_data_pending_; |
| 146 | 157 |
| 147 // Is this spdy stream direct to the origin server (or to a proxy). | 158 // Is this spdy stream direct to the origin server (or to a proxy). |
| 148 bool direct_; | 159 bool direct_; |
| 149 | 160 |
| 161 // Is the connection stalled waiting for an upload data chunk. | |
| 162 bool waiting_for_chunk_; | |
| 163 | |
| 150 bool send_last_chunk_; | 164 bool send_last_chunk_; |
| 151 | 165 |
| 152 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 166 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
| 153 }; | 167 }; |
| 154 | 168 |
| 155 } // namespace net | 169 } // namespace net |
| 156 | 170 |
| 157 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 171 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
| OLD | NEW |