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

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: Changing lifetime of NavigationSupportsUserData for Draft 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 23 matching lines...) Expand all
34 #include "content/browser/appcache/appcache_interceptor.h" 34 #include "content/browser/appcache/appcache_interceptor.h"
35 #include "content/browser/appcache/chrome_appcache_service.h" 35 #include "content/browser/appcache/chrome_appcache_service.h"
36 #include "content/browser/bad_message.h" 36 #include "content/browser/bad_message.h"
37 #include "content/browser/cert_store_impl.h" 37 #include "content/browser/cert_store_impl.h"
38 #include "content/browser/child_process_security_policy_impl.h" 38 #include "content/browser/child_process_security_policy_impl.h"
39 #include "content/browser/download/download_resource_handler.h" 39 #include "content/browser/download/download_resource_handler.h"
40 #include "content/browser/download/save_file_manager.h" 40 #include "content/browser/download/save_file_manager.h"
41 #include "content/browser/download/save_file_resource_handler.h" 41 #include "content/browser/download/save_file_resource_handler.h"
42 #include "content/browser/fileapi/chrome_blob_storage_context.h" 42 #include "content/browser/fileapi/chrome_blob_storage_context.h"
43 #include "content/browser/frame_host/frame_tree.h" 43 #include "content/browser/frame_host/frame_tree.h"
44 #include "content/browser/frame_host/navigation_handle_impl.h"
44 #include "content/browser/frame_host/navigation_request_info.h" 45 #include "content/browser/frame_host/navigation_request_info.h"
46 #include "content/browser/frame_host/navigation_user_data.h"
45 #include "content/browser/frame_host/navigator.h" 47 #include "content/browser/frame_host/navigator.h"
46 #include "content/browser/loader/async_resource_handler.h" 48 #include "content/browser/loader/async_resource_handler.h"
47 #include "content/browser/loader/async_revalidation_manager.h" 49 #include "content/browser/loader/async_revalidation_manager.h"
48 #include "content/browser/loader/cross_site_resource_handler.h" 50 #include "content/browser/loader/cross_site_resource_handler.h"
49 #include "content/browser/loader/detachable_resource_handler.h" 51 #include "content/browser/loader/detachable_resource_handler.h"
50 #include "content/browser/loader/mime_type_resource_handler.h" 52 #include "content/browser/loader/mime_type_resource_handler.h"
51 #include "content/browser/loader/navigation_resource_handler.h" 53 #include "content/browser/loader/navigation_resource_handler.h"
52 #include "content/browser/loader/navigation_resource_throttle.h" 54 #include "content/browser/loader/navigation_resource_throttle.h"
53 #include "content/browser/loader/navigation_url_loader_impl_core.h" 55 #include "content/browser/loader/navigation_url_loader_impl_core.h"
54 #include "content/browser/loader/power_save_block_resource_throttle.h" 56 #include "content/browser/loader/power_save_block_resource_throttle.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 scoped_ptr<ResourceRedirectDetails> details) { 369 scoped_ptr<ResourceRedirectDetails> details) {
368 RenderFrameHostImpl* host = 370 RenderFrameHostImpl* host =
369 RenderFrameHostImpl::FromID(render_process_id, render_frame_host); 371 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
370 WebContentsImpl* web_contents = 372 WebContentsImpl* web_contents =
371 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host)); 373 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
372 if (!web_contents) 374 if (!web_contents)
373 return; 375 return;
374 web_contents->DidGetRedirectForResourceRequest(host, *details.get()); 376 web_contents->DidGetRedirectForResourceRequest(host, *details.get());
375 } 377 }
376 378
377 void NotifyResponseOnUI(int render_process_id, 379 void NotifyResponseOnUI(
378 int render_frame_host, 380 int render_process_id,
379 scoped_ptr<ResourceRequestDetails> details) { 381 int render_frame_host,
382 scoped_ptr<ResourceRequestDetails> details,
383 scoped_ptr<NavigationSupportsUserData> navigation_supports_user_data) {
380 RenderFrameHostImpl* host = 384 RenderFrameHostImpl* host =
381 RenderFrameHostImpl::FromID(render_process_id, render_frame_host); 385 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
386 if (navigation_supports_user_data.get()) {
387 // Change what thread owns |navigation_supports_user_data|.
388 navigation_supports_user_data->DetachUserDataThread();
389 host->navigation_handle()->SetNavigationSupportsUserData(
390 std::move(navigation_supports_user_data));
391 }
382 WebContentsImpl* web_contents = 392 WebContentsImpl* web_contents =
383 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host)); 393 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
384 if (!web_contents) 394 if (!web_contents)
385 return; 395 return;
386 web_contents->DidGetResourceResponseStart(*details.get()); 396 web_contents->DidGetResourceResponseStart(*details.get());
387 } 397 }
388 398
389 bool IsValidatedSCT( 399 bool IsValidatedSCT(
390 const net::SignedCertificateTimestampAndStatus& sct_status) { 400 const net::SignedCertificateTimestampAndStatus& sct_status) {
391 return sct_status.status == net::ct::SCT_STATUS_OK; 401 return sct_status.status == net::ct::SCT_STATUS_OK;
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1011
1002 int render_process_id, render_frame_host; 1012 int render_process_id, render_frame_host;
1003 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) 1013 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host))
1004 return; 1014 return;
1005 1015
1006 // Don't notify WebContents observers for requests known to be 1016 // Don't notify WebContents observers for requests known to be
1007 // downloads; they aren't really associated with the Webcontents. 1017 // downloads; they aren't really associated with the Webcontents.
1008 // Note that not all downloads are known before content sniffing. 1018 // Note that not all downloads are known before content sniffing.
1009 if (info->IsDownload()) 1019 if (info->IsDownload())
1010 return; 1020 return;
1011
1012 // Notify the observers on the UI thread. 1021 // Notify the observers on the UI thread.
1013 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( 1022 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails(
1014 request, GetCertID(request, info->GetChildID()))); 1023 request, GetCertID(request, info->GetChildID())));
1024
1025 NavigationUserData* navigation_user_data = static_cast<NavigationUserData*>(
1026 request->GetUserData(kNavigationUserDataKey));
1027 scoped_ptr<NavigationSupportsUserData> navigation_supports_user_data(nullptr);
1028 if (navigation_user_data) {
1029 navigation_supports_user_data =
1030 navigation_user_data->take_own_navigation_supports_user_data();
1031 request->RemoveUserData(kNavigationUserDataKey);
1032 }
1033
1015 BrowserThread::PostTask( 1034 BrowserThread::PostTask(
1016 BrowserThread::UI, FROM_HERE, 1035 BrowserThread::UI, FROM_HERE,
1017 base::Bind( 1036 base::Bind(&NotifyResponseOnUI, render_process_id, render_frame_host,
1018 &NotifyResponseOnUI, 1037 base::Passed(&detail),
1019 render_process_id, render_frame_host, base::Passed(&detail))); 1038 base::Passed(&navigation_supports_user_data)));
1020 } 1039 }
1021 1040
1022 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) { 1041 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) {
1023 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 1042 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
1024 1043
1025 // Record final result of all resource loads. 1044 // Record final result of all resource loads.
1026 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) { 1045 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) {
1027 // This enumeration has "3" appended to its name to distinguish it from 1046 // This enumeration has "3" appended to its name to distinguish it from
1028 // older versions. 1047 // older versions.
1029 UMA_HISTOGRAM_SPARSE_SLOWLY( 1048 UMA_HISTOGRAM_SPARSE_SLOWLY(
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 new_request.get(), filter_->appcache_service(), child_id, 1633 new_request.get(), filter_->appcache_service(), child_id,
1615 request_data.appcache_host_id, request_data.resource_type, 1634 request_data.appcache_host_id, request_data.resource_type,
1616 request_data.should_reset_appcache); 1635 request_data.should_reset_appcache);
1617 1636
1618 scoped_ptr<ResourceHandler> handler( 1637 scoped_ptr<ResourceHandler> handler(
1619 CreateResourceHandler( 1638 CreateResourceHandler(
1620 new_request.get(), 1639 new_request.get(),
1621 request_data, sync_result, route_id, process_type, child_id, 1640 request_data, sync_result, route_id, process_type, child_id,
1622 resource_context)); 1641 resource_context));
1623 1642
1643 if (IsResourceTypeFrame(request_data.resource_type)) {
1644 new_request->SetUserData(kNavigationUserDataKey, new NavigationUserData());
1645 }
1646
1624 if (handler) 1647 if (handler)
1625 BeginRequestInternal(std::move(new_request), std::move(handler)); 1648 BeginRequestInternal(std::move(new_request), std::move(handler));
1626 } 1649 }
1627 1650
1628 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1651 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1629 net::URLRequest* request, 1652 net::URLRequest* request,
1630 const ResourceHostMsg_Request& request_data, 1653 const ResourceHostMsg_Request& request_data,
1631 IPC::Message* sync_result, 1654 IPC::Message* sync_result,
1632 int route_id, 1655 int route_id,
1633 int process_type, 1656 int process_type,
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2347 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2325 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2348 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2326 // currently it's a no-op. 2349 // currently it's a no-op.
2327 handler = 2350 handler =
2328 AddStandardHandlers(new_request.get(), resource_type, resource_context, 2351 AddStandardHandlers(new_request.get(), resource_type, resource_context,
2329 nullptr, // appcache_service 2352 nullptr, // appcache_service
2330 -1, // child_id 2353 -1, // child_id
2331 -1, // route_id 2354 -1, // route_id
2332 std::move(handler)); 2355 std::move(handler));
2333 2356
2357 new_request->SetUserData(kNavigationUserDataKey, new NavigationUserData());
2358
2334 BeginRequestInternal(std::move(new_request), std::move(handler)); 2359 BeginRequestInternal(std::move(new_request), std::move(handler));
2335 } 2360 }
2336 2361
2337 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { 2362 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2338 if (!async_revalidation_manager_) 2363 if (!async_revalidation_manager_)
2339 async_revalidation_manager_.reset(new AsyncRevalidationManager); 2364 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2340 } 2365 }
2341 2366
2342 // static 2367 // static
2343 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2368 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 load_flags |= net::LOAD_PREFETCH; 2678 load_flags |= net::LOAD_PREFETCH;
2654 } 2679 }
2655 2680
2656 if (is_sync_load) 2681 if (is_sync_load)
2657 load_flags |= net::LOAD_IGNORE_LIMITS; 2682 load_flags |= net::LOAD_IGNORE_LIMITS;
2658 2683
2659 return load_flags; 2684 return load_flags;
2660 } 2685 }
2661 2686
2662 } // namespace content 2687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698