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 int SendData(); |
| 105 |
98 // Call the user callback. | 106 // Call the user callback. |
99 void DoCallback(int rv); | 107 void DoCallback(int rv); |
100 | 108 |
101 void ScheduleBufferedReadCallback(); | 109 void ScheduleBufferedReadCallback(); |
102 | 110 |
103 // Returns true if the callback is invoked. | 111 // Returns true if the callback is invoked. |
104 bool DoBufferedReadCallback(); | 112 bool DoBufferedReadCallback(); |
105 bool ShouldWaitForMoreBufferedData() const; | 113 bool ShouldWaitForMoreBufferedData() const; |
106 | 114 |
107 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; | 115 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 148 |
141 // Is there a scheduled read callback pending. | 149 // Is there a scheduled read callback pending. |
142 bool buffered_read_callback_pending_; | 150 bool buffered_read_callback_pending_; |
143 // Has more data been received from the network during the wait for the | 151 // Has more data been received from the network during the wait for the |
144 // scheduled read callback. | 152 // scheduled read callback. |
145 bool more_read_data_pending_; | 153 bool more_read_data_pending_; |
146 | 154 |
147 // Is this spdy stream direct to the origin server (or to a proxy). | 155 // Is this spdy stream direct to the origin server (or to a proxy). |
148 bool direct_; | 156 bool direct_; |
149 | 157 |
| 158 // Is the connection stalled waiting for an upload data chunk. |
| 159 bool waiting_for_chunk_; |
| 160 |
150 bool send_last_chunk_; | 161 bool send_last_chunk_; |
151 | 162 |
152 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 163 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
153 }; | 164 }; |
154 | 165 |
155 } // namespace net | 166 } // namespace net |
156 | 167 |
157 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 168 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
OLD | NEW |