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 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing nits 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
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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 799 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
800 request.get(), 800 request.get(),
801 blob_context->context()->GetBlobDataFromPublicURL(request->url())); 801 blob_context->context()->GetBlobDataFromPublicURL(request->url()));
802 } 802 }
803 803
804 // From this point forward, the |DownloadResourceHandler| is responsible for 804 // From this point forward, the |DownloadResourceHandler| is responsible for
805 // |started_callback|. 805 // |started_callback|.
806 scoped_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload( 806 scoped_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload(
807 request.get(), is_content_initiated, true)); 807 request.get(), is_content_initiated, true));
808 808
809 BeginRequestInternal(std::move(request), std::move(handler)); 809 BeginRequestInternal(std::move(request), std::move(handler), nullptr);
810 810
811 return DOWNLOAD_INTERRUPT_REASON_NONE; 811 return DOWNLOAD_INTERRUPT_REASON_NONE;
812 } 812 }
813 813
814 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( 814 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest(
815 net::URLRequest* request) { 815 net::URLRequest* request) {
816 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 816 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
817 if (info) { 817 if (info) {
818 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); 818 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
819 if (loader) 819 if (loader)
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 request_data.appcache_host_id, request_data.resource_type, 1612 request_data.appcache_host_id, request_data.resource_type,
1613 request_data.should_reset_appcache); 1613 request_data.should_reset_appcache);
1614 1614
1615 scoped_ptr<ResourceHandler> handler( 1615 scoped_ptr<ResourceHandler> handler(
1616 CreateResourceHandler( 1616 CreateResourceHandler(
1617 new_request.get(), 1617 new_request.get(),
1618 request_data, sync_result, route_id, process_type, child_id, 1618 request_data, sync_result, route_id, process_type, child_id,
1619 resource_context)); 1619 resource_context));
1620 1620
1621 if (handler) 1621 if (handler)
1622 BeginRequestInternal(std::move(new_request), std::move(handler)); 1622 BeginRequestInternal(std::move(new_request), std::move(handler),
1623 resource_context);
1623 } 1624 }
1624 1625
1625 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1626 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1626 net::URLRequest* request, 1627 net::URLRequest* request,
1627 const ResourceHostMsg_Request& request_data, 1628 const ResourceHostMsg_Request& request_data,
1628 IPC::Message* sync_result, 1629 IPC::Message* sync_result,
1629 int route_id, 1630 int route_id,
1630 int process_type, 1631 int process_type,
1631 int child_id, 1632 int child_id,
1632 ResourceContext* resource_context) { 1633 ResourceContext* resource_context) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 // Since we're just saving some resources we need, disallow downloading. 1933 // Since we're just saving some resources we need, disallow downloading.
1933 ResourceRequestInfoImpl* extra_info = 1934 ResourceRequestInfoImpl* extra_info =
1934 CreateRequestInfo(child_id, render_view_route_id, 1935 CreateRequestInfo(child_id, render_view_route_id,
1935 render_frame_route_id, false, context); 1936 render_frame_route_id, false, context);
1936 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 1937 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
1937 1938
1938 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler( 1939 scoped_ptr<ResourceHandler> handler(new SaveFileResourceHandler(
1939 request.get(), save_item_id, save_package_id, child_id, 1940 request.get(), save_item_id, save_package_id, child_id,
1940 render_frame_route_id, url, save_file_manager_.get())); 1941 render_frame_route_id, url, save_file_manager_.get()));
1941 1942
1942 BeginRequestInternal(std::move(request), std::move(handler)); 1943 BeginRequestInternal(std::move(request), std::move(handler), nullptr);
1943 } 1944 }
1944 1945
1945 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1946 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1946 const GlobalRequestID& id) { 1947 const GlobalRequestID& id) {
1947 GetLoader(id)->MarkAsTransferring(); 1948 GetLoader(id)->MarkAsTransferring();
1948 } 1949 }
1949 1950
1950 void ResourceDispatcherHostImpl::CancelTransferringNavigation( 1951 void ResourceDispatcherHostImpl::CancelTransferringNavigation(
1951 const GlobalRequestID& id) { 1952 const GlobalRequestID& id) {
1952 // Request should still exist and be in the middle of a transfer. 1953 // Request should still exist and be in the middle of a transfer.
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2322 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2322 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2323 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2323 // currently it's a no-op. 2324 // currently it's a no-op.
2324 handler = 2325 handler =
2325 AddStandardHandlers(new_request.get(), resource_type, resource_context, 2326 AddStandardHandlers(new_request.get(), resource_type, resource_context,
2326 nullptr, // appcache_service 2327 nullptr, // appcache_service
2327 -1, // child_id 2328 -1, // child_id
2328 -1, // route_id 2329 -1, // route_id
2329 std::move(handler)); 2330 std::move(handler));
2330 2331
2331 BeginRequestInternal(std::move(new_request), std::move(handler)); 2332 BeginRequestInternal(std::move(new_request), std::move(handler),
2333 resource_context);
2332 } 2334 }
2333 2335
2334 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { 2336 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2335 if (!async_revalidation_manager_) 2337 if (!async_revalidation_manager_)
2336 async_revalidation_manager_.reset(new AsyncRevalidationManager); 2338 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2337 } 2339 }
2338 2340
2339 // static 2341 // static
2340 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2342 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2341 net::URLRequest* request) { 2343 net::URLRequest* request) {
2342 // The following fields should be a minor size contribution (experimentally 2344 // The following fields should be a minor size contribution (experimentally
2343 // on the order of 100). However since they are variable length, it could 2345 // on the order of 100). However since they are variable length, it could
2344 // in theory be a sizeable contribution. 2346 // in theory be a sizeable contribution.
2345 int strings_cost = request->extra_request_headers().ToString().size() + 2347 int strings_cost = request->extra_request_headers().ToString().size() +
2346 request->original_url().spec().size() + 2348 request->original_url().spec().size() +
2347 request->referrer().size() + 2349 request->referrer().size() +
2348 request->method().size(); 2350 request->method().size();
2349 2351
2350 // Note that this expression will typically be dominated by: 2352 // Note that this expression will typically be dominated by:
2351 // |kAvgBytesPerOutstandingRequest|. 2353 // |kAvgBytesPerOutstandingRequest|.
2352 return kAvgBytesPerOutstandingRequest + strings_cost; 2354 return kAvgBytesPerOutstandingRequest + strings_cost;
2353 } 2355 }
2354 2356
2355 void ResourceDispatcherHostImpl::BeginRequestInternal( 2357 void ResourceDispatcherHostImpl::BeginRequestInternal(
2356 scoped_ptr<net::URLRequest> request, 2358 scoped_ptr<net::URLRequest> request,
2357 scoped_ptr<ResourceHandler> handler) { 2359 scoped_ptr<ResourceHandler> handler,
2360 ResourceContext* resource_context) {
2358 DCHECK(!request->is_pending()); 2361 DCHECK(!request->is_pending());
2359 ResourceRequestInfoImpl* info = 2362 ResourceRequestInfoImpl* info =
2360 ResourceRequestInfoImpl::ForRequest(request.get()); 2363 ResourceRequestInfoImpl::ForRequest(request.get());
2361 2364
2362 if ((TimeTicks::Now() - last_user_gesture_time_) < 2365 if ((TimeTicks::Now() - last_user_gesture_time_) <
2363 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 2366 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
2364 request->SetLoadFlags( 2367 request->SetLoadFlags(
2365 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 2368 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
2366 } 2369 }
2367 2370
(...skipping 16 matching lines...) Expand all
2384 } 2387 }
2385 2388
2386 IncrementOutstandingRequestsMemory(-1, *info); 2389 IncrementOutstandingRequestsMemory(-1, *info);
2387 2390
2388 // A ResourceHandler must not outlive its associated URLRequest. 2391 // A ResourceHandler must not outlive its associated URLRequest.
2389 handler.reset(); 2392 handler.reset();
2390 return; 2393 return;
2391 } 2394 }
2392 2395
2393 scoped_ptr<ResourceLoader> loader( 2396 scoped_ptr<ResourceLoader> loader(
2394 new ResourceLoader(std::move(request), std::move(handler), this)); 2397 new ResourceLoader(std::move(request), std::move(handler), this,
2398 delegate_, resource_context));
2395 2399
2396 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID()); 2400 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID());
2397 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); 2401 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id);
2398 if (iter != blocked_loaders_map_.end()) { 2402 if (iter != blocked_loaders_map_.end()) {
2399 // The request should be blocked. 2403 // The request should be blocked.
2400 iter->second->push_back(std::move(loader)); 2404 iter->second->push_back(std::move(loader));
2401 return; 2405 return;
2402 } 2406 }
2403 2407
2404 StartLoading(info, std::move(loader)); 2408 StartLoading(info, std::move(loader));
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 load_flags |= net::LOAD_PREFETCH; 2654 load_flags |= net::LOAD_PREFETCH;
2651 } 2655 }
2652 2656
2653 if (is_sync_load) 2657 if (is_sync_load)
2654 load_flags |= net::LOAD_IGNORE_LIMITS; 2658 load_flags |= net::LOAD_IGNORE_LIMITS;
2655 2659
2656 return load_flags; 2660 return load_flags;
2657 } 2661 }
2658 2662
2659 } // namespace content 2663 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698