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_HTTP_HTTP_STREAM_PARSER_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_PARSER_H_ |
6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ | 6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Returns true if request headers and body should be merged (i.e. the | 95 // Returns true if request headers and body should be merged (i.e. the |
96 // sum is small enough and the body is in memory, and not chunked). | 96 // sum is small enough and the body is in memory, and not chunked). |
97 static bool ShouldMergeRequestHeadersAndBody( | 97 static bool ShouldMergeRequestHeadersAndBody( |
98 const std::string& request_headers, | 98 const std::string& request_headers, |
99 const UploadDataStream* request_body); | 99 const UploadDataStream* request_body); |
100 | 100 |
101 // The number of extra bytes required to encode a chunk. | 101 // The number of extra bytes required to encode a chunk. |
102 static const size_t kChunkHeaderFooterSize; | 102 static const size_t kChunkHeaderFooterSize; |
103 | 103 |
104 private: | 104 private: |
| 105 class SeekableIOBuffer; |
| 106 |
105 // FOO_COMPLETE states implement the second half of potentially asynchronous | 107 // FOO_COMPLETE states implement the second half of potentially asynchronous |
106 // operations and don't necessarily mean that FOO is complete. | 108 // operations and don't necessarily mean that FOO is complete. |
107 enum State { | 109 enum State { |
108 STATE_NONE, | 110 STATE_NONE, |
109 STATE_SENDING_HEADERS, | 111 STATE_SENDING_HEADERS, |
110 // If the request comes with a body, either of the following two | 112 // If the request comes with a body, either of the following two |
111 // states will be executed, depending on whether the body is chunked | 113 // states will be executed, depending on whether the body is chunked |
112 // or not. | 114 // or not. |
113 STATE_SENDING_CHUNKED_BODY, | 115 STATE_SENDING_CHUNKED_BODY, |
114 STATE_SENDING_NON_CHUNKED_BODY, | 116 STATE_SENDING_NON_CHUNKED_BODY, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // The underlying socket. | 218 // The underlying socket. |
217 ClientSocketHandle* const connection_; | 219 ClientSocketHandle* const connection_; |
218 | 220 |
219 BoundNetLog net_log_; | 221 BoundNetLog net_log_; |
220 | 222 |
221 // Callback to be used when doing IO. | 223 // Callback to be used when doing IO. |
222 CompletionCallback io_callback_; | 224 CompletionCallback io_callback_; |
223 | 225 |
224 // Stores an encoded chunk for chunked uploads. | 226 // Stores an encoded chunk for chunked uploads. |
225 // Note: This should perhaps be improved to not create copies of the data. | 227 // Note: This should perhaps be improved to not create copies of the data. |
226 scoped_refptr<IOBufferWithSize> raw_chunk_buf_; | 228 scoped_refptr<SeekableIOBuffer> chunk_buf_; |
227 // Wraps raw_chunk_buf_ to read the remaining data progressively. | |
228 scoped_refptr<DrainableIOBuffer> chunk_buf_; | |
229 size_t chunk_length_without_encoding_; | 229 size_t chunk_length_without_encoding_; |
230 bool sent_last_chunk_; | 230 bool sent_last_chunk_; |
231 | 231 |
232 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 232 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
233 }; | 233 }; |
234 | 234 |
235 } // namespace net | 235 } // namespace net |
236 | 236 |
237 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 237 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
OLD | NEW |