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 // HttpStream provides an abstraction for a basic http streams, SPDY, and QUIC. | 5 // HttpStream provides an abstraction for a basic http streams, SPDY, and QUIC. |
6 // The HttpStream subtype is expected to manage the underlying transport | 6 // The HttpStream subtype is expected to manage the underlying transport |
7 // appropriately. For example, a basic http stream will return the transport | 7 // appropriately. For example, a basic http stream will return the transport |
8 // socket to the pool for reuse. SPDY streams on the other hand leave the | 8 // socket to the pool for reuse. SPDY streams on the other hand leave the |
9 // transport socket management to the SpdySession. | 9 // transport socket management to the SpdySession. |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // Writes the headers and uploads body data to the underlying socket. | 57 // Writes the headers and uploads body data to the underlying socket. |
58 // ERR_IO_PENDING is returned if the operation could not be completed | 58 // ERR_IO_PENDING is returned if the operation could not be completed |
59 // synchronously, in which case the result will be passed to the callback | 59 // synchronously, in which case the result will be passed to the callback |
60 // when available. Returns OK on success. | 60 // when available. Returns OK on success. |
61 // | 61 // |
62 // The callback will only be invoked once the first full set of headers have | 62 // The callback will only be invoked once the first full set of headers have |
63 // been received, at which point |response| will have been populated with that | 63 // been received, at which point |response| will have been populated with that |
64 // set of headers, and is safe to read, until/unless ReadResponseHeaders is | 64 // set of headers, and is safe to read, until/unless ReadResponseHeaders is |
65 // called. | 65 // called. |
66 // | 66 // |
67 // |response| must remain valid until all sets of headers has been read, or | 67 // |response| must remain valid for the lifetime of the stream. There's |
68 // the HttpStream is destroyed. There's typically only one set of | 68 // typically only one set of headers, except in the case of 1xx responses (See |
69 // headers, except in the case of 1xx responses (See ReadResponseHeaders). | 69 // ReadResponseHeaders). |
70 // TODO(mmenke): |response|'s lifetime and ownership models are somewhat | |
71 // bonkers, particularly considering HttpNetworkTransaction can clobber | |
72 // it. Can something better be done, preferably without keeping multiple | |
73 // copies of the struct around? | |
70 virtual int SendRequest(const HttpRequestHeaders& request_headers, | 74 virtual int SendRequest(const HttpRequestHeaders& request_headers, |
71 HttpResponseInfo* response, | 75 HttpResponseInfo* response, |
72 const CompletionCallback& callback) = 0; | 76 const CompletionCallback& callback) = 0; |
73 | 77 |
74 // Reads from the underlying socket until the next set of response headers | 78 // Reads from the underlying socket until the next set of response headers |
75 // have been completely received. This may only be called on 1xx responses | 79 // have been completely received. This may only be called on 1xx responses |
76 // after SendRequest has completed successfully, to read the next set of | 80 // after SendRequest has completed successfully, to read the next set of |
77 // headers. | 81 // headers. |
78 // | 82 // |
79 // ERR_IO_PENDING is returned if the operation could not be completed | 83 // ERR_IO_PENDING is returned if the operation could not be completed |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 164 |
161 // Signs the EKM value for Token Binding from the TLS layer using |*key| and | 165 // Signs the EKM value for Token Binding from the TLS layer using |*key| and |
162 // puts the result in |*out|. Returns OK or ERR_FAILED. | 166 // puts the result in |*out|. Returns OK or ERR_FAILED. |
163 virtual Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, | 167 virtual Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
164 std::vector<uint8_t>* out) = 0; | 168 std::vector<uint8_t>* out) = 0; |
165 | 169 |
166 // In the case of an HTTP error or redirect, flush the response body (usually | 170 // In the case of an HTTP error or redirect, flush the response body (usually |
167 // a simple error or "this page has moved") so that we can re-use the | 171 // a simple error or "this page has moved") so that we can re-use the |
168 // underlying connection. This stream is responsible for deleting itself when | 172 // underlying connection. This stream is responsible for deleting itself when |
169 // draining is complete. | 173 // draining is complete. |
170 virtual void Drain(HttpNetworkSession* session) = 0; | 174 virtual void Drain(HttpNetworkSession* session, |
175 scoped_ptr<HttpResponseInfo> response_info) = 0; | |
asanka
2016/05/13 15:19:52
Should document here that |response_info| *must* b
mmenke
2016/05/20 21:50:02
The more I looked at this, the less I liked it. I
| |
171 | 176 |
172 // Get the network error details this stream is encountering. | 177 // Get the network error details this stream is encountering. |
173 // Fills in |details| if it is available; leaves |details| unchanged if it | 178 // Fills in |details| if it is available; leaves |details| unchanged if it |
174 // is unavailable. | 179 // is unavailable. |
175 virtual void PopulateNetErrorDetails(NetErrorDetails* details) = 0; | 180 virtual void PopulateNetErrorDetails(NetErrorDetails* details) = 0; |
176 | 181 |
177 // Called when the priority of the parent transaction changes. | 182 // Called when the priority of the parent transaction changes. |
178 virtual void SetPriority(RequestPriority priority) = 0; | 183 virtual void SetPriority(RequestPriority priority) = 0; |
179 | 184 |
180 // Queries the UploadDataStream for its progress (bytes sent). | 185 // Queries the UploadDataStream for its progress (bytes sent). |
181 virtual UploadProgress GetUploadProgress() const = 0; | 186 virtual UploadProgress GetUploadProgress() const = 0; |
182 | 187 |
183 // Returns a new (not initialized) stream using the same underlying | 188 // Returns a new (not initialized) stream using the same underlying |
184 // connection and invalidates the old stream - no further methods should be | 189 // connection and invalidates the old stream - no further methods should be |
185 // called on the old stream. The caller should ensure that the response body | 190 // called on the old stream. The caller should ensure that the response body |
186 // from the previous request is drained before calling this method. If the | 191 // from the previous request is drained before calling this method. If the |
187 // subclass does not support renewing the stream, NULL is returned. | 192 // subclass does not support renewing the stream, NULL is returned. |
188 virtual HttpStream* RenewStreamForAuth() = 0; | 193 virtual HttpStream* RenewStreamForAuth() = 0; |
189 | 194 |
190 private: | 195 private: |
191 DISALLOW_COPY_AND_ASSIGN(HttpStream); | 196 DISALLOW_COPY_AND_ASSIGN(HttpStream); |
192 }; | 197 }; |
193 | 198 |
194 } // namespace net | 199 } // namespace net |
195 | 200 |
196 #endif // NET_HTTP_HTTP_STREAM_H_ | 201 #endif // NET_HTTP_HTTP_STREAM_H_ |
OLD | NEW |