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

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.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: 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
« webkit/glue/webupload_data.h ('K') | « webkit/glue/webupload_data.cc ('k') | no next file » | 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 // This file contains an implementation of the ResourceLoaderBridge class. 5 // This file contains an implementation of the ResourceLoaderBridge class.
6 // The class is implemented using net::URLRequest, meaning it is a "simple" 6 // The class is implemented using net::URLRequest, meaning it is a "simple"
7 // version that directly issues requests. The more complicated one used in the 7 // version that directly issues requests. The more complicated one used in the
8 // browser uses IPC. 8 // browser uses IPC.
9 // 9 //
10 // Because net::URLRequest only provides an asynchronous resource loading API, 10 // Because net::URLRequest only provides an asynchronous resource loading API,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "net/url_request/url_request_job.h" 62 #include "net/url_request/url_request_job.h"
63 #include "webkit/appcache/appcache_interfaces.h" 63 #include "webkit/appcache/appcache_interfaces.h"
64 #include "webkit/blob/blob_storage_controller.h" 64 #include "webkit/blob/blob_storage_controller.h"
65 #include "webkit/blob/blob_url_request_job.h" 65 #include "webkit/blob/blob_url_request_job.h"
66 #include "webkit/blob/shareable_file_reference.h" 66 #include "webkit/blob/shareable_file_reference.h"
67 #include "webkit/fileapi/file_system_context.h" 67 #include "webkit/fileapi/file_system_context.h"
68 #include "webkit/fileapi/file_system_dir_url_request_job.h" 68 #include "webkit/fileapi/file_system_dir_url_request_job.h"
69 #include "webkit/fileapi/file_system_url_request_job.h" 69 #include "webkit/fileapi/file_system_url_request_job.h"
70 #include "webkit/glue/resource_loader_bridge.h" 70 #include "webkit/glue/resource_loader_bridge.h"
71 #include "webkit/glue/webkit_glue.h" 71 #include "webkit/glue/webkit_glue.h"
72 #include "webkit/glue/webupload_data.h"
72 #include "webkit/tools/test_shell/simple_appcache_system.h" 73 #include "webkit/tools/test_shell/simple_appcache_system.h"
73 #include "webkit/tools/test_shell/simple_file_system.h" 74 #include "webkit/tools/test_shell/simple_file_system.h"
74 #include "webkit/tools/test_shell/simple_file_writer.h" 75 #include "webkit/tools/test_shell/simple_file_writer.h"
75 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" 76 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h"
76 #include "webkit/tools/test_shell/test_shell_request_context.h" 77 #include "webkit/tools/test_shell/test_shell_request_context.h"
77 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" 78 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h"
78 79
79 #if defined(OS_MACOSX) || defined(OS_WIN) 80 #if defined(OS_MACOSX) || defined(OS_WIN)
80 #include "crypto/nss_util.h" 81 #include "crypto/nss_util.h"
81 #endif 82 #endif
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 std::string method; 273 std::string method;
273 GURL url; 274 GURL url;
274 GURL first_party_for_cookies; 275 GURL first_party_for_cookies;
275 GURL referrer; 276 GURL referrer;
276 WebKit::WebReferrerPolicy referrer_policy; 277 WebKit::WebReferrerPolicy referrer_policy;
277 std::string headers; 278 std::string headers;
278 int load_flags; 279 int load_flags;
279 ResourceType::Type request_type; 280 ResourceType::Type request_type;
280 int appcache_host_id; 281 int appcache_host_id;
281 bool download_to_file; 282 bool download_to_file;
282 scoped_refptr<net::UploadData> upload; 283 scoped_refptr<WebUploadData> upload;
283 }; 284 };
284 285
285 // The interval for calls to RequestProxy::MaybeUpdateUploadProgress 286 // The interval for calls to RequestProxy::MaybeUpdateUploadProgress
286 static const int kUpdateUploadProgressIntervalMsec = 100; 287 static const int kUpdateUploadProgressIntervalMsec = 100;
287 288
288 // The RequestProxy does most of its work on the IO thread. The Start and 289 // The RequestProxy does most of its work on the IO thread. The Start and
289 // Cancel methods are proxied over to the IO thread, where an net::URLRequest 290 // Cancel methods are proxied over to the IO thread, where an net::URLRequest
290 // object is instantiated. 291 // object is instantiated.
291 struct DeleteOnIOThread; // See below. 292 struct DeleteOnIOThread; // See below.
292 class RequestProxy 293 class RequestProxy
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 request_.reset(new net::URLRequest(params->url, this, g_request_context)); 425 request_.reset(new net::URLRequest(params->url, this, g_request_context));
425 request_->set_method(params->method); 426 request_->set_method(params->method);
426 request_->set_first_party_for_cookies(params->first_party_for_cookies); 427 request_->set_first_party_for_cookies(params->first_party_for_cookies);
427 request_->set_referrer(params->referrer.spec()); 428 request_->set_referrer(params->referrer.spec());
428 webkit_glue::ConfigureURLRequestForReferrerPolicy( 429 webkit_glue::ConfigureURLRequestForReferrerPolicy(
429 request_.get(), params->referrer_policy); 430 request_.get(), params->referrer_policy);
430 net::HttpRequestHeaders headers; 431 net::HttpRequestHeaders headers;
431 headers.AddHeadersFromString(params->headers); 432 headers.AddHeadersFromString(params->headers);
432 request_->SetExtraRequestHeaders(headers); 433 request_->SetExtraRequestHeaders(headers);
433 request_->set_load_flags(params->load_flags); 434 request_->set_load_flags(params->load_flags);
434 request_->set_upload(params->upload.get()); 435 scoped_refptr<net::UploadData> upload = new net::UploadData;
436 params->upload->PopulateUploadData(upload.get());
437 request_->set_upload(upload);
435 SimpleAppCacheSystem::SetExtraRequestInfo( 438 SimpleAppCacheSystem::SetExtraRequestInfo(
436 request_.get(), params->appcache_host_id, params->request_type); 439 request_.get(), params->appcache_host_id, params->request_type);
437 440
438 download_to_file_ = params->download_to_file; 441 download_to_file_ = params->download_to_file;
439 if (download_to_file_) { 442 if (download_to_file_) {
440 FilePath path; 443 FilePath path;
441 if (file_util::CreateTemporaryFile(&path)) { 444 if (file_util::CreateTemporaryFile(&path)) {
442 downloaded_file_ = ShareableFileReference::GetOrCreate( 445 downloaded_file_ = ShareableFileReference::GetOrCreate(
443 path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 446 path, ShareableFileReference::DELETE_ON_FINAL_RELEASE,
444 base::MessageLoopProxy::current()); 447 base::MessageLoopProxy::current());
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 g_io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_); 873 g_io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_);
871 } 874 }
872 } 875 }
873 876
874 // -------------------------------------------------------------------------- 877 // --------------------------------------------------------------------------
875 // ResourceLoaderBridge implementation: 878 // ResourceLoaderBridge implementation:
876 879
877 virtual void AppendDataToUpload(const char* data, int data_len) { 880 virtual void AppendDataToUpload(const char* data, int data_len) {
878 DCHECK(params_.get()); 881 DCHECK(params_.get());
879 if (!params_->upload) 882 if (!params_->upload)
880 params_->upload = new net::UploadData(); 883 params_->upload = new WebUploadData();
881 params_->upload->AppendBytes(data, data_len); 884 params_->upload->AppendBytes(data, data_len);
882 } 885 }
883 886
884 virtual void AppendFileRangeToUpload( 887 virtual void AppendFileRangeToUpload(
885 const FilePath& file_path, 888 const FilePath& file_path,
886 uint64 offset, 889 uint64 offset,
887 uint64 length, 890 uint64 length,
888 const base::Time& expected_modification_time) { 891 const base::Time& expected_modification_time) {
889 DCHECK(params_.get()); 892 DCHECK(params_.get());
890 if (!params_->upload) 893 if (!params_->upload)
891 params_->upload = new net::UploadData(); 894 params_->upload = new WebUploadData();
892 params_->upload->AppendFileRange(file_path, offset, length, 895 params_->upload->AppendFileRange(file_path, offset, length,
893 expected_modification_time); 896 expected_modification_time);
894 } 897 }
895 898
896 virtual void AppendBlobToUpload(const GURL& blob_url) { 899 virtual void AppendBlobToUpload(const GURL& blob_url) {
897 DCHECK(params_.get()); 900 DCHECK(params_.get());
898 if (!params_->upload) 901 if (!params_->upload)
899 params_->upload = new net::UploadData(); 902 params_->upload = new WebUploadData();
900 params_->upload->AppendBlob(blob_url); 903 params_->upload->AppendBlob(blob_url);
901 } 904 }
902 905
903 virtual void SetUploadIdentifier(int64 identifier) { 906 virtual void SetUploadIdentifier(int64 identifier) {
904 DCHECK(params_.get()); 907 DCHECK(params_.get());
905 if (!params_->upload) 908 if (!params_->upload)
906 params_->upload = new net::UploadData(); 909 params_->upload = new WebUploadData();
907 params_->upload->set_identifier(identifier); 910 params_->upload->set_identifier(identifier);
908 } 911 }
909 912
910 virtual bool Start(Peer* peer) { 913 virtual bool Start(Peer* peer) {
911 DCHECK(!proxy_); 914 DCHECK(!proxy_);
912 915
913 if (!SimpleResourceLoaderBridge::EnsureIOThread()) 916 if (!SimpleResourceLoaderBridge::EnsureIOThread())
914 return false; 917 return false;
915 918
916 proxy_ = new RequestProxy(); 919 proxy_ = new RequestProxy();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); 1137 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https")));
1135 g_file_over_http_params = new FileOverHTTPParams(file_path_template, 1138 g_file_over_http_params = new FileOverHTTPParams(file_path_template,
1136 http_prefix); 1139 http_prefix);
1137 } 1140 }
1138 1141
1139 // static 1142 // static
1140 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( 1143 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create(
1141 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { 1144 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
1142 return new ResourceLoaderBridgeImpl(request_info); 1145 return new ResourceLoaderBridgeImpl(request_info);
1143 } 1146 }
OLDNEW
« webkit/glue/webupload_data.h ('K') | « webkit/glue/webupload_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698