| OLD | NEW |
| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 26 #include "content/browser/appcache/appcache_interceptor.h" | 26 #include "content/browser/appcache/appcache_interceptor.h" |
| 27 #include "content/browser/appcache/chrome_appcache_service.h" | 27 #include "content/browser/appcache/chrome_appcache_service.h" |
| 28 #include "content/browser/cert_store_impl.h" | 28 #include "content/browser/cert_store_impl.h" |
| 29 #include "content/browser/child_process_security_policy_impl.h" | 29 #include "content/browser/child_process_security_policy_impl.h" |
| 30 #include "content/browser/download/download_resource_handler.h" | 30 #include "content/browser/download/download_resource_handler.h" |
| 31 #include "content/browser/download/save_file_manager.h" | 31 #include "content/browser/download/save_file_manager.h" |
| 32 #include "content/browser/download/save_file_resource_handler.h" | 32 #include "content/browser/download/save_file_resource_handler.h" |
| 33 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 33 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 34 #include "content/browser/frame_host/navigation_request_info.h" | 34 #include "content/browser/frame_host/navigation_request_info.h" |
| 35 #include "content/browser/frame_host/navigator.h" |
| 35 #include "content/browser/loader/async_resource_handler.h" | 36 #include "content/browser/loader/async_resource_handler.h" |
| 36 #include "content/browser/loader/buffered_resource_handler.h" | 37 #include "content/browser/loader/buffered_resource_handler.h" |
| 37 #include "content/browser/loader/cross_site_resource_handler.h" | 38 #include "content/browser/loader/cross_site_resource_handler.h" |
| 38 #include "content/browser/loader/detachable_resource_handler.h" | 39 #include "content/browser/loader/detachable_resource_handler.h" |
| 39 #include "content/browser/loader/power_save_block_resource_throttle.h" | 40 #include "content/browser/loader/power_save_block_resource_throttle.h" |
| 40 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 41 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
| 41 #include "content/browser/loader/resource_message_filter.h" | 42 #include "content/browser/loader/resource_message_filter.h" |
| 42 #include "content/browser/loader/resource_request_info_impl.h" | 43 #include "content/browser/loader/resource_request_info_impl.h" |
| 43 #include "content/browser/loader/stream_resource_handler.h" | 44 #include "content/browser/loader/stream_resource_handler.h" |
| 44 #include "content/browser/loader/sync_resource_handler.h" | 45 #include "content/browser/loader/sync_resource_handler.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 DCHECK(handle); | 377 DCHECK(handle); |
| 377 if (!handle) | 378 if (!handle) |
| 378 continue; | 379 continue; |
| 379 // Ensure the blob and any attached shareable files survive until | 380 // Ensure the blob and any attached shareable files survive until |
| 380 // upload completion. The |body| takes ownership of |handle|. | 381 // upload completion. The |body| takes ownership of |handle|. |
| 381 const void* key = handle.get(); | 382 const void* key = handle.get(); |
| 382 body->SetUserData(key, handle.release()); | 383 body->SetUserData(key, handle.release()); |
| 383 } | 384 } |
| 384 } | 385 } |
| 385 | 386 |
| 387 // PlzNavigate |
| 388 // This method is called in the UI thread to send the timestamp of a resource |
| 389 // request to the respective Navigator (for an UMA histogram). |
| 390 void LogResourceRequestTimeOnUI( |
| 391 base::TimeTicks timestamp, |
| 392 int render_process_id, |
| 393 int render_frame_id, |
| 394 const GURL& url) { |
| 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 396 RenderFrameHostImpl* host = |
| 397 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
| 398 if (host != NULL) { |
| 399 DCHECK(host->frame_tree_node()->IsMainFrame()); |
| 400 host->frame_tree_node()->navigator()->LogResourceRequestTime( |
| 401 timestamp, url); |
| 402 } |
| 403 } |
| 404 |
| 386 } // namespace | 405 } // namespace |
| 387 | 406 |
| 388 // static | 407 // static |
| 389 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 408 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
| 390 return g_resource_dispatcher_host; | 409 return g_resource_dispatcher_host; |
| 391 } | 410 } |
| 392 | 411 |
| 393 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 412 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
| 394 : save_file_manager_(new SaveFileManager()), | 413 : save_file_manager_(new SaveFileManager()), |
| 395 request_id_(-1), | 414 request_id_(-1), |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 } | 959 } |
| 941 | 960 |
| 942 filter_ = NULL; | 961 filter_ = NULL; |
| 943 return handled; | 962 return handled; |
| 944 } | 963 } |
| 945 | 964 |
| 946 void ResourceDispatcherHostImpl::OnRequestResource( | 965 void ResourceDispatcherHostImpl::OnRequestResource( |
| 947 int routing_id, | 966 int routing_id, |
| 948 int request_id, | 967 int request_id, |
| 949 const ResourceHostMsg_Request& request_data) { | 968 const ResourceHostMsg_Request& request_data) { |
| 969 // When logging time-to-network only care about main frame and non-transfer |
| 970 // navigations. |
| 971 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && |
| 972 request_data.transferred_request_request_id == -1) { |
| 973 BrowserThread::PostTask( |
| 974 BrowserThread::UI, |
| 975 FROM_HERE, |
| 976 base::Bind(&LogResourceRequestTimeOnUI, |
| 977 TimeTicks::Now(), |
| 978 filter_->child_id(), |
| 979 request_data.render_frame_id, |
| 980 request_data.url)); |
| 981 } |
| 950 BeginRequest(request_id, request_data, NULL, routing_id); | 982 BeginRequest(request_id, request_data, NULL, routing_id); |
| 951 } | 983 } |
| 952 | 984 |
| 953 // Begins a resource request with the given params on behalf of the specified | 985 // Begins a resource request with the given params on behalf of the specified |
| 954 // child process. Responses will be dispatched through the given receiver. The | 986 // child process. Responses will be dispatched through the given receiver. The |
| 955 // process ID is used to lookup WebContentsImpl from routing_id's in the case of | 987 // process ID is used to lookup WebContentsImpl from routing_id's in the case of |
| 956 // a request from a renderer. request_context is the cookie/cache context to be | 988 // a request from a renderer. request_context is the cookie/cache context to be |
| 957 // used for this request. | 989 // used for this request. |
| 958 // | 990 // |
| 959 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 991 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 | 2142 |
| 2111 // Add a flag to selectively bypass the data reduction proxy if the resource | 2143 // Add a flag to selectively bypass the data reduction proxy if the resource |
| 2112 // type is not an image. | 2144 // type is not an image. |
| 2113 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2145 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
| 2114 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2146 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
| 2115 | 2147 |
| 2116 return load_flags; | 2148 return load_flags; |
| 2117 } | 2149 } |
| 2118 | 2150 |
| 2119 } // namespace content | 2151 } // namespace content |
| OLD | NEW |