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

Side by Side Diff: content/child/web_url_request_util.cc

Issue 2954343005: Merge ResourceRequestBodyImpl and ResourceRequestBody. (Closed)
Patch Set: Remove comment Created 3 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 | « content/child/web_url_request_util.h ('k') | content/common/BUILD.gn » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/child/web_url_request_util.h" 5 #include "content/child/web_url_request_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 RequestExtraData* extra_data = 225 RequestExtraData* extra_data =
226 static_cast<RequestExtraData*>(request.GetExtraData()); 226 static_cast<RequestExtraData*>(request.GetExtraData());
227 if (extra_data->is_prefetch()) 227 if (extra_data->is_prefetch())
228 load_flags |= net::LOAD_PREFETCH; 228 load_flags |= net::LOAD_PREFETCH;
229 } 229 }
230 230
231 return load_flags; 231 return load_flags;
232 } 232 }
233 233
234 WebHTTPBody GetWebHTTPBodyForRequestBody( 234 WebHTTPBody GetWebHTTPBodyForRequestBody(
235 const scoped_refptr<ResourceRequestBodyImpl>& input) { 235 const scoped_refptr<ResourceRequestBody>& input) {
236 WebHTTPBody http_body; 236 WebHTTPBody http_body;
237 http_body.Initialize(); 237 http_body.Initialize();
238 http_body.SetIdentifier(input->identifier()); 238 http_body.SetIdentifier(input->identifier());
239 http_body.SetContainsPasswordData(input->contains_sensitive_info()); 239 http_body.SetContainsPasswordData(input->contains_sensitive_info());
240 for (const auto& element : *input->elements()) { 240 for (const auto& element : *input->elements()) {
241 switch (element.type()) { 241 switch (element.type()) {
242 case ResourceRequestBodyImpl::Element::TYPE_BYTES: 242 case ResourceRequestBody::Element::TYPE_BYTES:
243 http_body.AppendData(WebData(element.bytes(), element.length())); 243 http_body.AppendData(WebData(element.bytes(), element.length()));
244 break; 244 break;
245 case ResourceRequestBodyImpl::Element::TYPE_FILE: 245 case ResourceRequestBody::Element::TYPE_FILE:
246 http_body.AppendFileRange( 246 http_body.AppendFileRange(
247 blink::FilePathToWebString(element.path()), element.offset(), 247 blink::FilePathToWebString(element.path()), element.offset(),
248 (element.length() != std::numeric_limits<uint64_t>::max()) 248 (element.length() != std::numeric_limits<uint64_t>::max())
249 ? element.length() 249 ? element.length()
250 : -1, 250 : -1,
251 element.expected_modification_time().ToDoubleT()); 251 element.expected_modification_time().ToDoubleT());
252 break; 252 break;
253 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: 253 case ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM:
254 http_body.AppendFileSystemURLRange( 254 http_body.AppendFileSystemURLRange(
255 element.filesystem_url(), element.offset(), 255 element.filesystem_url(), element.offset(),
256 (element.length() != std::numeric_limits<uint64_t>::max()) 256 (element.length() != std::numeric_limits<uint64_t>::max())
257 ? element.length() 257 ? element.length()
258 : -1, 258 : -1,
259 element.expected_modification_time().ToDoubleT()); 259 element.expected_modification_time().ToDoubleT());
260 break; 260 break;
261 case ResourceRequestBodyImpl::Element::TYPE_BLOB: 261 case ResourceRequestBody::Element::TYPE_BLOB:
262 http_body.AppendBlob(WebString::FromASCII(element.blob_uuid())); 262 http_body.AppendBlob(WebString::FromASCII(element.blob_uuid()));
263 break; 263 break;
264 case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION: 264 case ResourceRequestBody::Element::TYPE_BYTES_DESCRIPTION:
265 case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY: 265 case ResourceRequestBody::Element::TYPE_DISK_CACHE_ENTRY:
266 default: 266 default:
267 NOTREACHED(); 267 NOTREACHED();
268 break; 268 break;
269 } 269 }
270 } 270 }
271 return http_body; 271 return http_body;
272 } 272 }
273 273
274 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebURLRequest( 274 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebURLRequest(
275 const blink::WebURLRequest& request) { 275 const blink::WebURLRequest& request) {
276 scoped_refptr<ResourceRequestBodyImpl> request_body; 276 scoped_refptr<ResourceRequestBody> request_body;
277 277
278 if (request.HttpBody().IsNull()) { 278 if (request.HttpBody().IsNull()) {
279 return request_body; 279 return request_body;
280 } 280 }
281 281
282 const std::string& method = request.HttpMethod().Latin1(); 282 const std::string& method = request.HttpMethod().Latin1();
283 // GET and HEAD requests shouldn't have http bodies. 283 // GET and HEAD requests shouldn't have http bodies.
284 DCHECK(method != "GET" && method != "HEAD"); 284 DCHECK(method != "GET" && method != "HEAD");
285 285
286 return GetRequestBodyForWebHTTPBody(request.HttpBody()); 286 return GetRequestBodyForWebHTTPBody(request.HttpBody());
287 } 287 }
288 288
289 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebHTTPBody( 289 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebHTTPBody(
290 const blink::WebHTTPBody& httpBody) { 290 const blink::WebHTTPBody& httpBody) {
291 scoped_refptr<ResourceRequestBodyImpl> request_body = 291 scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody();
292 new ResourceRequestBodyImpl();
293 size_t i = 0; 292 size_t i = 0;
294 WebHTTPBody::Element element; 293 WebHTTPBody::Element element;
295 while (httpBody.ElementAt(i++, element)) { 294 while (httpBody.ElementAt(i++, element)) {
296 switch (element.type) { 295 switch (element.type) {
297 case WebHTTPBody::Element::kTypeData: 296 case WebHTTPBody::Element::kTypeData:
298 if (!element.data.IsEmpty()) { 297 if (!element.data.IsEmpty()) {
299 // Blink sometimes gives empty data to append. These aren't 298 // Blink sometimes gives empty data to append. These aren't
300 // necessary so they are just optimized out here. 299 // necessary so they are just optimized out here.
301 request_body->AppendBytes(element.data.Data(), 300 request_body->AppendBytes(element.data.Data(),
302 static_cast<int>(element.data.size())); 301 static_cast<int>(element.data.size()));
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 bool stale_copy_in_cache, 520 bool stale_copy_in_cache,
522 int reason, 521 int reason,
523 bool was_ignored_by_handler) { 522 bool was_ignored_by_handler) {
524 blink::WebURLError error = 523 blink::WebURLError error =
525 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); 524 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason);
526 error.was_ignored_by_handler = was_ignored_by_handler; 525 error.was_ignored_by_handler = was_ignored_by_handler;
527 return error; 526 return error;
528 } 527 }
529 528
530 } // namespace content 529 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_request_util.h ('k') | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698