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

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

Issue 2130733003: [HttpStreamParser]: Flush buffers as soon as request is sent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased + mmenke's comments Created 4 years, 5 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
« no previous file with comments | « no previous file | net/http/http_stream_parser.cc » ('j') | net/http/http_stream_parser.cc » ('J')
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 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // operations and don't necessarily mean that FOO is complete. 128 // operations and don't necessarily mean that FOO is complete.
129 enum State { 129 enum State {
130 // STATE_NONE indicates that this is waiting on an external call before 130 // STATE_NONE indicates that this is waiting on an external call before
131 // continuing. 131 // continuing.
132 STATE_NONE, 132 STATE_NONE,
133 STATE_SEND_HEADERS, 133 STATE_SEND_HEADERS,
134 STATE_SEND_HEADERS_COMPLETE, 134 STATE_SEND_HEADERS_COMPLETE,
135 STATE_SEND_BODY, 135 STATE_SEND_BODY,
136 STATE_SEND_BODY_COMPLETE, 136 STATE_SEND_BODY_COMPLETE,
137 STATE_SEND_REQUEST_READ_BODY_COMPLETE, 137 STATE_SEND_REQUEST_READ_BODY_COMPLETE,
138 STATE_SEND_REQUEST_COMPLETE,
138 STATE_READ_HEADERS, 139 STATE_READ_HEADERS,
139 STATE_READ_HEADERS_COMPLETE, 140 STATE_READ_HEADERS_COMPLETE,
140 STATE_READ_BODY, 141 STATE_READ_BODY,
141 STATE_READ_BODY_COMPLETE, 142 STATE_READ_BODY_COMPLETE,
142 STATE_DONE 143 STATE_DONE
143 }; 144 };
144 145
145 // The number of bytes by which the header buffer is grown when it reaches 146 // The number of bytes by which the header buffer is grown when it reaches
146 // capacity. 147 // capacity.
147 static const int kHeaderBufInitialSize = 4 * 1024; // 4K 148 static const int kHeaderBufInitialSize = 4 * 1024; // 4K
(...skipping 12 matching lines...) Expand all
160 161
161 // Try to make progress sending/receiving the request/response. 162 // Try to make progress sending/receiving the request/response.
162 int DoLoop(int result); 163 int DoLoop(int result);
163 164
164 // The implementations of each state of the state machine. 165 // The implementations of each state of the state machine.
165 int DoSendHeaders(); 166 int DoSendHeaders();
166 int DoSendHeadersComplete(int result); 167 int DoSendHeadersComplete(int result);
167 int DoSendBody(); 168 int DoSendBody();
168 int DoSendBodyComplete(int result); 169 int DoSendBodyComplete(int result);
169 int DoSendRequestReadBodyComplete(int result); 170 int DoSendRequestReadBodyComplete(int result);
171 int DoSendRequestComplete(int result);
170 int DoReadHeaders(); 172 int DoReadHeaders();
171 int DoReadHeadersComplete(int result); 173 int DoReadHeadersComplete(int result);
172 int DoReadBody(); 174 int DoReadBody();
173 int DoReadBodyComplete(int result); 175 int DoReadBodyComplete(int result);
174 176
175 // This handles most of the logic for DoReadHeadersComplete. 177 // This handles most of the logic for DoReadHeadersComplete.
176 int HandleReadHeaderResult(int result); 178 int HandleReadHeaderResult(int result);
177 179
178 // Examines |read_buf_| to find the start and end of the headers. If they are 180 // Examines |read_buf_| to find the start and end of the headers. If they are
179 // found, parse them with DoParseResponseHeaders(). Return the offset for 181 // found, parse them with DoParseResponseHeaders(). Return the offset for
180 // the end of the headers, or -1 if the complete headers were not found, or 182 // the end of the headers, or -1 if the complete headers were not found, or
181 // with a net::Error if we encountered an error during parsing. 183 // with a net::Error if we encountered an error during parsing.
182 int FindAndParseResponseHeaders(); 184 int FindAndParseResponseHeaders();
183 185
184 // Parse the headers into response_. Returns OK on success or a net::Error on 186 // Parse the headers into response_. Returns OK on success or a net::Error on
185 // failure. 187 // failure.
186 int ParseResponseHeaders(int end_of_header_offset); 188 int ParseResponseHeaders(int end_of_header_offset);
187 189
188 // Examine the parsed headers to try to determine the response body size. 190 // Examine the parsed headers to try to determine the response body size.
189 void CalculateResponseBodySize(); 191 void CalculateResponseBodySize();
190 192
191 // Uploads statistics about status line compliance with RFC 7230. 193 // Uploads statistics about status line compliance with RFC 7230.
192 void ValidateStatusLine(const std::string& status_line); 194 void ValidateStatusLine(const std::string& status_line);
193 195
196 // Flush buffers once the request is sent.
197 void FlushBuffers();
198
199 // Check if buffers used to send the request are empty.
200 bool SendRequestBuffersEmpty();
201
194 // Next state of the request, when the current one completes. 202 // Next state of the request, when the current one completes.
195 State io_state_; 203 State io_state_;
196 204
197 // The request to send. 205 // The request to send.
198 const HttpRequestInfo* request_; 206 const HttpRequestInfo* request_;
199 207
200 // The request header data. May include a merged request body. 208 // The request header data. May include a merged request body.
201 scoped_refptr<DrainableIOBuffer> request_headers_; 209 scoped_refptr<DrainableIOBuffer> request_headers_;
202 210
203 // Size of just the request headers. May be less than the length of 211 // Size of just the request headers. May be less than the length of
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 int upload_error_; 284 int upload_error_;
277 285
278 base::WeakPtrFactory<HttpStreamParser> weak_ptr_factory_; 286 base::WeakPtrFactory<HttpStreamParser> weak_ptr_factory_;
279 287
280 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); 288 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser);
281 }; 289 };
282 290
283 } // namespace net 291 } // namespace net
284 292
285 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ 293 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_parser.cc » ('j') | net/http/http_stream_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698