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

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

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
11 #include <algorithm> 10 #include <algorithm>
12 #include <set> 11 #include <set>
12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/debug/alias.h" 19 #include "base/debug/alias.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 if (request->url().SchemeIs(url::kBlobScheme)) { 718 if (request->url().SchemeIs(url::kBlobScheme)) {
719 ChromeBlobStorageContext* blob_context = 719 ChromeBlobStorageContext* blob_context =
720 GetChromeBlobStorageContextForResourceContext(context); 720 GetChromeBlobStorageContextForResourceContext(context);
721 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 721 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
722 request.get(), 722 request.get(),
723 blob_context->context()->GetBlobDataFromPublicURL(request->url())); 723 blob_context->context()->GetBlobDataFromPublicURL(request->url()));
724 } 724 }
725 725
726 // From this point forward, the |DownloadResourceHandler| is responsible for 726 // From this point forward, the |DownloadResourceHandler| is responsible for
727 // |started_callback|. 727 // |started_callback|.
728 scoped_ptr<ResourceHandler> handler( 728 scoped_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload(
729 CreateResourceHandlerForDownload(request.get(), is_content_initiated, 729 request.get(), is_content_initiated, true, download_id,
730 true, download_id, save_info.Pass(), 730 std::move(save_info), started_callback));
731 started_callback));
732 731
733 BeginRequestInternal(request.Pass(), handler.Pass()); 732 BeginRequestInternal(std::move(request), std::move(handler));
734 733
735 return DOWNLOAD_INTERRUPT_REASON_NONE; 734 return DOWNLOAD_INTERRUPT_REASON_NONE;
736 } 735 }
737 736
738 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( 737 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest(
739 net::URLRequest* request) { 738 net::URLRequest* request) {
740 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 739 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
741 if (info) { 740 if (info) {
742 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); 741 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
743 if (loader) 742 if (loader)
(...skipping 10 matching lines...) Expand all
754 } 753 }
755 754
756 scoped_ptr<ResourceHandler> 755 scoped_ptr<ResourceHandler>
757 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( 756 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
758 net::URLRequest* request, 757 net::URLRequest* request,
759 bool is_content_initiated, 758 bool is_content_initiated,
760 bool must_download, 759 bool must_download,
761 uint32_t id, 760 uint32_t id,
762 scoped_ptr<DownloadSaveInfo> save_info, 761 scoped_ptr<DownloadSaveInfo> save_info,
763 const DownloadUrlParameters::OnStartedCallback& started_cb) { 762 const DownloadUrlParameters::OnStartedCallback& started_cb) {
764 scoped_ptr<ResourceHandler> handler( 763 scoped_ptr<ResourceHandler> handler(new DownloadResourceHandler(
765 new DownloadResourceHandler(id, request, started_cb, save_info.Pass())); 764 id, request, started_cb, std::move(save_info)));
766 if (delegate_) { 765 if (delegate_) {
767 const ResourceRequestInfoImpl* request_info( 766 const ResourceRequestInfoImpl* request_info(
768 ResourceRequestInfoImpl::ForRequest(request)); 767 ResourceRequestInfoImpl::ForRequest(request));
769 768
770 ScopedVector<ResourceThrottle> throttles; 769 ScopedVector<ResourceThrottle> throttles;
771 delegate_->DownloadStarting( 770 delegate_->DownloadStarting(
772 request, request_info->GetContext(), request_info->GetChildID(), 771 request, request_info->GetContext(), request_info->GetChildID(),
773 request_info->GetRouteID(), request_info->GetRequestID(), 772 request_info->GetRouteID(), request_info->GetRequestID(),
774 is_content_initiated, must_download, &throttles); 773 is_content_initiated, must_download, &throttles);
775 if (!throttles.empty()) { 774 if (!throttles.empty()) {
776 handler.reset( 775 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
777 new ThrottlingResourceHandler( 776 std::move(throttles)));
778 handler.Pass(), request, throttles.Pass()));
779 } 777 }
780 } 778 }
781 return handler.Pass(); 779 return handler;
782 } 780 }
783 781
784 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::MaybeInterceptAsStream( 782 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::MaybeInterceptAsStream(
785 const base::FilePath& plugin_path, 783 const base::FilePath& plugin_path,
786 net::URLRequest* request, 784 net::URLRequest* request,
787 ResourceResponse* response, 785 ResourceResponse* response,
788 std::string* payload) { 786 std::string* payload) {
789 payload->clear(); 787 payload->clear();
790 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 788 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
791 const std::string& mime_type = response->head.mime_type; 789 const std::string& mime_type = response->head.mime_type;
(...skipping 18 matching lines...) Expand all
810 stream_info->handle = handler->stream()->CreateHandle(); 808 stream_info->handle = handler->stream()->CreateHandle();
811 stream_info->original_url = request->url(); 809 stream_info->original_url = request->url();
812 stream_info->mime_type = mime_type; 810 stream_info->mime_type = mime_type;
813 // Make a copy of the response headers so it is safe to pass across threads; 811 // Make a copy of the response headers so it is safe to pass across threads;
814 // the old handler (AsyncResourceHandler) may modify it in parallel via the 812 // the old handler (AsyncResourceHandler) may modify it in parallel via the
815 // ResourceDispatcherHostDelegate. 813 // ResourceDispatcherHostDelegate.
816 if (response->head.headers.get()) { 814 if (response->head.headers.get()) {
817 stream_info->response_headers = 815 stream_info->response_headers =
818 new net::HttpResponseHeaders(response->head.headers->raw_headers()); 816 new net::HttpResponseHeaders(response->head.headers->raw_headers());
819 } 817 }
820 delegate_->OnStreamCreated(request, stream_info.Pass()); 818 delegate_->OnStreamCreated(request, std::move(stream_info));
821 return handler.Pass(); 819 return std::move(handler);
822 } 820 }
823 821
824 ResourceDispatcherHostLoginDelegate* 822 ResourceDispatcherHostLoginDelegate*
825 ResourceDispatcherHostImpl::CreateLoginDelegate( 823 ResourceDispatcherHostImpl::CreateLoginDelegate(
826 ResourceLoader* loader, 824 ResourceLoader* loader,
827 net::AuthChallengeInfo* auth_info) { 825 net::AuthChallengeInfo* auth_info) {
828 if (!delegate_) 826 if (!delegate_)
829 return NULL; 827 return NULL;
830 828
831 return delegate_->CreateLoginDelegate(auth_info, loader->request()); 829 return delegate_->CreateLoginDelegate(auth_info, loader->request());
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 request_data.appcache_host_id, request_data.resource_type, 1474 request_data.appcache_host_id, request_data.resource_type,
1477 request_data.should_reset_appcache); 1475 request_data.should_reset_appcache);
1478 1476
1479 scoped_ptr<ResourceHandler> handler( 1477 scoped_ptr<ResourceHandler> handler(
1480 CreateResourceHandler( 1478 CreateResourceHandler(
1481 new_request.get(), 1479 new_request.get(),
1482 request_data, sync_result, route_id, process_type, child_id, 1480 request_data, sync_result, route_id, process_type, child_id,
1483 resource_context)); 1481 resource_context));
1484 1482
1485 if (handler) 1483 if (handler)
1486 BeginRequestInternal(new_request.Pass(), handler.Pass()); 1484 BeginRequestInternal(std::move(new_request), std::move(handler));
1487 } 1485 }
1488 1486
1489 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1487 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1490 net::URLRequest* request, 1488 net::URLRequest* request,
1491 const ResourceHostMsg_Request& request_data, 1489 const ResourceHostMsg_Request& request_data,
1492 IPC::Message* sync_result, 1490 IPC::Message* sync_result,
1493 int route_id, 1491 int route_id,
1494 int process_type, 1492 int process_type,
1495 int child_id, 1493 int child_id,
1496 ResourceContext* resource_context) { 1494 ResourceContext* resource_context) {
(...skipping 10 matching lines...) Expand all
1507 return scoped_ptr<ResourceHandler>(); 1505 return scoped_ptr<ResourceHandler>();
1508 } 1506 }
1509 1507
1510 handler.reset(new SyncResourceHandler(request, sync_result, this)); 1508 handler.reset(new SyncResourceHandler(request, sync_result, this));
1511 } else { 1509 } else {
1512 handler.reset(new AsyncResourceHandler(request, this)); 1510 handler.reset(new AsyncResourceHandler(request, this));
1513 1511
1514 // The RedirectToFileResourceHandler depends on being next in the chain. 1512 // The RedirectToFileResourceHandler depends on being next in the chain.
1515 if (request_data.download_to_file) { 1513 if (request_data.download_to_file) {
1516 handler.reset( 1514 handler.reset(
1517 new RedirectToFileResourceHandler(handler.Pass(), request)); 1515 new RedirectToFileResourceHandler(std::move(handler), request));
1518 } 1516 }
1519 } 1517 }
1520 1518
1521 // Prefetches and <a ping> requests outlive their child process. 1519 // Prefetches and <a ping> requests outlive their child process.
1522 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { 1520 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) {
1523 handler.reset(new DetachableResourceHandler( 1521 handler.reset(new DetachableResourceHandler(
1524 request, 1522 request,
1525 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), 1523 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1526 handler.Pass())); 1524 std::move(handler)));
1527 } 1525 }
1528 1526
1529 // PlzNavigate: If using --enable-browser-side-navigation, the 1527 // PlzNavigate: If using --enable-browser-side-navigation, the
1530 // CrossSiteResourceHandler is not needed. This codepath is not used for the 1528 // CrossSiteResourceHandler is not needed. This codepath is not used for the
1531 // actual navigation request, but only the subsequent blob URL load. This does 1529 // actual navigation request, but only the subsequent blob URL load. This does
1532 // not require request transfers. 1530 // not require request transfers.
1533 if (!IsBrowserSideNavigationEnabled()) { 1531 if (!IsBrowserSideNavigationEnabled()) {
1534 // Install a CrossSiteResourceHandler for all main frame requests. This will 1532 // Install a CrossSiteResourceHandler for all main frame requests. This will
1535 // check whether a transfer is required and, if so, pause for the UI thread 1533 // check whether a transfer is required and, if so, pause for the UI thread
1536 // to drive the transfer. 1534 // to drive the transfer.
1537 bool is_swappable_navigation = 1535 bool is_swappable_navigation =
1538 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; 1536 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME;
1539 // If out-of-process iframes are possible, then all subframe requests need 1537 // If out-of-process iframes are possible, then all subframe requests need
1540 // to go through the CrossSiteResourceHandler to enforce the site isolation 1538 // to go through the CrossSiteResourceHandler to enforce the site isolation
1541 // policy. 1539 // policy.
1542 if (!is_swappable_navigation && 1540 if (!is_swappable_navigation &&
1543 SiteIsolationPolicy::AreCrossProcessFramesPossible()) { 1541 SiteIsolationPolicy::AreCrossProcessFramesPossible()) {
1544 is_swappable_navigation = 1542 is_swappable_navigation =
1545 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; 1543 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME;
1546 } 1544 }
1547 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) 1545 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER)
1548 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request)); 1546 handler.reset(new CrossSiteResourceHandler(std::move(handler), request));
1549 } 1547 }
1550 1548
1551 return AddStandardHandlers(request, request_data.resource_type, 1549 return AddStandardHandlers(request, request_data.resource_type,
1552 resource_context, filter_->appcache_service(), 1550 resource_context, filter_->appcache_service(),
1553 child_id, route_id, handler.Pass()); 1551 child_id, route_id, std::move(handler));
1554 } 1552 }
1555 1553
1556 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers( 1554 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers(
1557 net::URLRequest* request, 1555 net::URLRequest* request,
1558 ResourceType resource_type, 1556 ResourceType resource_type,
1559 ResourceContext* resource_context, 1557 ResourceContext* resource_context,
1560 AppCacheService* appcache_service, 1558 AppCacheService* appcache_service,
1561 int child_id, 1559 int child_id,
1562 int route_id, 1560 int route_id,
1563 scoped_ptr<ResourceHandler> handler) { 1561 scoped_ptr<ResourceHandler> handler) {
1564 // PlzNavigate: do not add ResourceThrottles for main resource requests from 1562 // PlzNavigate: do not add ResourceThrottles for main resource requests from
1565 // the renderer. Decisions about the navigation should have been done in the 1563 // the renderer. Decisions about the navigation should have been done in the
1566 // initial request. 1564 // initial request.
1567 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) && 1565 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) &&
1568 child_id != -1) { 1566 child_id != -1) {
1569 DCHECK(request->url().SchemeIs(url::kBlobScheme)); 1567 DCHECK(request->url().SchemeIs(url::kBlobScheme));
1570 return handler.Pass(); 1568 return handler;
1571 } 1569 }
1572 1570
1573 PluginService* plugin_service = nullptr; 1571 PluginService* plugin_service = nullptr;
1574 #if defined(ENABLE_PLUGINS) 1572 #if defined(ENABLE_PLUGINS)
1575 plugin_service = PluginService::GetInstance(); 1573 plugin_service = PluginService::GetInstance();
1576 #endif 1574 #endif
1577 // Insert a buffered event handler before the actual one. 1575 // Insert a buffered event handler before the actual one.
1578 handler.reset(new MimeTypeResourceHandler(handler.Pass(), this, 1576 handler.reset(new MimeTypeResourceHandler(std::move(handler), this,
1579 plugin_service, request)); 1577 plugin_service, request));
1580 1578
1581 ScopedVector<ResourceThrottle> throttles; 1579 ScopedVector<ResourceThrottle> throttles;
1582 1580
1583 // Add a NavigationResourceThrottle for navigations. 1581 // Add a NavigationResourceThrottle for navigations.
1584 // PlzNavigate: the throttle is unnecessary as communication with the UI 1582 // PlzNavigate: the throttle is unnecessary as communication with the UI
1585 // thread is handled by the NavigationURLloader. 1583 // thread is handled by the NavigationURLloader.
1586 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) 1584 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type))
1587 throttles.push_back(new NavigationResourceThrottle(request)); 1585 throttles.push_back(new NavigationResourceThrottle(request));
1588 1586
1589 if (delegate_) { 1587 if (delegate_) {
1590 delegate_->RequestBeginning(request, 1588 delegate_->RequestBeginning(request,
1591 resource_context, 1589 resource_context,
1592 appcache_service, 1590 appcache_service,
1593 resource_type, 1591 resource_type,
1594 &throttles); 1592 &throttles);
1595 } 1593 }
1596 1594
1597 if (request->has_upload()) { 1595 if (request->has_upload()) {
1598 // Block power save while uploading data. 1596 // Block power save while uploading data.
1599 throttles.push_back(new PowerSaveBlockResourceThrottle()); 1597 throttles.push_back(new PowerSaveBlockResourceThrottle());
1600 } 1598 }
1601 1599
1602 // TODO(ricea): Stop looking this up so much. 1600 // TODO(ricea): Stop looking this up so much.
1603 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1601 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1604 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, 1602 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id,
1605 info->IsAsync(), request)); 1603 info->IsAsync(), request));
1606 1604
1607 handler.reset( 1605 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
1608 new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); 1606 std::move(throttles)));
1609 1607
1610 return handler.Pass(); 1608 return handler;
1611 } 1609 }
1612 1610
1613 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { 1611 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
1614 UnregisterDownloadedTempFile(filter_->child_id(), request_id); 1612 UnregisterDownloadedTempFile(filter_->child_id(), request_id);
1615 } 1613 }
1616 1614
1617 void ResourceDispatcherHostImpl::OnDidChangePriority( 1615 void ResourceDispatcherHostImpl::OnDidChangePriority(
1618 int request_id, 1616 int request_id,
1619 net::RequestPriority new_priority, 1617 net::RequestPriority new_priority,
1620 int intra_priority_value) { 1618 int intra_priority_value) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 // Since we're just saving some resources we need, disallow downloading. 1816 // Since we're just saving some resources we need, disallow downloading.
1819 ResourceRequestInfoImpl* extra_info = 1817 ResourceRequestInfoImpl* extra_info =
1820 CreateRequestInfo(child_id, render_view_route_id, 1818 CreateRequestInfo(child_id, render_view_route_id,
1821 render_frame_route_id, false, context); 1819 render_frame_route_id, false, context);
1822 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 1820 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
1823 1821
1824 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler( 1822 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler(
1825 request.get(), save_item_id, save_package_id, child_id, 1823 request.get(), save_item_id, save_package_id, child_id,
1826 render_frame_route_id, url, save_file_manager_.get())); 1824 render_frame_route_id, url, save_file_manager_.get()));
1827 1825
1828 BeginRequestInternal(request.Pass(), handler.Pass()); 1826 BeginRequestInternal(std::move(request), std::move(handler));
1829 } 1827 }
1830 1828
1831 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1829 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1832 const GlobalRequestID& id) { 1830 const GlobalRequestID& id) {
1833 GetLoader(id)->MarkAsTransferring(); 1831 GetLoader(id)->MarkAsTransferring();
1834 } 1832 }
1835 1833
1836 void ResourceDispatcherHostImpl::CancelTransferringNavigation( 1834 void ResourceDispatcherHostImpl::CancelTransferringNavigation(
1837 const GlobalRequestID& id) { 1835 const GlobalRequestID& id) {
1838 // Request should still exist and be in the middle of a transfer. 1836 // Request should still exist and be in the middle of a transfer.
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 info.begin_params.request_context_type, frame_type, info.request_body); 2196 info.begin_params.request_context_type, frame_type, info.request_body);
2199 2197
2200 // TODO(davidben): Attach AppCacheInterceptor. 2198 // TODO(davidben): Attach AppCacheInterceptor.
2201 2199
2202 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2200 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2203 new_request.get(), loader)); 2201 new_request.get(), loader));
2204 2202
2205 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2203 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2206 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2204 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2207 // currently it's a no-op. 2205 // currently it's a no-op.
2208 handler = AddStandardHandlers(new_request.get(), resource_type, 2206 handler =
2209 resource_context, 2207 AddStandardHandlers(new_request.get(), resource_type, resource_context,
2210 nullptr, // appcache_service 2208 nullptr, // appcache_service
2211 -1, // child_id 2209 -1, // child_id
2212 -1, // route_id 2210 -1, // route_id
2213 handler.Pass()); 2211 std::move(handler));
2214 2212
2215 BeginRequestInternal(new_request.Pass(), handler.Pass()); 2213 BeginRequestInternal(std::move(new_request), std::move(handler));
2216 } 2214 }
2217 2215
2218 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { 2216 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2219 if (!async_revalidation_manager_) 2217 if (!async_revalidation_manager_)
2220 async_revalidation_manager_.reset(new AsyncRevalidationManager); 2218 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2221 } 2219 }
2222 2220
2223 // static 2221 // static
2224 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2222 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2225 net::URLRequest* request) { 2223 net::URLRequest* request) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 } 2266 }
2269 2267
2270 IncrementOutstandingRequestsMemory(-1, *info); 2268 IncrementOutstandingRequestsMemory(-1, *info);
2271 2269
2272 // A ResourceHandler must not outlive its associated URLRequest. 2270 // A ResourceHandler must not outlive its associated URLRequest.
2273 handler.reset(); 2271 handler.reset();
2274 return; 2272 return;
2275 } 2273 }
2276 2274
2277 linked_ptr<ResourceLoader> loader( 2275 linked_ptr<ResourceLoader> loader(
2278 new ResourceLoader(request.Pass(), handler.Pass(), this)); 2276 new ResourceLoader(std::move(request), std::move(handler), this));
2279 2277
2280 GlobalRoutingID id(info->GetGlobalRoutingID()); 2278 GlobalRoutingID id(info->GetGlobalRoutingID());
2281 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); 2279 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id);
2282 if (iter != blocked_loaders_map_.end()) { 2280 if (iter != blocked_loaders_map_.end()) {
2283 // The request should be blocked. 2281 // The request should be blocked.
2284 iter->second->push_back(loader); 2282 iter->second->push_back(loader);
2285 return; 2283 return;
2286 } 2284 }
2287 2285
2288 StartLoading(info, loader); 2286 StartLoading(info, loader);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 load_info.upload_position = upload_progress.position(); 2369 load_info.upload_position = upload_progress.position();
2372 2370
2373 GlobalRoutingID id(loader.second->GetRequestInfo()->GetGlobalRoutingID()); 2371 GlobalRoutingID id(loader.second->GetRequestInfo()->GetGlobalRoutingID());
2374 LoadInfoMap::iterator existing = info_map->find(id); 2372 LoadInfoMap::iterator existing = info_map->find(id);
2375 2373
2376 if (existing == info_map->end() || 2374 if (existing == info_map->end() ||
2377 LoadInfoIsMoreInteresting(load_info, existing->second)) { 2375 LoadInfoIsMoreInteresting(load_info, existing->second)) {
2378 (*info_map)[id] = load_info; 2376 (*info_map)[id] = load_info;
2379 } 2377 }
2380 } 2378 }
2381 return info_map.Pass(); 2379 return info_map;
2382 } 2380 }
2383 2381
2384 void ResourceDispatcherHostImpl::UpdateLoadInfo() { 2382 void ResourceDispatcherHostImpl::UpdateLoadInfo() {
2385 scoped_ptr<LoadInfoMap> info_map(GetLoadInfoForAllRoutes()); 2383 scoped_ptr<LoadInfoMap> info_map(GetLoadInfoForAllRoutes());
2386 2384
2387 // Stop the timer if there are no more pending requests. Future new requests 2385 // Stop the timer if there are no more pending requests. Future new requests
2388 // will restart it as necessary. 2386 // will restart it as necessary.
2389 // Also stop the timer if there are no loading clients, to avoid waking up 2387 // Also stop the timer if there are no loading clients, to avoid waking up
2390 // unnecessarily when there is a long running (hanging get) request. 2388 // unnecessarily when there is a long running (hanging get) request.
2391 if (info_map->empty() || !scheduler_->HasLoadingClients()) { 2389 if (info_map->empty() || !scheduler_->HasLoadingClients()) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 load_flags |= net::LOAD_PREFETCH; 2533 load_flags |= net::LOAD_PREFETCH;
2536 } 2534 }
2537 2535
2538 if (is_sync_load) 2536 if (is_sync_load)
2539 load_flags |= net::LOAD_IGNORE_LIMITS; 2537 load_flags |= net::LOAD_IGNORE_LIMITS;
2540 2538
2541 return load_flags; 2539 return load_flags;
2542 } 2540 }
2543 2541
2544 } // namespace content 2542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698