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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/debug/alias.h" | 17 #include "base/debug/alias.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/memory/shared_memory.h" | 20 #include "base/memory/shared_memory.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
23 #include "base/metrics/sparse_histogram.h" | 23 #include "base/metrics/sparse_histogram.h" |
24 #include "base/profiler/scoped_tracker.h" | |
24 #include "base/stl_util.h" | 25 #include "base/stl_util.h" |
25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
26 #include "content/browser/appcache/appcache_interceptor.h" | 27 #include "content/browser/appcache/appcache_interceptor.h" |
27 #include "content/browser/appcache/chrome_appcache_service.h" | 28 #include "content/browser/appcache/chrome_appcache_service.h" |
28 #include "content/browser/cert_store_impl.h" | 29 #include "content/browser/cert_store_impl.h" |
29 #include "content/browser/child_process_security_policy_impl.h" | 30 #include "content/browser/child_process_security_policy_impl.h" |
30 #include "content/browser/download/download_resource_handler.h" | 31 #include "content/browser/download/download_resource_handler.h" |
31 #include "content/browser/download/save_file_manager.h" | 32 #include "content/browser/download/save_file_manager.h" |
32 #include "content/browser/download/save_file_resource_handler.h" | 33 #include "content/browser/download/save_file_resource_handler.h" |
33 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 34 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2144 if (view) // The view could be gone at this point. | 2145 if (view) // The view could be gone at this point. |
2145 view->LoadStateChanged(i->second.url, i->second.load_state, | 2146 view->LoadStateChanged(i->second.url, i->second.load_state, |
2146 i->second.upload_position, | 2147 i->second.upload_position, |
2147 i->second.upload_size); | 2148 i->second.upload_size); |
2148 } | 2149 } |
2149 } | 2150 } |
2150 | 2151 |
2151 } // namespace | 2152 } // namespace |
2152 | 2153 |
2153 void ResourceDispatcherHostImpl::UpdateLoadStates() { | 2154 void ResourceDispatcherHostImpl::UpdateLoadStates() { |
2155 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455952 is | |
2156 // fixed. | |
2157 tracked_objects::ScopedTracker tracking_profile1( | |
2158 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2159 "455952 ResourceDispatcherHostImpl::UpdateLoadStates1")); | |
2154 // Populate this map with load state changes, and then send them on to the UI | 2160 // Populate this map with load state changes, and then send them on to the UI |
2155 // thread where they can be passed along to the respective RVHs. | 2161 // thread where they can be passed along to the respective RVHs. |
2156 LoadInfoMap info_map; | 2162 LoadInfoMap info_map; |
2157 | 2163 |
2158 LoaderMap::const_iterator i; | 2164 LoaderMap::const_iterator i; |
2159 | 2165 |
2160 // Determine the largest upload size of all requests | 2166 // Determine the largest upload size of all requests |
2161 // in each View (good chance it's zero). | 2167 // in each View (good chance it's zero). |
2162 std::map<GlobalRoutingID, uint64> largest_upload_size; | 2168 std::map<GlobalRoutingID, uint64> largest_upload_size; |
2163 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { | 2169 { |
2164 net::URLRequest* request = i->second->request(); | 2170 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455952 is |
2165 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 2171 // fixed. |
2166 uint64 upload_size = request->GetUploadProgress().size(); | 2172 tracked_objects::ScopedTracker tracking_profile2( |
2167 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) | 2173 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
vadimt
2015/02/06 01:48:08
Will work, but you don't need curlies. The time in
Peter Kasting
2015/02/06 01:54:54
I didn't want the code at the bottom of the functi
| |
2168 upload_size = 0; | 2174 "455952 ResourceDispatcherHostImpl::UpdateLoadStates2")); |
2169 GlobalRoutingID id(info->GetGlobalRoutingID()); | 2175 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { |
2170 if (upload_size && largest_upload_size[id] < upload_size) | 2176 net::URLRequest* request = i->second->request(); |
2171 largest_upload_size[id] = upload_size; | 2177 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); |
2178 uint64 upload_size = request->GetUploadProgress().size(); | |
2179 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) | |
2180 upload_size = 0; | |
2181 GlobalRoutingID id(info->GetGlobalRoutingID()); | |
2182 if (upload_size && largest_upload_size[id] < upload_size) | |
2183 largest_upload_size[id] = upload_size; | |
2184 } | |
2172 } | 2185 } |
2173 | 2186 |
2174 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { | 2187 { |
2175 net::URLRequest* request = i->second->request(); | 2188 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455952 is |
2176 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 2189 // fixed. |
2177 net::LoadStateWithParam load_state = request->GetLoadState(); | 2190 tracked_objects::ScopedTracker tracking_profile3( |
2178 net::UploadProgress progress = request->GetUploadProgress(); | 2191 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
2192 "455952 ResourceDispatcherHostImpl::UpdateLoadStates3")); | |
2193 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { | |
2194 net::URLRequest* request = i->second->request(); | |
2195 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | |
2196 net::LoadStateWithParam load_state = request->GetLoadState(); | |
2197 net::UploadProgress progress = request->GetUploadProgress(); | |
2179 | 2198 |
2180 // We also poll for upload progress on this timer and send upload | 2199 // We also poll for upload progress on this timer and send upload |
2181 // progress ipc messages to the plugin process. | 2200 // progress ipc messages to the plugin process. |
2182 i->second->ReportUploadProgress(); | 2201 i->second->ReportUploadProgress(); |
2183 | 2202 |
2184 GlobalRoutingID id(info->GetGlobalRoutingID()); | 2203 GlobalRoutingID id(info->GetGlobalRoutingID()); |
2185 | 2204 |
2186 // If a request is uploading data, ignore all other requests so that the | 2205 // If a request is uploading data, ignore all other requests so that the |
2187 // upload progress takes priority for being shown in the status bar. | 2206 // upload progress takes priority for being shown in the status bar. |
2188 if (largest_upload_size.find(id) != largest_upload_size.end() && | 2207 if (largest_upload_size.find(id) != largest_upload_size.end() && |
2189 progress.size() < largest_upload_size[id]) | 2208 progress.size() < largest_upload_size[id]) |
2190 continue; | 2209 continue; |
2191 | 2210 |
2192 net::LoadStateWithParam to_insert = load_state; | 2211 net::LoadStateWithParam to_insert = load_state; |
2193 LoadInfoMap::iterator existing = info_map.find(id); | 2212 LoadInfoMap::iterator existing = info_map.find(id); |
2194 if (existing != info_map.end()) { | 2213 if (existing != info_map.end()) { |
2195 to_insert = | 2214 to_insert = |
2196 MoreInterestingLoadState(existing->second.load_state, load_state); | 2215 MoreInterestingLoadState(existing->second.load_state, load_state); |
2197 if (to_insert.state == existing->second.load_state.state) | 2216 if (to_insert.state == existing->second.load_state.state) |
2198 continue; | 2217 continue; |
2218 } | |
2219 LoadInfo& load_info = info_map[id]; | |
2220 load_info.url = request->url(); | |
2221 load_info.load_state = to_insert; | |
2222 load_info.upload_size = progress.size(); | |
2223 load_info.upload_position = progress.position(); | |
2199 } | 2224 } |
2200 LoadInfo& load_info = info_map[id]; | |
2201 load_info.url = request->url(); | |
2202 load_info.load_state = to_insert; | |
2203 load_info.upload_size = progress.size(); | |
2204 load_info.upload_position = progress.position(); | |
2205 } | 2225 } |
2206 | 2226 |
2207 if (info_map.empty()) | 2227 if (info_map.empty()) |
2208 return; | 2228 return; |
2209 | 2229 |
2210 BrowserThread::PostTask( | 2230 BrowserThread::PostTask( |
2211 BrowserThread::UI, FROM_HERE, | 2231 BrowserThread::UI, FROM_HERE, |
2212 base::Bind(&LoadInfoUpdateCallback, info_map)); | 2232 base::Bind(&LoadInfoUpdateCallback, info_map)); |
2213 } | 2233 } |
2214 | 2234 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2368 | 2388 |
2369 // Add a flag to selectively bypass the data reduction proxy if the resource | 2389 // Add a flag to selectively bypass the data reduction proxy if the resource |
2370 // type is not an image. | 2390 // type is not an image. |
2371 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2391 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2372 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2392 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2373 | 2393 |
2374 return load_flags; | 2394 return load_flags; |
2375 } | 2395 } |
2376 | 2396 |
2377 } // namespace content | 2397 } // namespace content |
OLD | NEW |