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

Side by Side Diff: webkit/glue/weburlloader_impl.cc

Issue 10834289: Split net::UploadData into two: for IPC and for upload handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + moved ResolveBlobRef from webkit_blob to webkit_glue Created 8 years, 4 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 | « webkit/glue/webkit_glue.gypi ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "webkit/glue/weburlloader_impl.h" 7 #include "webkit/glue/weburlloader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 14 matching lines...) Expand all
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoadTi ming.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoadTi ming.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h"
32 #include "webkit/glue/ftp_directory_listing_response_delegate.h" 32 #include "webkit/glue/ftp_directory_listing_response_delegate.h"
33 #include "webkit/glue/multipart_response_delegate.h" 33 #include "webkit/glue/multipart_response_delegate.h"
34 #include "webkit/glue/resource_loader_bridge.h" 34 #include "webkit/glue/resource_loader_bridge.h"
35 #include "webkit/glue/resource_request_body.h"
35 #include "webkit/glue/webkit_glue.h" 36 #include "webkit/glue/webkit_glue.h"
36 #include "webkit/glue/webkitplatformsupport_impl.h" 37 #include "webkit/glue/webkitplatformsupport_impl.h"
37 #include "webkit/glue/weburlrequest_extradata_impl.h" 38 #include "webkit/glue/weburlrequest_extradata_impl.h"
38 #include "webkit/glue/weburlresponse_extradata_impl.h" 39 #include "webkit/glue/weburlresponse_extradata_impl.h"
39 40
40 using base::Time; 41 using base::Time;
41 using base::TimeTicks; 42 using base::TimeTicks;
42 using WebKit::WebData; 43 using WebKit::WebData;
43 using WebKit::WebHTTPBody; 44 using WebKit::WebHTTPBody;
44 using WebKit::WebHTTPHeaderVisitor; 45 using WebKit::WebHTTPHeaderVisitor;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 request_info.referrer_policy = referrer_policy_; 438 request_info.referrer_policy = referrer_policy_;
438 } 439 }
439 bridge_.reset(platform->CreateResourceLoader(request_info)); 440 bridge_.reset(platform->CreateResourceLoader(request_info));
440 441
441 if (!request.httpBody().isNull()) { 442 if (!request.httpBody().isNull()) {
442 // GET and HEAD requests shouldn't have http bodies. 443 // GET and HEAD requests shouldn't have http bodies.
443 DCHECK(method != "GET" && method != "HEAD"); 444 DCHECK(method != "GET" && method != "HEAD");
444 const WebHTTPBody& httpBody = request.httpBody(); 445 const WebHTTPBody& httpBody = request.httpBody();
445 size_t i = 0; 446 size_t i = 0;
446 WebHTTPBody::Element element; 447 WebHTTPBody::Element element;
448 scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody;
447 while (httpBody.elementAt(i++, element)) { 449 while (httpBody.elementAt(i++, element)) {
448 switch (element.type) { 450 switch (element.type) {
449 case WebHTTPBody::Element::TypeData: 451 case WebHTTPBody::Element::TypeData:
450 if (!element.data.isEmpty()) { 452 if (!element.data.isEmpty()) {
451 // WebKit sometimes gives up empty data to append. These aren't 453 // WebKit sometimes gives up empty data to append. These aren't
452 // necessary so we just optimize those out here. 454 // necessary so we just optimize those out here.
453 bridge_->AppendDataToUpload( 455 request_body->AppendBytes(
454 element.data.data(), static_cast<int>(element.data.size())); 456 element.data.data(), static_cast<int>(element.data.size()));
455 } 457 }
456 break; 458 break;
457 case WebHTTPBody::Element::TypeFile: 459 case WebHTTPBody::Element::TypeFile:
458 if (element.fileLength == -1) { 460 if (element.fileLength == -1) {
459 bridge_->AppendFileToUpload( 461 request_body->AppendFileRange(
460 WebStringToFilePath(element.filePath)); 462 WebStringToFilePath(element.filePath),
463 0, kuint64max, base::Time());
461 } else { 464 } else {
462 bridge_->AppendFileRangeToUpload( 465 request_body->AppendFileRange(
463 WebStringToFilePath(element.filePath), 466 WebStringToFilePath(element.filePath),
464 static_cast<uint64>(element.fileStart), 467 static_cast<uint64>(element.fileStart),
465 static_cast<uint64>(element.fileLength), 468 static_cast<uint64>(element.fileLength),
466 base::Time::FromDoubleT(element.modificationTime)); 469 base::Time::FromDoubleT(element.modificationTime));
467 } 470 }
468 break; 471 break;
469 case WebHTTPBody::Element::TypeBlob: 472 case WebHTTPBody::Element::TypeBlob:
470 bridge_->AppendBlobToUpload(GURL(element.blobURL)); 473 request_body->AppendBlob(GURL(element.blobURL));
471 break; 474 break;
472 default: 475 default:
473 NOTREACHED(); 476 NOTREACHED();
474 } 477 }
475 } 478 }
476 bridge_->SetUploadIdentifier(request.httpBody().identifier()); 479 request_body->set_identifier(request.httpBody().identifier());
480 bridge_->SetRequestBody(request_body);
477 } 481 }
478 482
479 if (sync_load_response) { 483 if (sync_load_response) {
480 bridge_->SyncLoad(sync_load_response); 484 bridge_->SyncLoad(sync_load_response);
481 return; 485 return;
482 } 486 }
483 487
484 if (bridge_->Start(this)) { 488 if (bridge_->Start(this)) {
485 AddRef(); // Balanced in OnCompletedRequest 489 AddRef(); // Balanced in OnCompletedRequest
486 } else { 490 } else {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 769
766 void WebURLLoaderImpl::cancel() { 770 void WebURLLoaderImpl::cancel() {
767 context_->Cancel(); 771 context_->Cancel();
768 } 772 }
769 773
770 void WebURLLoaderImpl::setDefersLoading(bool value) { 774 void WebURLLoaderImpl::setDefersLoading(bool value) {
771 context_->SetDefersLoading(value); 775 context_->SetDefersLoading(value);
772 } 776 }
773 777
774 } // namespace webkit_glue 778 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698