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

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

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 #include <algorithm> 10 #include <algorithm>
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 request.get(), 840 request.get(),
841 blob_context->context()->GetBlobDataFromPublicURL(request->url())); 841 blob_context->context()->GetBlobDataFromPublicURL(request->url()));
842 } 842 }
843 843
844 // From this point forward, the |DownloadResourceHandler| is responsible for 844 // From this point forward, the |DownloadResourceHandler| is responsible for
845 // |started_callback|. 845 // |started_callback|.
846 scoped_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload( 846 scoped_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload(
847 request.get(), is_content_initiated, true, download_id, 847 request.get(), is_content_initiated, true, download_id,
848 std::move(save_info), started_callback)); 848 std::move(save_info), started_callback));
849 849
850 BeginRequestInternal(std::move(request), std::move(handler)); 850 BeginRequestInternal(std::move(request), std::move(handler), nullptr);
851 851
852 return DOWNLOAD_INTERRUPT_REASON_NONE; 852 return DOWNLOAD_INTERRUPT_REASON_NONE;
853 } 853 }
854 854
855 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( 855 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest(
856 net::URLRequest* request) { 856 net::URLRequest* request) {
857 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 857 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
858 if (info) { 858 if (info) {
859 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); 859 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
860 if (loader) 860 if (loader)
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 request_data.appcache_host_id, request_data.resource_type, 1644 request_data.appcache_host_id, request_data.resource_type,
1645 request_data.should_reset_appcache); 1645 request_data.should_reset_appcache);
1646 1646
1647 scoped_ptr<ResourceHandler> handler( 1647 scoped_ptr<ResourceHandler> handler(
1648 CreateResourceHandler( 1648 CreateResourceHandler(
1649 new_request.get(), 1649 new_request.get(),
1650 request_data, sync_result, route_id, process_type, child_id, 1650 request_data, sync_result, route_id, process_type, child_id,
1651 resource_context)); 1651 resource_context));
1652 1652
1653 if (handler) 1653 if (handler)
1654 BeginRequestInternal(std::move(new_request), std::move(handler)); 1654 BeginRequestInternal(std::move(new_request), std::move(handler),
1655 resource_context);
1655 } 1656 }
1656 1657
1657 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1658 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1658 net::URLRequest* request, 1659 net::URLRequest* request,
1659 const ResourceHostMsg_Request& request_data, 1660 const ResourceHostMsg_Request& request_data,
1660 IPC::Message* sync_result, 1661 IPC::Message* sync_result,
1661 int route_id, 1662 int route_id,
1662 int process_type, 1663 int process_type,
1663 int child_id, 1664 int child_id,
1664 ResourceContext* resource_context) { 1665 ResourceContext* resource_context) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 // Since we're just saving some resources we need, disallow downloading. 1965 // Since we're just saving some resources we need, disallow downloading.
1965 ResourceRequestInfoImpl* extra_info = 1966 ResourceRequestInfoImpl* extra_info =
1966 CreateRequestInfo(child_id, render_view_route_id, 1967 CreateRequestInfo(child_id, render_view_route_id,
1967 render_frame_route_id, false, context); 1968 render_frame_route_id, false, context);
1968 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 1969 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
1969 1970
1970 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler( 1971 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler(
1971 request.get(), save_item_id, save_package_id, child_id, 1972 request.get(), save_item_id, save_package_id, child_id,
1972 render_frame_route_id, url, save_file_manager_.get())); 1973 render_frame_route_id, url, save_file_manager_.get()));
1973 1974
1974 BeginRequestInternal(std::move(request), std::move(handler)); 1975 BeginRequestInternal(std::move(request), std::move(handler), nullptr);
1975 } 1976 }
1976 1977
1977 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1978 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1978 const GlobalRequestID& id) { 1979 const GlobalRequestID& id) {
1979 GetLoader(id)->MarkAsTransferring(); 1980 GetLoader(id)->MarkAsTransferring();
1980 } 1981 }
1981 1982
1982 void ResourceDispatcherHostImpl::CancelTransferringNavigation( 1983 void ResourceDispatcherHostImpl::CancelTransferringNavigation(
1983 const GlobalRequestID& id) { 1984 const GlobalRequestID& id) {
1984 // Request should still exist and be in the middle of a transfer. 1985 // Request should still exist and be in the middle of a transfer.
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2354 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2354 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2355 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2355 // currently it's a no-op. 2356 // currently it's a no-op.
2356 handler = 2357 handler =
2357 AddStandardHandlers(new_request.get(), resource_type, resource_context, 2358 AddStandardHandlers(new_request.get(), resource_type, resource_context,
2358 nullptr, // appcache_service 2359 nullptr, // appcache_service
2359 -1, // child_id 2360 -1, // child_id
2360 -1, // route_id 2361 -1, // route_id
2361 std::move(handler)); 2362 std::move(handler));
2362 2363
2363 BeginRequestInternal(std::move(new_request), std::move(handler)); 2364 BeginRequestInternal(std::move(new_request), std::move(handler),
2365 resource_context);
2364 } 2366 }
2365 2367
2366 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { 2368 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2367 if (!async_revalidation_manager_) 2369 if (!async_revalidation_manager_)
2368 async_revalidation_manager_.reset(new AsyncRevalidationManager); 2370 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2369 } 2371 }
2370 2372
2371 // static 2373 // static
2372 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2374 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2373 net::URLRequest* request) { 2375 net::URLRequest* request) {
2374 // The following fields should be a minor size contribution (experimentally 2376 // The following fields should be a minor size contribution (experimentally
2375 // on the order of 100). However since they are variable length, it could 2377 // on the order of 100). However since they are variable length, it could
2376 // in theory be a sizeable contribution. 2378 // in theory be a sizeable contribution.
2377 int strings_cost = request->extra_request_headers().ToString().size() + 2379 int strings_cost = request->extra_request_headers().ToString().size() +
2378 request->original_url().spec().size() + 2380 request->original_url().spec().size() +
2379 request->referrer().size() + 2381 request->referrer().size() +
2380 request->method().size(); 2382 request->method().size();
2381 2383
2382 // Note that this expression will typically be dominated by: 2384 // Note that this expression will typically be dominated by:
2383 // |kAvgBytesPerOutstandingRequest|. 2385 // |kAvgBytesPerOutstandingRequest|.
2384 return kAvgBytesPerOutstandingRequest + strings_cost; 2386 return kAvgBytesPerOutstandingRequest + strings_cost;
2385 } 2387 }
2386 2388
2387 void ResourceDispatcherHostImpl::BeginRequestInternal( 2389 void ResourceDispatcherHostImpl::BeginRequestInternal(
2388 scoped_ptr<net::URLRequest> request, 2390 scoped_ptr<net::URLRequest> request,
2389 scoped_ptr<ResourceHandler> handler) { 2391 scoped_ptr<ResourceHandler> handler,
2392 ResourceContext* resource_context) {
2390 DCHECK(!request->is_pending()); 2393 DCHECK(!request->is_pending());
2391 ResourceRequestInfoImpl* info = 2394 ResourceRequestInfoImpl* info =
2392 ResourceRequestInfoImpl::ForRequest(request.get()); 2395 ResourceRequestInfoImpl::ForRequest(request.get());
2393 2396
2394 if ((TimeTicks::Now() - last_user_gesture_time_) < 2397 if ((TimeTicks::Now() - last_user_gesture_time_) <
2395 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 2398 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
2396 request->SetLoadFlags( 2399 request->SetLoadFlags(
2397 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 2400 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
2398 } 2401 }
2399 2402
(...skipping 16 matching lines...) Expand all
2416 } 2419 }
2417 2420
2418 IncrementOutstandingRequestsMemory(-1, *info); 2421 IncrementOutstandingRequestsMemory(-1, *info);
2419 2422
2420 // A ResourceHandler must not outlive its associated URLRequest. 2423 // A ResourceHandler must not outlive its associated URLRequest.
2421 handler.reset(); 2424 handler.reset();
2422 return; 2425 return;
2423 } 2426 }
2424 2427
2425 scoped_ptr<ResourceLoader> loader( 2428 scoped_ptr<ResourceLoader> loader(
2426 new ResourceLoader(std::move(request), std::move(handler), this)); 2429 new ResourceLoader(std::move(request), std::move(handler), this,
2430 delegate_, resource_context));
2427 2431
2428 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID()); 2432 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID());
2429 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); 2433 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id);
2430 if (iter != blocked_loaders_map_.end()) { 2434 if (iter != blocked_loaders_map_.end()) {
2431 // The request should be blocked. 2435 // The request should be blocked.
2432 iter->second->push_back(std::move(loader)); 2436 iter->second->push_back(std::move(loader));
2433 return; 2437 return;
2434 } 2438 }
2435 2439
2436 StartLoading(info, std::move(loader)); 2440 StartLoading(info, std::move(loader));
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 load_flags |= net::LOAD_PREFETCH; 2686 load_flags |= net::LOAD_PREFETCH;
2683 } 2687 }
2684 2688
2685 if (is_sync_load) 2689 if (is_sync_load)
2686 load_flags |= net::LOAD_IGNORE_LIMITS; 2690 load_flags |= net::LOAD_IGNORE_LIMITS;
2687 2691
2688 return load_flags; 2692 return load_flags;
2689 } 2693 }
2690 2694
2691 } // namespace content 2695 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698