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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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
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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "net/base/upload_data_stream.h" 80 #include "net/base/upload_data_stream.h"
81 #include "net/cert/cert_status_flags.h" 81 #include "net/cert/cert_status_flags.h"
82 #include "net/cookies/cookie_monster.h" 82 #include "net/cookies/cookie_monster.h"
83 #include "net/http/http_response_headers.h" 83 #include "net/http/http_response_headers.h"
84 #include "net/http/http_response_info.h" 84 #include "net/http/http_response_info.h"
85 #include "net/ssl/ssl_cert_request_info.h" 85 #include "net/ssl/ssl_cert_request_info.h"
86 #include "net/url_request/url_request.h" 86 #include "net/url_request/url_request.h"
87 #include "net/url_request/url_request_context.h" 87 #include "net/url_request/url_request_context.h"
88 #include "net/url_request/url_request_job_factory.h" 88 #include "net/url_request/url_request_job_factory.h"
89 #include "url/url_constants.h" 89 #include "url/url_constants.h"
90 #include "webkit/common/blob/blob_data.h" 90 #include "storage/common/blob/blob_data.h"
91 #include "webkit/browser/blob/blob_data_handle.h" 91 #include "storage/browser/blob/blob_data_handle.h"
92 #include "webkit/browser/blob/blob_storage_context.h" 92 #include "storage/browser/blob/blob_storage_context.h"
93 #include "webkit/browser/blob/blob_url_request_job_factory.h" 93 #include "storage/browser/blob/blob_url_request_job_factory.h"
94 #include "webkit/browser/fileapi/file_permission_policy.h" 94 #include "storage/browser/fileapi/file_permission_policy.h"
95 #include "webkit/browser/fileapi/file_system_context.h" 95 #include "storage/browser/fileapi/file_system_context.h"
96 #include "webkit/common/blob/shareable_file_reference.h" 96 #include "storage/common/blob/shareable_file_reference.h"
97 97
98 using base::Time; 98 using base::Time;
99 using base::TimeDelta; 99 using base::TimeDelta;
100 using base::TimeTicks; 100 using base::TimeTicks;
101 using webkit_blob::ShareableFileReference; 101 using storage::ShareableFileReference;
102 102
103 // ---------------------------------------------------------------------------- 103 // ----------------------------------------------------------------------------
104 104
105 namespace content { 105 namespace content {
106 106
107 namespace { 107 namespace {
108 108
109 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; 109 static ResourceDispatcherHostImpl* g_resource_dispatcher_host;
110 110
111 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates 111 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 request->set_referrer_policy(net_referrer_policy); 193 request->set_referrer_policy(net_referrer_policy);
194 } 194 }
195 195
196 // Consults the RendererSecurity policy to determine whether the 196 // Consults the RendererSecurity policy to determine whether the
197 // ResourceDispatcherHostImpl should service this request. A request might be 197 // ResourceDispatcherHostImpl should service this request. A request might be
198 // disallowed if the renderer is not authorized to retrieve the request URL or 198 // disallowed if the renderer is not authorized to retrieve the request URL or
199 // if the renderer is attempting to upload an unauthorized file. 199 // if the renderer is attempting to upload an unauthorized file.
200 bool ShouldServiceRequest(int process_type, 200 bool ShouldServiceRequest(int process_type,
201 int child_id, 201 int child_id,
202 const ResourceHostMsg_Request& request_data, 202 const ResourceHostMsg_Request& request_data,
203 fileapi::FileSystemContext* file_system_context) { 203 storage::FileSystemContext* file_system_context) {
204 if (process_type == PROCESS_TYPE_PLUGIN) 204 if (process_type == PROCESS_TYPE_PLUGIN)
205 return true; 205 return true;
206 206
207 ChildProcessSecurityPolicyImpl* policy = 207 ChildProcessSecurityPolicyImpl* policy =
208 ChildProcessSecurityPolicyImpl::GetInstance(); 208 ChildProcessSecurityPolicyImpl::GetInstance();
209 209
210 // Check if the renderer is permitted to request the requested URL. 210 // Check if the renderer is permitted to request the requested URL.
211 if (!policy->CanRequestURL(child_id, request_data.url)) { 211 if (!policy->CanRequestURL(child_id, request_data.url)) {
212 VLOG(1) << "Denied unauthorized request for " 212 VLOG(1) << "Denied unauthorized request for "
213 << request_data.url.possibly_invalid_spec(); 213 << request_data.url.possibly_invalid_spec();
214 return false; 214 return false;
215 } 215 }
216 216
217 // Check if the renderer is permitted to upload the requested files. 217 // Check if the renderer is permitted to upload the requested files.
218 if (request_data.request_body.get()) { 218 if (request_data.request_body.get()) {
219 const std::vector<ResourceRequestBody::Element>* uploads = 219 const std::vector<ResourceRequestBody::Element>* uploads =
220 request_data.request_body->elements(); 220 request_data.request_body->elements();
221 std::vector<ResourceRequestBody::Element>::const_iterator iter; 221 std::vector<ResourceRequestBody::Element>::const_iterator iter;
222 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { 222 for (iter = uploads->begin(); iter != uploads->end(); ++iter) {
223 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE && 223 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE &&
224 !policy->CanReadFile(child_id, iter->path())) { 224 !policy->CanReadFile(child_id, iter->path())) {
225 NOTREACHED() << "Denied unauthorized upload of " 225 NOTREACHED() << "Denied unauthorized upload of "
226 << iter->path().value(); 226 << iter->path().value();
227 return false; 227 return false;
228 } 228 }
229 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) { 229 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) {
230 fileapi::FileSystemURL url = 230 storage::FileSystemURL url =
231 file_system_context->CrackURL(iter->filesystem_url()); 231 file_system_context->CrackURL(iter->filesystem_url());
232 if (!policy->CanReadFileSystemFile(child_id, url)) { 232 if (!policy->CanReadFileSystemFile(child_id, url)) {
233 NOTREACHED() << "Denied unauthorized upload of " 233 NOTREACHED() << "Denied unauthorized upload of "
234 << iter->filesystem_url().spec(); 234 << iter->filesystem_url().spec();
235 return false; 235 return false;
236 } 236 }
237 } 237 }
238 } 238 }
239 } 239 }
240 240
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (!web_contents) 292 if (!web_contents)
293 return; 293 return;
294 web_contents->DidGetResourceResponseStart(*details.get()); 294 web_contents->DidGetResourceResponseStart(*details.get());
295 } 295 }
296 296
297 bool IsValidatedSCT( 297 bool IsValidatedSCT(
298 const net::SignedCertificateTimestampAndStatus& sct_status) { 298 const net::SignedCertificateTimestampAndStatus& sct_status) {
299 return sct_status.status == net::ct::SCT_STATUS_OK; 299 return sct_status.status == net::ct::SCT_STATUS_OK;
300 } 300 }
301 301
302 webkit_blob::BlobStorageContext* GetBlobStorageContext( 302 storage::BlobStorageContext* GetBlobStorageContext(
303 ResourceMessageFilter* filter) { 303 ResourceMessageFilter* filter) {
304 if (!filter->blob_storage_context()) 304 if (!filter->blob_storage_context())
305 return NULL; 305 return NULL;
306 return filter->blob_storage_context()->context(); 306 return filter->blob_storage_context()->context();
307 } 307 }
308 308
309 } // namespace 309 } // namespace
310 310
311 // static 311 // static
312 ResourceDispatcherHost* ResourceDispatcherHost::Get() { 312 ResourceDispatcherHost* ResourceDispatcherHost::Get() {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST); 536 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST);
537 } 537 }
538 538
539 ResourceRequestInfoImpl* extra_info = 539 ResourceRequestInfoImpl* extra_info =
540 CreateRequestInfo(child_id, route_id, true, context); 540 CreateRequestInfo(child_id, route_id, true, context);
541 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 541 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
542 542
543 if (request->url().SchemeIs(url::kBlobScheme)) { 543 if (request->url().SchemeIs(url::kBlobScheme)) {
544 ChromeBlobStorageContext* blob_context = 544 ChromeBlobStorageContext* blob_context =
545 GetChromeBlobStorageContextForResourceContext(context); 545 GetChromeBlobStorageContextForResourceContext(context);
546 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( 546 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
547 request.get(), 547 request.get(),
548 blob_context->context()->GetBlobDataFromPublicURL(request->url())); 548 blob_context->context()->GetBlobDataFromPublicURL(request->url()));
549 } 549 }
550 550
551 // From this point forward, the |DownloadResourceHandler| is responsible for 551 // From this point forward, the |DownloadResourceHandler| is responsible for
552 // |started_callback|. 552 // |started_callback|.
553 scoped_ptr<ResourceHandler> handler( 553 scoped_ptr<ResourceHandler> handler(
554 CreateResourceHandlerForDownload(request.get(), is_content_initiated, 554 CreateResourceHandlerForDownload(request.get(), is_content_initiated,
555 true, download_id, save_info.Pass(), 555 true, download_id, save_info.Pass(),
556 started_callback)); 556 started_callback));
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 request_data.visiblity_state, 1080 request_data.visiblity_state,
1081 resource_context, 1081 resource_context,
1082 filter_->GetWeakPtr(), 1082 filter_->GetWeakPtr(),
1083 !is_sync_load); 1083 !is_sync_load);
1084 // Request takes ownership. 1084 // Request takes ownership.
1085 extra_info->AssociateWithRequest(new_request.get()); 1085 extra_info->AssociateWithRequest(new_request.get());
1086 1086
1087 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1087 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1088 // Hang on to a reference to ensure the blob is not released prior 1088 // Hang on to a reference to ensure the blob is not released prior
1089 // to the job being started. 1089 // to the job being started.
1090 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( 1090 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1091 new_request.get(), 1091 new_request.get(),
1092 filter_->blob_storage_context()->context()-> 1092 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL(
1093 GetBlobDataFromPublicURL(new_request->url())); 1093 new_request->url()));
1094 } 1094 }
1095 1095
1096 // Initialize the service worker handler for the request. 1096 // Initialize the service worker handler for the request.
1097 ServiceWorkerRequestHandler::InitializeHandler( 1097 ServiceWorkerRequestHandler::InitializeHandler(
1098 new_request.get(), 1098 new_request.get(),
1099 filter_->service_worker_context(), 1099 filter_->service_worker_context(),
1100 GetBlobStorageContext(filter_), 1100 GetBlobStorageContext(filter_),
1101 child_id, 1101 child_id,
1102 request_data.service_worker_provider_id, 1102 request_data.service_worker_provider_id,
1103 request_data.resource_type); 1103 request_data.resource_type);
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 1981
1982 // Add a flag to selectively bypass the data reduction proxy if the resource 1982 // Add a flag to selectively bypass the data reduction proxy if the resource
1983 // type is not an image. 1983 // type is not an image.
1984 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 1984 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
1985 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 1985 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
1986 1986
1987 return load_flags; 1987 return load_flags;
1988 } 1988 }
1989 1989
1990 } // namespace content 1990 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698