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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 DCHECK(handle); | 323 DCHECK(handle); |
323 if (!handle) | 324 if (!handle) |
324 continue; | 325 continue; |
325 // Ensure the blob and any attached shareable files survive until | 326 // Ensure the blob and any attached shareable files survive until |
326 // upload completion. The |body| takes ownership of |handle|. | 327 // upload completion. The |body| takes ownership of |handle|. |
327 const void* key = handle.get(); | 328 const void* key = handle.get(); |
328 body->SetUserData(key, handle.release()); | 329 body->SetUserData(key, handle.release()); |
329 } | 330 } |
330 } | 331 } |
331 | 332 |
| 333 // PlzNavigate |
| 334 // This method is called in the UI thread to send the timestamp of a resource |
| 335 // request to the respective NavigatorImpl (for an UMA histogram). |
| 336 void LogResourceRequestTimeOnUI( |
| 337 base::TimeTicks timestamp, int render_process_id, int render_frame_host) { |
| 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 339 RenderFrameHostImpl* host = |
| 340 RenderFrameHostImpl::FromID(render_process_id, render_frame_host); |
| 341 if (host != NULL) { |
| 342 DCHECK(host->frame_tree_node()->IsMainFrame()); |
| 343 LOG(WARNING) << "$$$$$$$$$$$$$$$"; |
| 344 LOG(WARNING) << "Found RenderFrameHostImpl"; |
| 345 LOG(WARNING) << "process_id / child_id = " << render_process_id; |
| 346 LOG(WARNING) << "routing_id / render_frame_host = " << render_frame_host; |
| 347 content::Navigator* navigator = host->frame_tree_node()->navigator(); |
| 348 navigator->LogResourceRequestTime(timestamp); |
| 349 } |
| 350 } |
| 351 |
332 } // namespace | 352 } // namespace |
333 | 353 |
334 // static | 354 // static |
335 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 355 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
336 return g_resource_dispatcher_host; | 356 return g_resource_dispatcher_host; |
337 } | 357 } |
338 | 358 |
339 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 359 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
340 : save_file_manager_(new SaveFileManager()), | 360 : save_file_manager_(new SaveFileManager()), |
341 request_id_(-1), | 361 request_id_(-1), |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 901 } |
882 | 902 |
883 filter_ = NULL; | 903 filter_ = NULL; |
884 return handled; | 904 return handled; |
885 } | 905 } |
886 | 906 |
887 void ResourceDispatcherHostImpl::OnRequestResource( | 907 void ResourceDispatcherHostImpl::OnRequestResource( |
888 int routing_id, | 908 int routing_id, |
889 int request_id, | 909 int request_id, |
890 const ResourceHostMsg_Request& request_data) { | 910 const ResourceHostMsg_Request& request_data) { |
| 911 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
| 912 int child_id = filter_->child_id(); |
| 913 BrowserThread::PostTask( |
| 914 BrowserThread::UI, |
| 915 FROM_HERE, |
| 916 base::Bind(&LogResourceRequestTimeOnUI, |
| 917 TimeTicks::Now(), child_id, request_data.render_frame_id)); |
| 918 } |
891 BeginRequest(request_id, request_data, NULL, routing_id); | 919 BeginRequest(request_id, request_data, NULL, routing_id); |
892 } | 920 } |
893 | 921 |
894 // Begins a resource request with the given params on behalf of the specified | 922 // Begins a resource request with the given params on behalf of the specified |
895 // child process. Responses will be dispatched through the given receiver. The | 923 // child process. Responses will be dispatched through the given receiver. The |
896 // process ID is used to lookup WebContentsImpl from routing_id's in the case of | 924 // process ID is used to lookup WebContentsImpl from routing_id's in the case of |
897 // a request from a renderer. request_context is the cookie/cache context to be | 925 // a request from a renderer. request_context is the cookie/cache context to be |
898 // used for this request. | 926 // used for this request. |
899 // | 927 // |
900 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 928 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 | 2077 |
2050 // Add a flag to selectively bypass the data reduction proxy if the resource | 2078 // Add a flag to selectively bypass the data reduction proxy if the resource |
2051 // type is not an image. | 2079 // type is not an image. |
2052 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2080 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2053 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2081 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2054 | 2082 |
2055 return load_flags; | 2083 return load_flags; |
2056 } | 2084 } |
2057 | 2085 |
2058 } // namespace content | 2086 } // namespace content |
OLD | NEW |