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

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

Powered by Google App Engine
This is Rietveld 408576698