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

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

Issue 2038813003: Making ResourceRequestBody part of //content's public API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 6 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/frame_messages.h » ('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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; 213 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES;
214 } 214 }
215 215
216 if (!request.allowStoredCredentials()) 216 if (!request.allowStoredCredentials())
217 load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; 217 load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA;
218 218
219 return load_flags; 219 return load_flags;
220 } 220 }
221 221
222 WebHTTPBody GetWebHTTPBodyForRequestBody( 222 WebHTTPBody GetWebHTTPBodyForRequestBody(
223 const scoped_refptr<ResourceRequestBody>& input) { 223 const scoped_refptr<ResourceRequestBodyImpl>& input) {
224 WebHTTPBody http_body; 224 WebHTTPBody http_body;
225 http_body.initialize(); 225 http_body.initialize();
226 http_body.setIdentifier(input->identifier()); 226 http_body.setIdentifier(input->identifier());
227 for (const auto& element : *input->elements()) { 227 for (const auto& element : *input->elements()) {
228 switch (element.type()) { 228 switch (element.type()) {
229 case ResourceRequestBody::Element::TYPE_BYTES: 229 case ResourceRequestBodyImpl::Element::TYPE_BYTES:
230 http_body.appendData(WebData(element.bytes(), element.length())); 230 http_body.appendData(WebData(element.bytes(), element.length()));
231 break; 231 break;
232 case ResourceRequestBody::Element::TYPE_FILE: 232 case ResourceRequestBodyImpl::Element::TYPE_FILE:
233 http_body.appendFileRange( 233 http_body.appendFileRange(
234 element.path().AsUTF16Unsafe(), element.offset(), 234 element.path().AsUTF16Unsafe(), element.offset(),
235 (element.length() != std::numeric_limits<uint64_t>::max()) 235 (element.length() != std::numeric_limits<uint64_t>::max())
236 ? element.length() 236 ? element.length()
237 : -1, 237 : -1,
238 element.expected_modification_time().ToDoubleT()); 238 element.expected_modification_time().ToDoubleT());
239 break; 239 break;
240 case ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM: 240 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM:
241 http_body.appendFileSystemURLRange( 241 http_body.appendFileSystemURLRange(
242 element.filesystem_url(), element.offset(), 242 element.filesystem_url(), element.offset(),
243 (element.length() != std::numeric_limits<uint64_t>::max()) 243 (element.length() != std::numeric_limits<uint64_t>::max())
244 ? element.length() 244 ? element.length()
245 : -1, 245 : -1,
246 element.expected_modification_time().ToDoubleT()); 246 element.expected_modification_time().ToDoubleT());
247 break; 247 break;
248 case ResourceRequestBody::Element::TYPE_BLOB: 248 case ResourceRequestBodyImpl::Element::TYPE_BLOB:
249 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); 249 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid()));
250 break; 250 break;
251 case ResourceRequestBody::Element::TYPE_BYTES_DESCRIPTION: 251 case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION:
252 case ResourceRequestBody::Element::TYPE_DISK_CACHE_ENTRY: 252 case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY:
253 default: 253 default:
254 NOTREACHED(); 254 NOTREACHED();
255 break; 255 break;
256 } 256 }
257 } 257 }
258 return http_body; 258 return http_body;
259 } 259 }
260 260
261 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebURLRequest( 261 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebURLRequest(
262 const blink::WebURLRequest& request) { 262 const blink::WebURLRequest& request) {
263 scoped_refptr<ResourceRequestBody> request_body; 263 scoped_refptr<ResourceRequestBodyImpl> request_body;
264 264
265 if (request.httpBody().isNull()) { 265 if (request.httpBody().isNull()) {
266 return request_body; 266 return request_body;
267 } 267 }
268 268
269 const std::string& method = request.httpMethod().latin1(); 269 const std::string& method = request.httpMethod().latin1();
270 // GET and HEAD requests shouldn't have http bodies. 270 // GET and HEAD requests shouldn't have http bodies.
271 DCHECK(method != "GET" && method != "HEAD"); 271 DCHECK(method != "GET" && method != "HEAD");
272 272
273 return GetRequestBodyForWebHTTPBody(request.httpBody()); 273 return GetRequestBodyForWebHTTPBody(request.httpBody());
274 } 274 }
275 275
276 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebHTTPBody( 276 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebHTTPBody(
277 const blink::WebHTTPBody& httpBody) { 277 const blink::WebHTTPBody& httpBody) {
278 scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody(); 278 scoped_refptr<ResourceRequestBodyImpl> request_body =
279 new ResourceRequestBodyImpl();
279 size_t i = 0; 280 size_t i = 0;
280 WebHTTPBody::Element element; 281 WebHTTPBody::Element element;
281 while (httpBody.elementAt(i++, element)) { 282 while (httpBody.elementAt(i++, element)) {
282 switch (element.type) { 283 switch (element.type) {
283 case WebHTTPBody::Element::TypeData: 284 case WebHTTPBody::Element::TypeData:
284 if (!element.data.isEmpty()) { 285 if (!element.data.isEmpty()) {
285 // Blink sometimes gives empty data to append. These aren't 286 // Blink sometimes gives empty data to append. These aren't
286 // necessary so they are just optimized out here. 287 // necessary so they are just optimized out here.
287 request_body->AppendBytes( 288 request_body->AppendBytes(
288 element.data.data(), static_cast<int>(element.data.size())); 289 element.data.data(), static_cast<int>(element.data.size()));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 bool stale_copy_in_cache, 480 bool stale_copy_in_cache,
480 int reason, 481 int reason,
481 bool was_ignored_by_handler) { 482 bool was_ignored_by_handler) {
482 blink::WebURLError error = 483 blink::WebURLError error =
483 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); 484 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason);
484 error.wasIgnoredByHandler = was_ignored_by_handler; 485 error.wasIgnoredByHandler = was_ignored_by_handler;
485 return error; 486 return error;
486 } 487 }
487 488
488 } // namespace content 489 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_request_util.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698