Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: net/http/http_stream_parser.h

Issue 9293029: net: Introduce SeekableIOBuffer and clean up HttpStreamParser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/io_buffer.h ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « net/base/io_buffer.h ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698