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

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

Issue 51683002: [Net] Assert that URLRequests with LOAD_IGNORE_LIMITS have MAXIMUM_PRIORITY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // is no current mechanism to prompt the user for their consent for a 466 // is no current mechanism to prompt the user for their consent for a
467 // re-post. For GETs, try to retrieve data from the cache and skip 467 // re-post. For GETs, try to retrieve data from the cache and skip
468 // validating the entry if present. 468 // validating the entry if present.
469 if (request->get_upload() != NULL) 469 if (request->get_upload() != NULL)
470 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; 470 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE;
471 else 471 else
472 extra_load_flags |= net::LOAD_PREFERRING_CACHE; 472 extra_load_flags |= net::LOAD_PREFERRING_CACHE;
473 } else { 473 } else {
474 extra_load_flags |= net::LOAD_DISABLE_CACHE; 474 extra_load_flags |= net::LOAD_DISABLE_CACHE;
475 } 475 }
476 request->set_load_flags(request->load_flags() | extra_load_flags); 476 request->SetLoadFlags(request->load_flags() | extra_load_flags);
477 477
478 // No need to get offline load flags for downloads, but make sure 478 // No need to get offline load flags for downloads, but make sure
479 // we have an OfflinePolicy to receive request completions. 479 // we have an OfflinePolicy to receive request completions.
480 GlobalRoutingID id(child_id, route_id); 480 GlobalRoutingID id(child_id, route_id);
481 if (!offline_policy_map_[id]) 481 if (!offline_policy_map_[id])
482 offline_policy_map_[id] = new OfflinePolicy(); 482 offline_policy_map_[id] = new OfflinePolicy();
483 483
484 // Check if the renderer is permitted to request the requested URL. 484 // Check if the renderer is permitted to request the requested URL.
485 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> 485 if (!ChildProcessSecurityPolicyImpl::GetInstance()->
486 CanRequestURL(child_id, url)) { 486 CanRequestURL(child_id, url)) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 request = new_request.get(); 1031 request = new_request.get();
1032 1032
1033 request->set_method(request_data.method); 1033 request->set_method(request_data.method);
1034 request->set_first_party_for_cookies(request_data.first_party_for_cookies); 1034 request->set_first_party_for_cookies(request_data.first_party_for_cookies);
1035 SetReferrerForRequest(request, referrer); 1035 SetReferrerForRequest(request, referrer);
1036 1036
1037 net::HttpRequestHeaders headers; 1037 net::HttpRequestHeaders headers;
1038 headers.AddHeadersFromString(request_data.headers); 1038 headers.AddHeadersFromString(request_data.headers);
1039 request->SetExtraRequestHeaders(headers); 1039 request->SetExtraRequestHeaders(headers);
1040 1040
1041 request->set_load_flags(load_flags); 1041 request->SetLoadFlags(load_flags);
1042 request->SetPriority(request_data.priority); 1042 request->SetPriority(request_data.priority);
1043 1043
1044 // Resolve elements from request_body and prepare upload data. 1044 // Resolve elements from request_body and prepare upload data.
1045 if (request_data.request_body.get()) { 1045 if (request_data.request_body.get()) {
1046 webkit_blob::BlobStorageContext* blob_context = NULL; 1046 webkit_blob::BlobStorageContext* blob_context = NULL;
1047 if (filter_->blob_storage_context()) 1047 if (filter_->blob_storage_context())
1048 blob_context = filter_->blob_storage_context()->context(); 1048 blob_context = filter_->blob_storage_context()->context();
1049 request->set_upload(UploadDataStreamBuilder::Build( 1049 request->set_upload(UploadDataStreamBuilder::Build(
1050 request_data.request_body.get(), 1050 request_data.request_body.get(),
1051 blob_context, 1051 blob_context,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 return; 1275 return;
1276 } 1276 }
1277 1277
1278 scoped_ptr<net::URLRequest> request( 1278 scoped_ptr<net::URLRequest> request(
1279 request_context->CreateRequest(url, NULL)); 1279 request_context->CreateRequest(url, NULL));
1280 request->set_method("GET"); 1280 request->set_method("GET");
1281 SetReferrerForRequest(request.get(), referrer); 1281 SetReferrerForRequest(request.get(), referrer);
1282 1282
1283 // So far, for saving page, we need fetch content from cache, in the 1283 // So far, for saving page, we need fetch content from cache, in the
1284 // future, maybe we can use a configuration to configure this behavior. 1284 // future, maybe we can use a configuration to configure this behavior.
1285 request->set_load_flags(net::LOAD_PREFERRING_CACHE); 1285 request->SetLoadFlags(net::LOAD_PREFERRING_CACHE);
1286 1286
1287 // No need to get offline load flags for save files, but make sure 1287 // No need to get offline load flags for save files, but make sure
1288 // we have an OfflinePolicy to receive request completions. 1288 // we have an OfflinePolicy to receive request completions.
1289 GlobalRoutingID id(child_id, route_id); 1289 GlobalRoutingID id(child_id, route_id);
1290 if (!offline_policy_map_[id]) 1290 if (!offline_policy_map_[id])
1291 offline_policy_map_[id] = new OfflinePolicy(); 1291 offline_policy_map_[id] = new OfflinePolicy();
1292 1292
1293 // Since we're just saving some resources we need, disallow downloading. 1293 // Since we're just saving some resources we need, disallow downloading.
1294 ResourceRequestInfoImpl* extra_info = 1294 ResourceRequestInfoImpl* extra_info =
1295 CreateRequestInfo(child_id, route_id, false, context); 1295 CreateRequestInfo(child_id, route_id, false, context);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 1562
1563 void ResourceDispatcherHostImpl::BeginRequestInternal( 1563 void ResourceDispatcherHostImpl::BeginRequestInternal(
1564 scoped_ptr<net::URLRequest> request, 1564 scoped_ptr<net::URLRequest> request,
1565 scoped_ptr<ResourceHandler> handler) { 1565 scoped_ptr<ResourceHandler> handler) {
1566 DCHECK(!request->is_pending()); 1566 DCHECK(!request->is_pending());
1567 ResourceRequestInfoImpl* info = 1567 ResourceRequestInfoImpl* info =
1568 ResourceRequestInfoImpl::ForRequest(request.get()); 1568 ResourceRequestInfoImpl::ForRequest(request.get());
1569 1569
1570 if ((TimeTicks::Now() - last_user_gesture_time_) < 1570 if ((TimeTicks::Now() - last_user_gesture_time_) <
1571 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 1571 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
1572 request->set_load_flags( 1572 request->SetLoadFlags(
1573 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 1573 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
1574 } 1574 }
1575 1575
1576 // Add the memory estimate that starting this request will consume. 1576 // Add the memory estimate that starting this request will consume.
1577 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); 1577 info->set_memory_cost(CalculateApproximateMemoryCost(request.get()));
1578 1578
1579 // If enqueing/starting this request will exceed our per-process memory 1579 // If enqueing/starting this request will exceed our per-process memory
1580 // bound, abort it right away. 1580 // bound, abort it right away.
1581 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info); 1581 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info);
1582 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) { 1582 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 1912 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
1913 && !policy->CanReadRawCookies(child_id)) { 1913 && !policy->CanReadRawCookies(child_id)) {
1914 VLOG(1) << "Denied unauthorized request for raw headers"; 1914 VLOG(1) << "Denied unauthorized request for raw headers";
1915 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 1915 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
1916 } 1916 }
1917 1917
1918 return load_flags; 1918 return load_flags;
1919 } 1919 }
1920 1920
1921 } // namespace content 1921 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698