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

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

Issue 2108643004: Remove use of WebContentsImpl from ResourceDispatcherHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-try-3
Patch Set: fixes Created 4 years, 5 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 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "content/browser/loader/sync_resource_handler.h" 62 #include "content/browser/loader/sync_resource_handler.h"
63 #include "content/browser/loader/throttling_resource_handler.h" 63 #include "content/browser/loader/throttling_resource_handler.h"
64 #include "content/browser/loader/upload_data_stream_builder.h" 64 #include "content/browser/loader/upload_data_stream_builder.h"
65 #include "content/browser/resource_context_impl.h" 65 #include "content/browser/resource_context_impl.h"
66 #include "content/browser/service_worker/foreign_fetch_request_handler.h" 66 #include "content/browser/service_worker/foreign_fetch_request_handler.h"
67 #include "content/browser/service_worker/link_header_support.h" 67 #include "content/browser/service_worker/link_header_support.h"
68 #include "content/browser/service_worker/service_worker_request_handler.h" 68 #include "content/browser/service_worker/service_worker_request_handler.h"
69 #include "content/browser/streams/stream.h" 69 #include "content/browser/streams/stream.h"
70 #include "content/browser/streams/stream_context.h" 70 #include "content/browser/streams/stream_context.h"
71 #include "content/browser/streams/stream_registry.h" 71 #include "content/browser/streams/stream_registry.h"
72 #include "content/browser/web_contents/web_contents_impl.h"
73 #include "content/common/navigation_params.h" 72 #include "content/common/navigation_params.h"
74 #include "content/common/net/url_request_service_worker_data.h" 73 #include "content/common/net/url_request_service_worker_data.h"
75 #include "content/common/resource_messages.h" 74 #include "content/common/resource_messages.h"
76 #include "content/common/resource_request.h" 75 #include "content/common/resource_request.h"
77 #include "content/common/resource_request_body_impl.h" 76 #include "content/common/resource_request_body_impl.h"
78 #include "content/common/resource_request_completion_status.h" 77 #include "content/common/resource_request_completion_status.h"
79 #include "content/common/site_isolation_policy.h" 78 #include "content/common/site_isolation_policy.h"
80 #include "content/common/ssl_status_serialization.h" 79 #include "content/common/ssl_status_serialization.h"
81 #include "content/common/view_messages.h" 80 #include "content/common/view_messages.h"
82 #include "content/public/browser/browser_thread.h" 81 #include "content/public/browser/browser_thread.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeAllPermissionsForFile( 355 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeAllPermissionsForFile(
357 child_id, path); 356 child_id, path);
358 } 357 }
359 358
360 int GetCertID(CertStore* cert_store, net::URLRequest* request, int child_id) { 359 int GetCertID(CertStore* cert_store, net::URLRequest* request, int child_id) {
361 if (request->ssl_info().cert.get()) 360 if (request->ssl_info().cert.get())
362 return cert_store->StoreCert(request->ssl_info().cert.get(), child_id); 361 return cert_store->StoreCert(request->ssl_info().cert.get(), child_id);
363 return 0; 362 return 0;
364 } 363 }
365 364
366 void NotifyRedirectOnUI(int render_process_id,
367 int render_frame_host,
368 std::unique_ptr<ResourceRedirectDetails> details) {
369 RenderFrameHostImpl* host =
370 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
371 WebContentsImpl* web_contents =
372 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
373 if (!web_contents)
374 return;
375 web_contents->DidGetRedirectForResourceRequest(host, *details.get());
376 }
377
378 void NotifyResponseOnUI(int render_process_id,
379 int render_frame_host,
380 std::unique_ptr<ResourceRequestDetails> details) {
381 RenderFrameHostImpl* host =
382 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
383 WebContentsImpl* web_contents =
384 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
385 if (!web_contents)
386 return;
387 web_contents->DidGetResourceResponseStart(*details.get());
388 }
389
390 bool IsValidatedSCT( 365 bool IsValidatedSCT(
391 const net::SignedCertificateTimestampAndStatus& sct_status) { 366 const net::SignedCertificateTimestampAndStatus& sct_status) {
392 return sct_status.status == net::ct::SCT_STATUS_OK; 367 return sct_status.status == net::ct::SCT_STATUS_OK;
393 } 368 }
394 369
395 storage::BlobStorageContext* GetBlobStorageContext( 370 storage::BlobStorageContext* GetBlobStorageContext(
396 ChromeBlobStorageContext* blob_storage_context) { 371 ChromeBlobStorageContext* blob_storage_context) {
397 if (!blob_storage_context) 372 if (!blob_storage_context)
398 return NULL; 373 return NULL;
399 return blob_storage_context->context(); 374 return blob_storage_context->context();
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 // downloads; they aren't really associated with the Webcontents. 911 // downloads; they aren't really associated with the Webcontents.
937 // Note that not all downloads are known before content sniffing. 912 // Note that not all downloads are known before content sniffing.
938 if (info->IsDownload()) 913 if (info->IsDownload())
939 return; 914 return;
940 915
941 // Notify the observers on the UI thread. 916 // Notify the observers on the UI thread.
942 std::unique_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( 917 std::unique_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails(
943 loader->request(), 918 loader->request(),
944 GetCertID(GetCertStore(), loader->request(), info->GetChildID()), 919 GetCertID(GetCertStore(), loader->request(), info->GetChildID()),
945 new_url)); 920 new_url));
946 BrowserThread::PostTask( 921 loader_delegate_->DidGetRedirectForResourceRequest(
947 BrowserThread::UI, FROM_HERE, 922 render_process_id, render_frame_host, std::move(detail));
948 base::Bind(
949 &NotifyRedirectOnUI,
950 render_process_id, render_frame_host, base::Passed(&detail)));
951 } 923 }
952 924
953 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { 925 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
954 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 926 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
955 net::URLRequest* request = loader->request(); 927 net::URLRequest* request = loader->request();
956 if (request->was_fetched_via_proxy() && 928 if (request->was_fetched_via_proxy() &&
957 request->was_fetched_via_spdy() && 929 request->was_fetched_via_spdy() &&
958 request->url().SchemeIs(url::kHttpScheme)) { 930 request->url().SchemeIs(url::kHttpScheme)) {
959 scheduler_->OnReceivedSpdyProxiedHttpResponse( 931 scheduler_->OnReceivedSpdyProxiedHttpResponse(
960 info->GetChildID(), info->GetRouteID()); 932 info->GetChildID(), info->GetRouteID());
(...skipping 13 matching lines...) Expand all
974 946
975 // Don't notify WebContents observers for requests known to be 947 // Don't notify WebContents observers for requests known to be
976 // downloads; they aren't really associated with the Webcontents. 948 // downloads; they aren't really associated with the Webcontents.
977 // Note that not all downloads are known before content sniffing. 949 // Note that not all downloads are known before content sniffing.
978 if (info->IsDownload()) 950 if (info->IsDownload())
979 return; 951 return;
980 952
981 // Notify the observers on the UI thread. 953 // Notify the observers on the UI thread.
982 std::unique_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( 954 std::unique_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails(
983 request, GetCertID(GetCertStore(), request, info->GetChildID()))); 955 request, GetCertID(GetCertStore(), request, info->GetChildID())));
984 BrowserThread::PostTask( 956 loader_delegate_->DidGetResourceResponseStart(
985 BrowserThread::UI, FROM_HERE, 957 render_process_id, render_frame_host, std::move(detail));
986 base::Bind(
987 &NotifyResponseOnUI,
988 render_process_id, render_frame_host, base::Passed(&detail)));
989 } 958 }
990 959
991 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) { 960 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) {
992 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 961 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
993 962
994 // Record final result of all resource loads. 963 // Record final result of all resource loads.
995 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) { 964 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) {
996 // This enumeration has "3" appended to its name to distinguish it from 965 // This enumeration has "3" appended to its name to distinguish it from
997 // older versions. 966 // older versions.
998 UMA_HISTOGRAM_SPARSE_SLOWLY( 967 UMA_HISTOGRAM_SPARSE_SLOWLY(
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 tracked_objects::ScopedTracker tracking_profile( 2360 tracked_objects::ScopedTracker tracking_profile(
2392 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2361 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2393 "456331 ResourceDispatcherHostImpl::StartLoading")); 2362 "456331 ResourceDispatcherHostImpl::StartLoading"));
2394 2363
2395 ResourceLoader* loader_ptr = loader.get(); 2364 ResourceLoader* loader_ptr = loader.get();
2396 pending_loaders_[info->GetGlobalRequestID()] = std::move(loader); 2365 pending_loaders_[info->GetGlobalRequestID()] = std::move(loader);
2397 2366
2398 loader_ptr->StartRequest(); 2367 loader_ptr->StartRequest();
2399 } 2368 }
2400 2369
2401 void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) { 2370 void ResourceDispatcherHostImpl::OnUserGesture() {
2402 last_user_gesture_time_ = TimeTicks::Now(); 2371 last_user_gesture_time_ = TimeTicks::Now();
2403 } 2372 }
2404 2373
2405 net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest( 2374 net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest(
2406 const GlobalRequestID& id) { 2375 const GlobalRequestID& id) {
2407 ResourceLoader* loader = GetLoader(id); 2376 ResourceLoader* loader = GetLoader(id);
2408 if (!loader) 2377 if (!loader)
2409 return NULL; 2378 return NULL;
2410 2379
2411 return loader->request(); 2380 return loader->request();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); 2605 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id);
2637 response->head.security_info = SerializeSecurityInfo(ssl); 2606 response->head.security_info = SerializeSecurityInfo(ssl);
2638 } 2607 }
2639 2608
2640 CertStore* ResourceDispatcherHostImpl::GetCertStore() { 2609 CertStore* ResourceDispatcherHostImpl::GetCertStore() {
2641 return cert_store_for_testing_ ? cert_store_for_testing_ 2610 return cert_store_for_testing_ ? cert_store_for_testing_
2642 : CertStore::GetInstance(); 2611 : CertStore::GetInstance();
2643 } 2612 }
2644 2613
2645 } // namespace content 2614 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698