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

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

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 10
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // navigation becomes the default. crbug.com/561610 577 // navigation becomes the default. crbug.com/561610
578 if (!IsBrowserSideNavigationEnabled() && 578 if (!IsBrowserSideNavigationEnabled() &&
579 base::FeatureList::IsEnabled(features::kStaleWhileRevalidate)) { 579 base::FeatureList::IsEnabled(features::kStaleWhileRevalidate)) {
580 async_revalidation_manager_.reset(new AsyncRevalidationManager); 580 async_revalidation_manager_.reset(new AsyncRevalidationManager);
581 } 581 }
582 } 582 }
583 583
584 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { 584 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() {
585 DCHECK(outstanding_requests_stats_map_.empty()); 585 DCHECK(outstanding_requests_stats_map_.empty());
586 DCHECK(g_resource_dispatcher_host); 586 DCHECK(g_resource_dispatcher_host);
587 DCHECK_CURRENTLY_ON(BrowserThread::UI);
587 g_resource_dispatcher_host = NULL; 588 g_resource_dispatcher_host = NULL;
588 } 589 }
589 590
590 // static 591 // static
591 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { 592 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
592 return g_resource_dispatcher_host; 593 return g_resource_dispatcher_host;
593 } 594 }
594 595
595 // static 596 // static
596 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRouteFromUI( 597 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRouteFromUI(
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 for (const auto& routing_id : ids) { 1171 for (const auto& routing_id : ids) {
1171 CancelBlockedRequestsForRoute(routing_id); 1172 CancelBlockedRequestsForRoute(routing_id);
1172 } 1173 }
1173 1174
1174 scheduler_.reset(); 1175 scheduler_.reset();
1175 } 1176 }
1176 1177
1177 bool ResourceDispatcherHostImpl::OnMessageReceived( 1178 bool ResourceDispatcherHostImpl::OnMessageReceived(
1178 const IPC::Message& message, 1179 const IPC::Message& message,
1179 ResourceMessageFilter* filter) { 1180 ResourceMessageFilter* filter) {
1181 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1180 filter_ = filter; 1182 filter_ = filter;
1181 bool handled = true; 1183 bool handled = true;
1182 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message) 1184 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message)
1183 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) 1185 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource)
1184 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) 1186 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad)
1185 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, 1187 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile,
1186 OnReleaseDownloadedFile) 1188 OnReleaseDownloadedFile)
1187 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) 1189 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK)
1188 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) 1190 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest)
1189 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) 1191 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority)
(...skipping 21 matching lines...) Expand all
1211 } 1213 }
1212 1214
1213 filter_ = NULL; 1215 filter_ = NULL;
1214 return handled; 1216 return handled;
1215 } 1217 }
1216 1218
1217 void ResourceDispatcherHostImpl::OnRequestResource( 1219 void ResourceDispatcherHostImpl::OnRequestResource(
1218 int routing_id, 1220 int routing_id,
1219 int request_id, 1221 int request_id,
1220 const ResourceRequest& request_data) { 1222 const ResourceRequest& request_data) {
1223 std::unique_ptr<mojom::URLLoader> loader =
1224 std::move(mojo_loader_for_next_load_request_);
1225 mojom::URLLoaderClientPtr client =
1226 std::move(mojo_loader_client_for_next_load_request_);
1227
1221 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1228 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1222 tracked_objects::ScopedTracker tracking_profile( 1229 tracked_objects::ScopedTracker tracking_profile(
1223 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1230 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1224 "477117 ResourceDispatcherHostImpl::OnRequestResource")); 1231 "477117 ResourceDispatcherHostImpl::OnRequestResource"));
1225 // 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
1226 // navigations. 1233 // navigations.
1227 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted 1234 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted
1228 // instead. 1235 // instead.
1229 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && 1236 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME &&
1230 request_data.transferred_request_request_id == -1 && 1237 request_data.transferred_request_request_id == -1 &&
1231 !IsBrowserSideNavigationEnabled()) { 1238 !IsBrowserSideNavigationEnabled()) {
1232 BrowserThread::PostTask( 1239 BrowserThread::PostTask(
1233 BrowserThread::UI, 1240 BrowserThread::UI,
1234 FROM_HERE, 1241 FROM_HERE,
1235 base::Bind(&LogResourceRequestTimeOnUI, 1242 base::Bind(&LogResourceRequestTimeOnUI,
1236 TimeTicks::Now(), 1243 TimeTicks::Now(),
1237 filter_->child_id(), 1244 filter_->child_id(),
1238 request_data.render_frame_id, 1245 request_data.render_frame_id,
1239 request_data.url)); 1246 request_data.url));
1240 } 1247 }
1241 BeginRequest(request_id, request_data, NULL, routing_id); 1248 BeginRequest(request_id, request_data, NULL, routing_id, std::move(loader),
1249 std::move(client));
1242 } 1250 }
1243 1251
1244 // Begins a resource request with the given params on behalf of the specified 1252 // Begins a resource request with the given params on behalf of the specified
1245 // child process. Responses will be dispatched through the given receiver. The 1253 // child process. Responses will be dispatched through the given receiver. The
1246 // process ID is used to lookup WebContentsImpl from routing_id's in the case of 1254 // process ID is used to lookup WebContentsImpl from routing_id's in the case of
1247 // a request from a renderer. request_context is the cookie/cache context to be 1255 // a request from a renderer. request_context is the cookie/cache context to be
1248 // used for this request. 1256 // used for this request.
1249 // 1257 //
1250 // If sync_result is non-null, then a SyncLoad reply will be generated, else 1258 // If sync_result is non-null, then a SyncLoad reply will be generated, else
1251 // a normal asynchronous set of response messages will be generated. 1259 // a normal asynchronous set of response messages will be generated.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 } 1369 }
1362 1370
1363 // We should have a CrossSiteResourceHandler to finish the transfer. 1371 // We should have a CrossSiteResourceHandler to finish the transfer.
1364 DCHECK(info->cross_site_handler()); 1372 DCHECK(info->cross_site_handler());
1365 } 1373 }
1366 1374
1367 void ResourceDispatcherHostImpl::BeginRequest( 1375 void ResourceDispatcherHostImpl::BeginRequest(
1368 int request_id, 1376 int request_id,
1369 const ResourceRequest& request_data, 1377 const ResourceRequest& request_data,
1370 IPC::Message* sync_result, // only valid for sync 1378 IPC::Message* sync_result, // only valid for sync
1371 int route_id) { 1379 int route_id,
1380 std::unique_ptr<mojom::URLLoader> url_loader,
1381 mojom::URLLoaderClientPtr client) {
1372 int process_type = filter_->process_type(); 1382 int process_type = filter_->process_type();
1373 int child_id = filter_->child_id(); 1383 int child_id = filter_->child_id();
1374 1384
1375 // Reject request id that's currently in use. 1385 // Reject request id that's currently in use.
1376 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { 1386 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1377 bad_message::ReceivedBadMessage(filter_, 1387 bad_message::ReceivedBadMessage(filter_,
1378 bad_message::RDH_INVALID_REQUEST_ID); 1388 bad_message::RDH_INVALID_REQUEST_ID);
1379 return; 1389 return;
1380 } 1390 }
1381 1391
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1630 }
1621 1631
1622 // Have the appcache associate its extra info with the request. 1632 // Have the appcache associate its extra info with the request.
1623 AppCacheInterceptor::SetExtraRequestInfo( 1633 AppCacheInterceptor::SetExtraRequestInfo(
1624 new_request.get(), filter_->appcache_service(), child_id, 1634 new_request.get(), filter_->appcache_service(), child_id,
1625 request_data.appcache_host_id, request_data.resource_type, 1635 request_data.appcache_host_id, request_data.resource_type,
1626 request_data.should_reset_appcache); 1636 request_data.should_reset_appcache);
1627 1637
1628 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( 1638 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler(
1629 new_request.get(), request_data, sync_result, route_id, process_type, 1639 new_request.get(), request_data, sync_result, route_id, process_type,
1630 child_id, resource_context)); 1640 child_id, resource_context, client != nullptr));
1631 1641
1632 if (handler) 1642 if (handler)
1633 BeginRequestInternal(std::move(new_request), std::move(handler)); 1643 BeginRequestInternal(std::move(new_request), std::move(handler),
1644 std::move(url_loader), std::move(client));
1634 } 1645 }
1635 1646
1636 std::unique_ptr<ResourceHandler> 1647 std::unique_ptr<ResourceHandler>
1637 ResourceDispatcherHostImpl::CreateResourceHandler( 1648 ResourceDispatcherHostImpl::CreateResourceHandler(
1638 net::URLRequest* request, 1649 net::URLRequest* request,
1639 const ResourceRequest& request_data, 1650 const ResourceRequest& request_data,
1640 IPC::Message* sync_result, 1651 IPC::Message* sync_result,
1641 int route_id, 1652 int route_id,
1642 int process_type, 1653 int process_type,
1643 int child_id, 1654 int child_id,
1644 ResourceContext* resource_context) { 1655 ResourceContext* resource_context,
1656 bool using_mojo) {
1645 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1657 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1646 tracked_objects::ScopedTracker tracking_profile( 1658 tracked_objects::ScopedTracker tracking_profile(
1647 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1659 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1648 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1660 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1649 // Construct the IPC resource handler. 1661 // Construct the IPC resource handler.
1650 std::unique_ptr<ResourceHandler> handler; 1662 std::unique_ptr<ResourceHandler> handler;
1651 if (sync_result) { 1663 if (sync_result) {
1664 DCHECK(!using_mojo);
1652 // download_to_file is not supported for synchronous requests. 1665 // download_to_file is not supported for synchronous requests.
1653 if (request_data.download_to_file) { 1666 if (request_data.download_to_file) {
1654 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); 1667 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD);
1655 return std::unique_ptr<ResourceHandler>(); 1668 return std::unique_ptr<ResourceHandler>();
1656 } 1669 }
1657 1670
1658 handler.reset(new SyncResourceHandler(request, sync_result, this)); 1671 handler.reset(new SyncResourceHandler(request, sync_result, this));
1659 } else { 1672 } else {
1660 handler.reset(new AsyncResourceHandler(request, this)); 1673 handler.reset(new AsyncResourceHandler(request, this, using_mojo));
1661 1674
1662 // The RedirectToFileResourceHandler depends on being next in the chain. 1675 // The RedirectToFileResourceHandler depends on being next in the chain.
1663 if (request_data.download_to_file) { 1676 if (request_data.download_to_file) {
1664 handler.reset( 1677 handler.reset(
1665 new RedirectToFileResourceHandler(std::move(handler), request)); 1678 new RedirectToFileResourceHandler(std::move(handler), request));
1666 } 1679 }
1667 } 1680 }
1668 1681
1669 // Prefetches and <a ping> requests outlive their child process. 1682 // Prefetches and <a ping> requests outlive their child process.
1670 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { 1683 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 ResourceLoader* loader = GetLoader(filter_->child_id(), request_id); 1784 ResourceLoader* loader = GetLoader(filter_->child_id(), request_id);
1772 // The request may go away before processing this message, so |loader| can 1785 // The request may go away before processing this message, so |loader| can
1773 // legitimately be null. 1786 // legitimately be null.
1774 if (!loader) 1787 if (!loader)
1775 return; 1788 return;
1776 1789
1777 scheduler_->ReprioritizeRequest(loader->request(), new_priority, 1790 scheduler_->ReprioritizeRequest(loader->request(), new_priority,
1778 intra_priority_value); 1791 intra_priority_value);
1779 } 1792 }
1780 1793
1794 void ResourceDispatcherHostImpl::OnReceivedResponseForMojo(
1795 int request_id,
1796 const ResourceResponseHead& head) {
1797 int child_id = filter_->child_id();
1798 ResourceLoader* loader = GetLoader(child_id, request_id);
1799 mojom::URLLoaderClient* client = loader->client();
1800 client->OnReceiveResponse(head, loader->GetRequestInfo()->TakeBodyReader());
1801 }
1802
1803 void ResourceDispatcherHostImpl::OnRequestCompleteForMojo(
1804 int request_id,
1805 const ResourceRequestCompletionStatus& status) {
1806 int child_id = filter_->child_id();
1807 ResourceLoader* loader = GetLoader(child_id, request_id);
1808 DCHECK(loader);
1809 mojom::URLLoaderClient* client = loader->client();
1810 DCHECK(client);
1811
1812 client->OnComplete(status);
1813 }
1814
1781 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { 1815 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) {
1782 // TODO(michaeln): maybe throttle DataDownloaded messages 1816 // TODO(michaeln): maybe throttle DataDownloaded messages
1783 } 1817 }
1784 1818
1785 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( 1819 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile(
1786 int child_id, int request_id, const base::FilePath& file_path) { 1820 int child_id, int request_id, const base::FilePath& file_path) {
1787 scoped_refptr<ShareableFileReference> reference = 1821 scoped_refptr<ShareableFileReference> reference =
1788 ShareableFileReference::Get(file_path); 1822 ShareableFileReference::Get(file_path);
1789 DCHECK(reference.get()); 1823 DCHECK(reference.get());
1790 1824
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 // blocked_loaders_map_, as blocking requests modifies the map. 2090 // blocked_loaders_map_, as blocking requests modifies the map.
2057 std::set<GlobalFrameRoutingId> routing_ids; 2091 std::set<GlobalFrameRoutingId> routing_ids;
2058 for (const auto& blocked_loaders : blocked_loaders_map_) { 2092 for (const auto& blocked_loaders : blocked_loaders_map_) {
2059 if (blocked_loaders.first.child_id == child_id) 2093 if (blocked_loaders.first.child_id == child_id)
2060 routing_ids.insert(blocked_loaders.first); 2094 routing_ids.insert(blocked_loaders.first);
2061 } 2095 }
2062 for (const GlobalFrameRoutingId& route_id : routing_ids) { 2096 for (const GlobalFrameRoutingId& route_id : routing_ids) {
2063 CancelBlockedRequestsForRoute(route_id); 2097 CancelBlockedRequestsForRoute(route_id);
2064 } 2098 }
2065 } 2099 }
2100
2101 // Uninitiated URLLoader has no routing ID, so it should be deleted only when
2102 // cancel_all_routes is specified.
2103 if (cancel_all_routes) {
2104 auto it = uninitiated_url_loaders_.begin();
2105 while (it != uninitiated_url_loaders_.end()) {
2106 if (it->second.first == child_id) {
2107 it = uninitiated_url_loaders_.erase(it);
2108 } else {
2109 ++it;
2110 }
2111 }
2112 }
2066 } 2113 }
2067 2114
2068 // Cancels the request and removes it from the list. 2115 // Cancels the request and removes it from the list.
2069 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, 2116 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id,
2070 int request_id) { 2117 int request_id) {
2071 LoaderMap::iterator i = pending_loaders_.find( 2118 LoaderMap::iterator i = pending_loaders_.find(
2072 GlobalRequestID(child_id, request_id)); 2119 GlobalRequestID(child_id, request_id));
2073 if (i == pending_loaders_.end()) { 2120 if (i == pending_loaders_.end()) {
2074 NOTREACHED() << "Trying to remove a request that's not here"; 2121 NOTREACHED() << "Trying to remove a request that's not here";
2075 return; 2122 return;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 std::move(handler)); 2390 std::move(handler));
2344 2391
2345 BeginRequestInternal(std::move(new_request), std::move(handler)); 2392 BeginRequestInternal(std::move(new_request), std::move(handler));
2346 } 2393 }
2347 2394
2348 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { 2395 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2349 if (!async_revalidation_manager_) 2396 if (!async_revalidation_manager_)
2350 async_revalidation_manager_.reset(new AsyncRevalidationManager); 2397 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2351 } 2398 }
2352 2399
2400 bool ResourceDispatcherHostImpl::SendWithMojoIfPossible(
2401 const IPC::Message& message,
2402 ResourceMessageFilter* filter) {
2403 if (IPC_MESSAGE_ID_CLASS(message.type()) != ResourceMsgStart)
2404 return false;
2405
2406 base::PickleIterator iter(message);
2407 int request_id = -1;
2408 bool ok = iter.ReadInt(&request_id);
2409 DCHECK(ok);
2410 ResourceLoader* loader = GetLoader(filter->child_id(), request_id);
2411 if (!loader || !loader->client())
2412 return false;
2413
2414 DCHECK(!filter_);
2415 filter_ = filter;
2416 bool handled = true;
2417 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message)
2418 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedResponse, OnReceivedResponseForMojo)
2419 IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete, OnRequestCompleteForMojo)
2420 IPC_MESSAGE_UNHANDLED(handled = false)
2421 IPC_END_MESSAGE_MAP()
2422
2423 filter_ = nullptr;
2424 return handled;
2425 }
2426
2427 void ResourceDispatcherHostImpl::AddUninitiatedURLLoader(
2428 int child_id,
2429 std::unique_ptr<mojom::URLLoader> loader) {
2430 mojom::URLLoader* raw = loader.get();
2431 uninitiated_url_loaders_.insert(
2432 std::make_pair(raw, std::make_pair(child_id, std::move(loader))));
2433 }
2434
2435 std::unique_ptr<mojom::URLLoader>
2436 ResourceDispatcherHostImpl::TakeUninitiatedURLLoader(mojom::URLLoader* loader) {
2437 auto it = uninitiated_url_loaders_.find(loader);
2438 if (it == uninitiated_url_loaders_.end())
2439 return nullptr;
2440 std::unique_ptr<mojom::URLLoader> result = std::move(it->second.second);
2441 uninitiated_url_loaders_.erase(it);
2442 return result;
2443 }
2444
2445 void ResourceDispatcherHostImpl::SetMojoLoaderAndClientrForNextLoadRequest(
2446 std::unique_ptr<mojom::URLLoader> loader,
2447 mojom::URLLoaderClientPtr client) {
2448 mojo_loader_for_next_load_request_ = std::move(loader);
2449 mojo_loader_client_for_next_load_request_ = std::move(client);
2450 }
2451
2353 // static 2452 // static
2354 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2453 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2355 net::URLRequest* request) { 2454 net::URLRequest* request) {
2356 // The following fields should be a minor size contribution (experimentally 2455 // The following fields should be a minor size contribution (experimentally
2357 // on the order of 100). However since they are variable length, it could 2456 // on the order of 100). However since they are variable length, it could
2358 // in theory be a sizeable contribution. 2457 // in theory be a sizeable contribution.
2359 int strings_cost = request->extra_request_headers().ToString().size() + 2458 int strings_cost = request->extra_request_headers().ToString().size() +
2360 request->original_url().spec().size() + 2459 request->original_url().spec().size() +
2361 request->referrer().size() + 2460 request->referrer().size() +
2362 request->method().size(); 2461 request->method().size();
2363 2462
2364 // Note that this expression will typically be dominated by: 2463 // Note that this expression will typically be dominated by:
2365 // |kAvgBytesPerOutstandingRequest|. 2464 // |kAvgBytesPerOutstandingRequest|.
2366 return kAvgBytesPerOutstandingRequest + strings_cost; 2465 return kAvgBytesPerOutstandingRequest + strings_cost;
2367 } 2466 }
2368 2467
2369 void ResourceDispatcherHostImpl::BeginRequestInternal( 2468 void ResourceDispatcherHostImpl::BeginRequestInternal(
2370 std::unique_ptr<net::URLRequest> request, 2469 std::unique_ptr<net::URLRequest> request,
2371 std::unique_ptr<ResourceHandler> handler) { 2470 std::unique_ptr<ResourceHandler> handler,
2471 std::unique_ptr<mojom::URLLoader> url_loader,
2472 mojom::URLLoaderClientPtr client) {
2372 DCHECK(!request->is_pending()); 2473 DCHECK(!request->is_pending());
2373 ResourceRequestInfoImpl* info = 2474 ResourceRequestInfoImpl* info =
2374 ResourceRequestInfoImpl::ForRequest(request.get()); 2475 ResourceRequestInfoImpl::ForRequest(request.get());
2375 2476
2376 if ((TimeTicks::Now() - last_user_gesture_time_) < 2477 if ((TimeTicks::Now() - last_user_gesture_time_) <
2377 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 2478 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
2378 request->SetLoadFlags( 2479 request->SetLoadFlags(
2379 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 2480 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
2380 } 2481 }
2381 2482
(...skipping 15 matching lines...) Expand all
2397 NOTREACHED(); 2498 NOTREACHED();
2398 } 2499 }
2399 2500
2400 IncrementOutstandingRequestsMemory(-1, *info); 2501 IncrementOutstandingRequestsMemory(-1, *info);
2401 2502
2402 // A ResourceHandler must not outlive its associated URLRequest. 2503 // A ResourceHandler must not outlive its associated URLRequest.
2403 handler.reset(); 2504 handler.reset();
2404 return; 2505 return;
2405 } 2506 }
2406 2507
2407 std::unique_ptr<ResourceLoader> loader(new ResourceLoader( 2508 std::unique_ptr<ResourceLoader> loader(
2408 std::move(request), std::move(handler), GetCertStore(), this)); 2509 new ResourceLoader(std::move(request), std::move(handler), GetCertStore(),
2510 std::move(url_loader), std::move(client), this));
2409 2511
2410 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID()); 2512 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID());
2411 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); 2513 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id);
2412 if (iter != blocked_loaders_map_.end()) { 2514 if (iter != blocked_loaders_map_.end()) {
2413 // The request should be blocked. 2515 // The request should be blocked.
2414 iter->second->push_back(std::move(loader)); 2516 iter->second->push_back(std::move(loader));
2415 return; 2517 return;
2416 } 2518 }
2417 2519
2418 StartLoading(info, std::move(loader)); 2520 StartLoading(info, std::move(loader));
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); 2791 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id);
2690 response->head.security_info = SerializeSecurityInfo(ssl); 2792 response->head.security_info = SerializeSecurityInfo(ssl);
2691 } 2793 }
2692 2794
2693 CertStore* ResourceDispatcherHostImpl::GetCertStore() { 2795 CertStore* ResourceDispatcherHostImpl::GetCertStore() {
2694 return cert_store_for_testing_ ? cert_store_for_testing_ 2796 return cert_store_for_testing_ ? cert_store_for_testing_
2695 : CertStore::GetInstance(); 2797 : CertStore::GetInstance();
2696 } 2798 }
2697 2799
2698 } // namespace content 2800 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698