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

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

Issue 1569673002: [NOT FOR LANDING] Detailed loading traces Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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
« no previous file with comments | « content/browser/loader/resource_buffer.cc ('k') | content/browser/loader/resource_loader.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 // 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 <stddef.h> 9 #include <stddef.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 GetCertID(loader->request(), info->GetChildID()), 979 GetCertID(loader->request(), info->GetChildID()),
980 new_url)); 980 new_url));
981 BrowserThread::PostTask( 981 BrowserThread::PostTask(
982 BrowserThread::UI, FROM_HERE, 982 BrowserThread::UI, FROM_HERE,
983 base::Bind( 983 base::Bind(
984 &NotifyRedirectOnUI, 984 &NotifyRedirectOnUI,
985 render_process_id, render_frame_host, base::Passed(&detail))); 985 render_process_id, render_frame_host, base::Passed(&detail)));
986 } 986 }
987 987
988 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { 988 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
989 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::DidReceiveResponse");
990
989 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 991 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
990 net::URLRequest* request = loader->request(); 992 net::URLRequest* request = loader->request();
991 if (request->was_fetched_via_proxy() && 993 if (request->was_fetched_via_proxy() &&
992 request->was_fetched_via_spdy() && 994 request->was_fetched_via_spdy() &&
993 request->url().SchemeIs(url::kHttpScheme)) { 995 request->url().SchemeIs(url::kHttpScheme)) {
994 scheduler_->OnReceivedSpdyProxiedHttpResponse( 996 scheduler_->OnReceivedSpdyProxiedHttpResponse(
995 info->GetChildID(), info->GetRouteID()); 997 info->GetChildID(), info->GetRouteID());
996 } 998 }
997 999
998 if (request->response_info().async_revalidation_required) { 1000 if (request->response_info().async_revalidation_required) {
(...skipping 16 matching lines...) Expand all
1015 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( 1017 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails(
1016 request, GetCertID(request, info->GetChildID()))); 1018 request, GetCertID(request, info->GetChildID())));
1017 BrowserThread::PostTask( 1019 BrowserThread::PostTask(
1018 BrowserThread::UI, FROM_HERE, 1020 BrowserThread::UI, FROM_HERE,
1019 base::Bind( 1021 base::Bind(
1020 &NotifyResponseOnUI, 1022 &NotifyResponseOnUI,
1021 render_process_id, render_frame_host, base::Passed(&detail))); 1023 render_process_id, render_frame_host, base::Passed(&detail)));
1022 } 1024 }
1023 1025
1024 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) { 1026 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) {
1027 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::DidFinishLoading");
1025 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 1028 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
1026 1029
1027 // Record final result of all resource loads. 1030 // Record final result of all resource loads.
1028 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) { 1031 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) {
1029 // This enumeration has "3" appended to its name to distinguish it from 1032 // This enumeration has "3" appended to its name to distinguish it from
1030 // older versions. 1033 // older versions.
1031 UMA_HISTOGRAM_SPARSE_SLOWLY( 1034 UMA_HISTOGRAM_SPARSE_SLOWLY(
1032 "Net.ErrorCodesForMainFrame3", 1035 "Net.ErrorCodesForMainFrame3",
1033 -loader->request()->status().error()); 1036 -loader->request()->status().error());
1034 1037
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 UMA_HISTOGRAM_SPARSE_SLOWLY( 1129 UMA_HISTOGRAM_SPARSE_SLOWLY(
1127 "Net.ErrorCodesForSubresources2", 1130 "Net.ErrorCodesForSubresources2",
1128 -loader->request()->status().error()); 1131 -loader->request()->status().error());
1129 } 1132 }
1130 1133
1131 if (loader->request()->url().SchemeIsCryptographic()) { 1134 if (loader->request()->url().SchemeIsCryptographic()) {
1132 RecordCertificateHistograms(loader->request()->ssl_info(), 1135 RecordCertificateHistograms(loader->request()->ssl_info(),
1133 info->GetResourceType()); 1136 info->GetResourceType());
1134 } 1137 }
1135 1138
1136 if (delegate_) 1139 if (delegate_) {
1140 TRACE_EVENT0("toplevel", "ResourceDispatcherHostDelegate::RequestComplete");
1141
1137 delegate_->RequestComplete(loader->request()); 1142 delegate_->RequestComplete(loader->request());
1143 }
1138 1144
1139 // Destroy the ResourceLoader. 1145 // Destroy the ResourceLoader.
1140 RemovePendingRequest(info->GetChildID(), info->GetRequestID()); 1146 RemovePendingRequest(info->GetChildID(), info->GetRequestID());
1141 } 1147 }
1142 1148
1143 void ResourceDispatcherHostImpl::OnInit() { 1149 void ResourceDispatcherHostImpl::OnInit() {
1144 scheduler_.reset(new ResourceScheduler); 1150 scheduler_.reset(new ResourceScheduler);
1145 } 1151 }
1146 1152
1147 void ResourceDispatcherHostImpl::OnShutdown() { 1153 void ResourceDispatcherHostImpl::OnShutdown() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 } 1216 }
1211 1217
1212 filter_ = NULL; 1218 filter_ = NULL;
1213 return handled; 1219 return handled;
1214 } 1220 }
1215 1221
1216 void ResourceDispatcherHostImpl::OnRequestResource( 1222 void ResourceDispatcherHostImpl::OnRequestResource(
1217 int routing_id, 1223 int routing_id,
1218 int request_id, 1224 int request_id,
1219 const ResourceHostMsg_Request& request_data) { 1225 const ResourceHostMsg_Request& request_data) {
1226 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::OnRequestResource");
1227
1220 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1228 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1221 tracked_objects::ScopedTracker tracking_profile( 1229 tracked_objects::ScopedTracker tracking_profile(
1222 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1230 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1223 "477117 ResourceDispatcherHostImpl::OnRequestResource")); 1231 "477117 ResourceDispatcherHostImpl::OnRequestResource"));
1224 // When logging time-to-network only care about main frame and non-transfer 1232 // When logging time-to-network only care about main frame and non-transfer
1225 // navigations. 1233 // navigations.
1226 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted 1234 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted
1227 // instead. 1235 // instead.
1228 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && 1236 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME &&
1229 request_data.transferred_request_request_id == -1 && 1237 request_data.transferred_request_request_id == -1 &&
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1362
1355 // We should have a CrossSiteResourceHandler to finish the transfer. 1363 // We should have a CrossSiteResourceHandler to finish the transfer.
1356 DCHECK(info->cross_site_handler()); 1364 DCHECK(info->cross_site_handler());
1357 } 1365 }
1358 1366
1359 void ResourceDispatcherHostImpl::BeginRequest( 1367 void ResourceDispatcherHostImpl::BeginRequest(
1360 int request_id, 1368 int request_id,
1361 const ResourceHostMsg_Request& request_data, 1369 const ResourceHostMsg_Request& request_data,
1362 IPC::Message* sync_result, // only valid for sync 1370 IPC::Message* sync_result, // only valid for sync
1363 int route_id) { 1371 int route_id) {
1372 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::BeginRequest");
1364 int process_type = filter_->process_type(); 1373 int process_type = filter_->process_type();
1365 int child_id = filter_->child_id(); 1374 int child_id = filter_->child_id();
1366 1375
1367 // Reject request id that's currently in use. 1376 // Reject request id that's currently in use.
1368 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { 1377 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1369 bad_message::ReceivedBadMessage(filter_, 1378 bad_message::ReceivedBadMessage(filter_,
1370 bad_message::RDH_INVALID_REQUEST_ID); 1379 bad_message::RDH_INVALID_REQUEST_ID);
1371 return; 1380 return;
1372 } 1381 }
1373 1382
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 headers.AddHeadersFromString(request_data.headers); 1436 headers.AddHeadersFromString(request_data.headers);
1428 1437
1429 if (is_shutdown_ || 1438 if (is_shutdown_ ||
1430 !ShouldServiceRequest(process_type, child_id, request_data, headers, 1439 !ShouldServiceRequest(process_type, child_id, request_data, headers,
1431 filter_, resource_context)) { 1440 filter_, resource_context)) {
1432 AbortRequestBeforeItStarts(filter_, sync_result, request_id); 1441 AbortRequestBeforeItStarts(filter_, sync_result, request_id);
1433 return; 1442 return;
1434 } 1443 }
1435 1444
1436 // Allow the observer to block/handle the request. 1445 // Allow the observer to block/handle the request.
1437 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, 1446 {
1438 request_data.url, 1447 TRACE_EVENT0("toplevel",
1439 request_data.resource_type, 1448 "ResourceDispatcherHostDelegate::ShouldBeginRequest");
1440 resource_context)) { 1449
1441 AbortRequestBeforeItStarts(filter_, sync_result, request_id); 1450 if (delegate_ &&
1442 return; 1451 !delegate_->ShouldBeginRequest(request_data.method, request_data.url,
1452 request_data.resource_type,
1453 resource_context)) {
1454 AbortRequestBeforeItStarts(filter_, sync_result, request_id);
1455 return;
1456 }
1443 } 1457 }
1444
1445 // Construct the request.
1446 scoped_ptr<net::URLRequest> new_request = request_context->CreateRequest( 1458 scoped_ptr<net::URLRequest> new_request = request_context->CreateRequest(
1447 is_navigation_stream_request ? request_data.resource_body_stream_url 1459 is_navigation_stream_request ? request_data.resource_body_stream_url
1448 : request_data.url, 1460 : request_data.url,
1449 request_data.priority, nullptr); 1461 request_data.priority, nullptr);
1450 1462
1451 // PlzNavigate: Always set the method to GET when gaining access to the 1463 // PlzNavigate: Always set the method to GET when gaining access to the
1452 // stream that contains the response body of a navigation. Otherwise the data 1464 // stream that contains the response body of a navigation. Otherwise the data
1453 // that was already fetched by the browser will not be transmitted to the 1465 // that was already fetched by the browser will not be transmitted to the
1454 // renderer. 1466 // renderer.
1455 if (is_navigation_stream_request) 1467 if (is_navigation_stream_request)
(...skipping 15 matching lines...) Expand all
1471 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { 1483 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) {
1472 new_request->set_first_party_url_policy( 1484 new_request->set_first_party_url_policy(
1473 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); 1485 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1474 } 1486 }
1475 1487
1476 const Referrer referrer(request_data.referrer, request_data.referrer_policy); 1488 const Referrer referrer(request_data.referrer, request_data.referrer_policy);
1477 SetReferrerForRequest(new_request.get(), referrer); 1489 SetReferrerForRequest(new_request.get(), referrer);
1478 1490
1479 new_request->SetExtraRequestHeaders(headers); 1491 new_request->SetExtraRequestHeaders(headers);
1480 1492
1481 storage::BlobStorageContext* blob_context = 1493 storage::BlobStorageContext* blob_context;
1482 GetBlobStorageContext(filter_->blob_storage_context()); 1494 {
1495 TRACE_EVENT0("toplevel", "GetBlobStorageContext");
1496 blob_context = GetBlobStorageContext(filter_->blob_storage_context());
1497 }
1483 // Resolve elements from request_body and prepare upload data. 1498 // Resolve elements from request_body and prepare upload data.
1484 if (request_data.request_body.get()) { 1499 if (request_data.request_body.get()) {
1485 // |blob_context| could be null when the request is from the plugins because 1500 // |blob_context| could be null when the request is from the plugins because
1486 // ResourceMessageFilters created in PluginProcessHost don't have the blob 1501 // ResourceMessageFilters created in PluginProcessHost don't have the blob
1487 // context. 1502 // context.
1488 if (blob_context) { 1503 if (blob_context) {
1489 // Attaches the BlobDataHandles to request_body not to free the blobs and 1504 // Attaches the BlobDataHandles to request_body not to free the blobs and
1490 // any attached shareable files until upload completion. These data will 1505 // any attached shareable files until upload completion. These data will
1491 // be used in UploadDataStream and ServiceWorkerURLRequestJob. 1506 // be used in UploadDataStream and ServiceWorkerURLRequestJob.
1507 TRACE_EVENT0("toplevel",
1508 "ResourceDispatcherHostImpl::BeginRequest::"
1509 "AttachRequestBodyBlobDataHandles");
1492 AttachRequestBodyBlobDataHandles( 1510 AttachRequestBodyBlobDataHandles(
1493 request_data.request_body.get(), 1511 request_data.request_body.get(),
1494 blob_context); 1512 blob_context);
1495 } 1513 }
1496 new_request->set_upload(UploadDataStreamBuilder::Build( 1514 new_request->set_upload(UploadDataStreamBuilder::Build(
1497 request_data.request_body.get(), 1515 request_data.request_body.get(),
1498 blob_context, 1516 blob_context,
1499 filter_->file_system_context(), 1517 filter_->file_system_context(),
1500 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) 1518 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1501 .get())); 1519 .get()));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 } 1646 }
1629 1647
1630 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1648 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1631 net::URLRequest* request, 1649 net::URLRequest* request,
1632 const ResourceHostMsg_Request& request_data, 1650 const ResourceHostMsg_Request& request_data,
1633 IPC::Message* sync_result, 1651 IPC::Message* sync_result,
1634 int route_id, 1652 int route_id,
1635 int process_type, 1653 int process_type,
1636 int child_id, 1654 int child_id,
1637 ResourceContext* resource_context) { 1655 ResourceContext* resource_context) {
1656 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::CreateResourceHandler");
1657
1638 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1658 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1639 tracked_objects::ScopedTracker tracking_profile( 1659 tracked_objects::ScopedTracker tracking_profile(
1640 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1660 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1641 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1661 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1642 // Construct the IPC resource handler. 1662 // Construct the IPC resource handler.
1643 scoped_ptr<ResourceHandler> handler; 1663 scoped_ptr<ResourceHandler> handler;
1644 if (sync_result) { 1664 if (sync_result) {
1645 // download_to_file is not supported for synchronous requests. 1665 // download_to_file is not supported for synchronous requests.
1646 if (request_data.download_to_file) { 1666 if (request_data.download_to_file) {
1647 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); 1667 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 } 1715 }
1696 1716
1697 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers( 1717 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers(
1698 net::URLRequest* request, 1718 net::URLRequest* request,
1699 ResourceType resource_type, 1719 ResourceType resource_type,
1700 ResourceContext* resource_context, 1720 ResourceContext* resource_context,
1701 AppCacheService* appcache_service, 1721 AppCacheService* appcache_service,
1702 int child_id, 1722 int child_id,
1703 int route_id, 1723 int route_id,
1704 scoped_ptr<ResourceHandler> handler) { 1724 scoped_ptr<ResourceHandler> handler) {
1725 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::AddStandardHandlers");
1705 // PlzNavigate: do not add ResourceThrottles for main resource requests from 1726 // PlzNavigate: do not add ResourceThrottles for main resource requests from
1706 // the renderer. Decisions about the navigation should have been done in the 1727 // the renderer. Decisions about the navigation should have been done in the
1707 // initial request. 1728 // initial request.
1708 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) && 1729 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) &&
1709 child_id != -1) { 1730 child_id != -1) {
1710 DCHECK(request->url().SchemeIs(url::kBlobScheme)); 1731 DCHECK(request->url().SchemeIs(url::kBlobScheme));
1711 return handler; 1732 return handler;
1712 } 1733 }
1713 1734
1714 PluginService* plugin_service = nullptr; 1735 PluginService* plugin_service = nullptr;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 } 2073 }
2053 for (const GlobalFrameRoutingId& route_id : routing_ids) { 2074 for (const GlobalFrameRoutingId& route_id : routing_ids) {
2054 CancelBlockedRequestsForRoute(route_id); 2075 CancelBlockedRequestsForRoute(route_id);
2055 } 2076 }
2056 } 2077 }
2057 } 2078 }
2058 2079
2059 // Cancels the request and removes it from the list. 2080 // Cancels the request and removes it from the list.
2060 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, 2081 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id,
2061 int request_id) { 2082 int request_id) {
2083 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::RemovePendingRequest");
2084
2062 LoaderMap::iterator i = pending_loaders_.find( 2085 LoaderMap::iterator i = pending_loaders_.find(
2063 GlobalRequestID(child_id, request_id)); 2086 GlobalRequestID(child_id, request_id));
2064 if (i == pending_loaders_.end()) { 2087 if (i == pending_loaders_.end()) {
2065 NOTREACHED() << "Trying to remove a request that's not here"; 2088 NOTREACHED() << "Trying to remove a request that's not here";
2066 return; 2089 return;
2067 } 2090 }
2068 RemovePendingLoader(i); 2091 RemovePendingLoader(i);
2069 } 2092 }
2070 2093
2071 void ResourceDispatcherHostImpl::RemovePendingLoader( 2094 void ResourceDispatcherHostImpl::RemovePendingLoader(
2072 const LoaderMap::iterator& iter) { 2095 const LoaderMap::iterator& iter) {
2096 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::RemovePendingLoader");
2097
2073 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); 2098 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo();
2074 2099
2075 // Remove the memory credit that we added when pushing the request onto 2100 // Remove the memory credit that we added when pushing the request onto
2076 // the pending list. 2101 // the pending list.
2077 IncrementOutstandingRequestsMemory(-1, *info); 2102 IncrementOutstandingRequestsMemory(-1, *info);
2078 2103 {
2079 pending_loaders_.erase(iter); 2104 TRACE_EVENT0("toplevel",
2105 "ResourceDispatcherHostImpl::RemovePendingLoader::Erase");
2106 pending_loaders_.erase(iter);
2107 }
2080 } 2108 }
2081 2109
2082 void ResourceDispatcherHostImpl::CancelRequest(int child_id, 2110 void ResourceDispatcherHostImpl::CancelRequest(int child_id,
2083 int request_id) { 2111 int request_id) {
2084 ResourceLoader* loader = GetLoader(child_id, request_id); 2112 ResourceLoader* loader = GetLoader(child_id, request_id);
2085 if (!loader) { 2113 if (!loader) {
2086 // We probably want to remove this warning eventually, but I wanted to be 2114 // We probably want to remove this warning eventually, but I wanted to be
2087 // able to notice when this happens during initial development since it 2115 // able to notice when this happens during initial development since it
2088 // should be rare and may indicate a bug. 2116 // should be rare and may indicate a bug.
2089 DVLOG(1) << "Canceling a request that wasn't found"; 2117 DVLOG(1) << "Canceling a request that wasn't found";
(...skipping 20 matching lines...) Expand all
2110 if (stats.memory_cost == 0 && stats.num_requests == 0) 2138 if (stats.memory_cost == 0 && stats.num_requests == 0)
2111 outstanding_requests_stats_map_.erase(info.GetChildID()); 2139 outstanding_requests_stats_map_.erase(info.GetChildID());
2112 else 2140 else
2113 outstanding_requests_stats_map_[info.GetChildID()] = stats; 2141 outstanding_requests_stats_map_[info.GetChildID()] = stats;
2114 } 2142 }
2115 2143
2116 ResourceDispatcherHostImpl::OustandingRequestsStats 2144 ResourceDispatcherHostImpl::OustandingRequestsStats
2117 ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemory( 2145 ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemory(
2118 int count, 2146 int count,
2119 const ResourceRequestInfoImpl& info) { 2147 const ResourceRequestInfoImpl& info) {
2148 TRACE_EVENT0(
2149 "toplevel",
2150 "ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemory");
2151
2120 DCHECK_EQ(1, abs(count)); 2152 DCHECK_EQ(1, abs(count));
2121 2153
2122 // Retrieve the previous value (defaulting to 0 if not found). 2154 // Retrieve the previous value (defaulting to 0 if not found).
2123 OustandingRequestsStats stats = GetOutstandingRequestsStats(info); 2155 OustandingRequestsStats stats = GetOutstandingRequestsStats(info);
2124 2156
2125 // Insert/update the total; delete entries when their count reaches 0. 2157 // Insert/update the total; delete entries when their count reaches 0.
2126 stats.memory_cost += count * info.memory_cost(); 2158 stats.memory_cost += count * info.memory_cost();
2127 DCHECK_GE(stats.memory_cost, 0); 2159 DCHECK_GE(stats.memory_cost, 0);
2128 UpdateOutstandingRequestsStats(info, stats); 2160 UpdateOutstandingRequestsStats(info, stats);
2129 2161
(...skipping 16 matching lines...) Expand all
2146 OustandingRequestsStats stats = GetOutstandingRequestsStats(*info); 2178 OustandingRequestsStats stats = GetOutstandingRequestsStats(*info);
2147 stats.num_requests += count; 2179 stats.num_requests += count;
2148 DCHECK_GE(stats.num_requests, 0); 2180 DCHECK_GE(stats.num_requests, 0);
2149 UpdateOutstandingRequestsStats(*info, stats); 2181 UpdateOutstandingRequestsStats(*info, stats);
2150 2182
2151 return stats; 2183 return stats;
2152 } 2184 }
2153 2185
2154 bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest( 2186 bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest(
2155 net::URLRequest* request) { 2187 net::URLRequest* request) {
2188 TRACE_EVENT0("toplevel",
2189 "ResourceDispatcherHostImpl::HasSufficientResourcesForRequest");
2190
2156 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 2191 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
2157 OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, info); 2192 OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, info);
2158 2193
2159 if (stats.num_requests > max_num_in_flight_requests_per_process_) 2194 if (stats.num_requests > max_num_in_flight_requests_per_process_)
2160 return false; 2195 return false;
2161 if (num_in_flight_requests_ > max_num_in_flight_requests_) 2196 if (num_in_flight_requests_ > max_num_in_flight_requests_)
2162 return false; 2197 return false;
2163 2198
2164 return true; 2199 return true;
2165 } 2200 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 request->method().size(); 2388 request->method().size();
2354 2389
2355 // Note that this expression will typically be dominated by: 2390 // Note that this expression will typically be dominated by:
2356 // |kAvgBytesPerOutstandingRequest|. 2391 // |kAvgBytesPerOutstandingRequest|.
2357 return kAvgBytesPerOutstandingRequest + strings_cost; 2392 return kAvgBytesPerOutstandingRequest + strings_cost;
2358 } 2393 }
2359 2394
2360 void ResourceDispatcherHostImpl::BeginRequestInternal( 2395 void ResourceDispatcherHostImpl::BeginRequestInternal(
2361 scoped_ptr<net::URLRequest> request, 2396 scoped_ptr<net::URLRequest> request,
2362 scoped_ptr<ResourceHandler> handler) { 2397 scoped_ptr<ResourceHandler> handler) {
2398 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::BeginRequestInternal");
2363 DCHECK(!request->is_pending()); 2399 DCHECK(!request->is_pending());
2364 ResourceRequestInfoImpl* info = 2400 ResourceRequestInfoImpl* info =
2365 ResourceRequestInfoImpl::ForRequest(request.get()); 2401 ResourceRequestInfoImpl::ForRequest(request.get());
2366 2402
2367 if ((TimeTicks::Now() - last_user_gesture_time_) < 2403 if ((TimeTicks::Now() - last_user_gesture_time_) <
2368 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 2404 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
2369 request->SetLoadFlags( 2405 request->SetLoadFlags(
2370 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 2406 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
2371 } 2407 }
2372 2408
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 iter->second->push_back(std::move(loader)); 2441 iter->second->push_back(std::move(loader));
2406 return; 2442 return;
2407 } 2443 }
2408 2444
2409 StartLoading(info, std::move(loader)); 2445 StartLoading(info, std::move(loader));
2410 } 2446 }
2411 2447
2412 void ResourceDispatcherHostImpl::StartLoading( 2448 void ResourceDispatcherHostImpl::StartLoading(
2413 ResourceRequestInfoImpl* info, 2449 ResourceRequestInfoImpl* info,
2414 scoped_ptr<ResourceLoader> loader) { 2450 scoped_ptr<ResourceLoader> loader) {
2451 TRACE_EVENT0("toplevel", "ResourceDispatcherHostImpl::StartLoading");
2415 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 2452 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
2416 tracked_objects::ScopedTracker tracking_profile( 2453 tracked_objects::ScopedTracker tracking_profile(
2417 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2454 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2418 "456331 ResourceDispatcherHostImpl::StartLoading")); 2455 "456331 ResourceDispatcherHostImpl::StartLoading"));
2419 2456
2420 ResourceLoader* loader_ptr = loader.get(); 2457 ResourceLoader* loader_ptr = loader.get();
2421 pending_loaders_[info->GetGlobalRequestID()] = std::move(loader); 2458 pending_loaders_[info->GetGlobalRequestID()] = std::move(loader);
2422 2459
2423 loader_ptr->StartRequest(); 2460 loader_ptr->StartRequest();
2424 } 2461 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 if (!it->second->might_have_observers()) { 2672 if (!it->second->might_have_observers()) {
2636 delete it->second; 2673 delete it->second;
2637 delegate_map_.erase(it); 2674 delegate_map_.erase(it);
2638 } 2675 }
2639 } 2676 }
2640 2677
2641 int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest( 2678 int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest(
2642 const ResourceHostMsg_Request& request_data, 2679 const ResourceHostMsg_Request& request_data,
2643 int child_id, 2680 int child_id,
2644 bool is_sync_load) { 2681 bool is_sync_load) {
2682 TRACE_EVENT0(
2683 "toplevel",
2684 "ResourceDispatcherHostImpl::BeginRequest::BuildLoadFlagsForRequest");
2645 int load_flags = request_data.load_flags; 2685 int load_flags = request_data.load_flags;
2646 2686
2647 // Although EV status is irrelevant to sub-frames and sub-resources, we have 2687 // Although EV status is irrelevant to sub-frames and sub-resources, we have
2648 // to perform EV certificate verification on all resources because an HTTP 2688 // to perform EV certificate verification on all resources because an HTTP
2649 // keep-alive connection created to load a sub-frame or a sub-resource could 2689 // keep-alive connection created to load a sub-frame or a sub-resource could
2650 // be reused to load a main frame. 2690 // be reused to load a main frame.
2651 load_flags |= net::LOAD_VERIFY_EV_CERT; 2691 load_flags |= net::LOAD_VERIFY_EV_CERT;
2652 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { 2692 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) {
2653 load_flags |= net::LOAD_MAIN_FRAME; 2693 load_flags |= net::LOAD_MAIN_FRAME;
2654 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) { 2694 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) {
2655 load_flags |= net::LOAD_PREFETCH; 2695 load_flags |= net::LOAD_PREFETCH;
2656 } 2696 }
2657 2697
2658 if (is_sync_load) 2698 if (is_sync_load)
2659 load_flags |= net::LOAD_IGNORE_LIMITS; 2699 load_flags |= net::LOAD_IGNORE_LIMITS;
2660 2700
2661 return load_flags; 2701 return load_flags;
2662 } 2702 }
2663 2703
2664 } // namespace content 2704 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_buffer.cc ('k') | content/browser/loader/resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698