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

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 3282003: Support handling blob URL and resolve blob references in upload data.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 URLRequest, meaning it is a "simple" version 6 // The class is implemented using URLRequest, meaning it is a "simple" version
7 // that directly issues requests. The more complicated one used in the 7 // that directly issues requests. The more complicated one used in the
8 // browser uses IPC. 8 // browser uses IPC.
9 // 9 //
10 // Because URLRequest only provides an asynchronous resource loading API, this 10 // Because URLRequest only provides an asynchronous resource loading API, this
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "net/base/upload_data.h" 51 #include "net/base/upload_data.h"
52 #include "net/http/http_cache.h" 52 #include "net/http/http_cache.h"
53 #include "net/http/http_request_headers.h" 53 #include "net/http/http_request_headers.h"
54 #include "net/http/http_response_headers.h" 54 #include "net/http/http_response_headers.h"
55 #include "net/proxy/proxy_service.h" 55 #include "net/proxy/proxy_service.h"
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 #include "net/socket/ssl_client_socket_nss_factory.h" 57 #include "net/socket/ssl_client_socket_nss_factory.h"
58 #endif 58 #endif
59 #include "net/url_request/url_request.h" 59 #include "net/url_request/url_request.h"
60 #include "webkit/appcache/appcache_interfaces.h" 60 #include "webkit/appcache/appcache_interfaces.h"
61 #include "webkit/blob/blob_storage_controller.h"
61 #include "webkit/glue/resource_loader_bridge.h" 62 #include "webkit/glue/resource_loader_bridge.h"
62 #include "webkit/tools/test_shell/simple_appcache_system.h" 63 #include "webkit/tools/test_shell/simple_appcache_system.h"
63 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" 64 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h"
64 #include "webkit/tools/test_shell/test_shell_request_context.h" 65 #include "webkit/tools/test_shell/test_shell_request_context.h"
66 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h"
65 67
66 using webkit_glue::ResourceLoaderBridge; 68 using webkit_glue::ResourceLoaderBridge;
67 using net::StaticCookiePolicy; 69 using net::StaticCookiePolicy;
68 using net::HttpResponseHeaders; 70 using net::HttpResponseHeaders;
69 71
70 namespace { 72 namespace {
71 73
72 struct TestShellRequestContextParams { 74 struct TestShellRequestContextParams {
73 TestShellRequestContextParams( 75 TestShellRequestContextParams(
74 const FilePath& in_cache_path, 76 const FilePath& in_cache_path,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 g_request_context_params = NULL; 115 g_request_context_params = NULL;
114 } else { 116 } else {
115 g_request_context = new TestShellRequestContext(); 117 g_request_context = new TestShellRequestContext();
116 SetAcceptAllCookies(false); 118 SetAcceptAllCookies(false);
117 } 119 }
118 120
119 g_request_context->AddRef(); 121 g_request_context->AddRef();
120 122
121 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); 123 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context);
122 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); 124 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context);
125 TestShellWebBlobRegistryImpl::InitializeOnIOThread(
126 static_cast<TestShellRequestContext*>(g_request_context)->
127 blob_storage_controller());
123 } 128 }
124 129
125 virtual void CleanUp() { 130 virtual void CleanUp() {
126 SimpleSocketStreamBridge::Cleanup(); 131 SimpleSocketStreamBridge::Cleanup();
132 TestShellWebBlobRegistryImpl::Cleanup();
127 if (g_request_context) { 133 if (g_request_context) {
128 g_request_context->Release(); 134 g_request_context->Release();
129 g_request_context = NULL; 135 g_request_context = NULL;
130 } 136 }
131 } 137 }
132 138
133 void SetAcceptAllCookies(bool accept_all_cookies) { 139 void SetAcceptAllCookies(bool accept_all_cookies) {
134 StaticCookiePolicy::Type policy_type = accept_all_cookies ? 140 StaticCookiePolicy::Type policy_type = accept_all_cookies ?
135 StaticCookiePolicy::ALLOW_ALL_COOKIES : 141 StaticCookiePolicy::ALLOW_ALL_COOKIES :
136 StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES; 142 StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 void NotifyUploadProgress(uint64 position, uint64 size) { 262 void NotifyUploadProgress(uint64 position, uint64 size) {
257 if (peer_) 263 if (peer_)
258 peer_->OnUploadProgress(position, size); 264 peer_->OnUploadProgress(position, size);
259 } 265 }
260 266
261 // -------------------------------------------------------------------------- 267 // --------------------------------------------------------------------------
262 // The following methods are called on the io thread. They correspond to 268 // The following methods are called on the io thread. They correspond to
263 // actions performed on the owner's thread. 269 // actions performed on the owner's thread.
264 270
265 void AsyncStart(RequestParams* params) { 271 void AsyncStart(RequestParams* params) {
272 // Might need to resolve the blob references in the upload data.
273 if (params->upload) {
274 static_cast<TestShellRequestContext*>(g_request_context)->
275 blob_storage_controller()->ResolveBlobReferencesInUploadData(
276 params->upload.get());
277 }
278
266 request_.reset(new URLRequest(params->url, this)); 279 request_.reset(new URLRequest(params->url, this));
267 request_->set_method(params->method); 280 request_->set_method(params->method);
268 request_->set_first_party_for_cookies(params->first_party_for_cookies); 281 request_->set_first_party_for_cookies(params->first_party_for_cookies);
269 request_->set_referrer(params->referrer.spec()); 282 request_->set_referrer(params->referrer.spec());
270 net::HttpRequestHeaders headers; 283 net::HttpRequestHeaders headers;
271 headers.AddHeadersFromString(params->headers); 284 headers.AddHeadersFromString(params->headers);
272 request_->SetExtraRequestHeaders(headers); 285 request_->SetExtraRequestHeaders(headers);
273 request_->set_load_flags(params->load_flags); 286 request_->set_load_flags(params->load_flags);
274 request_->set_upload(params->upload.get()); 287 request_->set_upload(params->upload.get());
275 request_->set_context(g_request_context); 288 request_->set_context(g_request_context);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 uint64 offset, 588 uint64 offset,
576 uint64 length, 589 uint64 length,
577 const base::Time& expected_modification_time) { 590 const base::Time& expected_modification_time) {
578 DCHECK(params_.get()); 591 DCHECK(params_.get());
579 if (!params_->upload) 592 if (!params_->upload)
580 params_->upload = new net::UploadData(); 593 params_->upload = new net::UploadData();
581 params_->upload->AppendFileRange(file_path, offset, length, 594 params_->upload->AppendFileRange(file_path, offset, length,
582 expected_modification_time); 595 expected_modification_time);
583 } 596 }
584 597
598 virtual void AppendBlobToUpload(const GURL& blob_url) {
599 DCHECK(params_.get());
600 if (!params_->upload)
601 params_->upload = new net::UploadData();
602 params_->upload->AppendBlob(blob_url);
603 }
604
585 virtual void SetUploadIdentifier(int64 identifier) { 605 virtual void SetUploadIdentifier(int64 identifier) {
586 DCHECK(params_.get()); 606 DCHECK(params_.get());
587 if (!params_->upload) 607 if (!params_->upload)
588 params_->upload = new net::UploadData(); 608 params_->upload = new net::UploadData();
589 params_->upload->set_identifier(identifier); 609 params_->upload->set_identifier(identifier);
590 } 610 }
591 611
592 virtual bool Start(Peer* peer) { 612 virtual bool Start(Peer* peer) {
593 DCHECK(!proxy_); 613 DCHECK(!proxy_);
594 614
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 849
830 // static 850 // static
831 scoped_refptr<base::MessageLoopProxy> 851 scoped_refptr<base::MessageLoopProxy>
832 SimpleResourceLoaderBridge::GetIoThread() { 852 SimpleResourceLoaderBridge::GetIoThread() {
833 if (!EnsureIOThread()) { 853 if (!EnsureIOThread()) {
834 LOG(DFATAL) << "Failed to create IO thread."; 854 LOG(DFATAL) << "Failed to create IO thread.";
835 return NULL; 855 return NULL;
836 } 856 }
837 return g_io_thread->message_loop_proxy(); 857 return g_io_thread->message_loop_proxy();
838 } 858 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698