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

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

Issue 648803002: Fix outstanding request stats for multiple transfer navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug and add test Created 6 years, 2 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
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 const linked_ptr<ResourceLoader>& loader) { 997 const linked_ptr<ResourceLoader>& loader) {
998 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 998 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
999 GlobalRoutingID old_routing_id( 999 GlobalRoutingID old_routing_id(
1000 request_data.transferred_request_child_id, info->GetRouteID()); 1000 request_data.transferred_request_child_id, info->GetRouteID());
1001 GlobalRequestID old_request_id(request_data.transferred_request_child_id, 1001 GlobalRequestID old_request_id(request_data.transferred_request_child_id,
1002 request_data.transferred_request_request_id); 1002 request_data.transferred_request_request_id);
1003 GlobalRoutingID new_routing_id(child_id, route_id); 1003 GlobalRoutingID new_routing_id(child_id, route_id);
1004 GlobalRequestID new_request_id(child_id, request_id); 1004 GlobalRequestID new_request_id(child_id, request_id);
1005 1005
1006 // Clear out data that depends on |info| before updating it. 1006 // Clear out data that depends on |info| before updating it.
1007 IncrementOutstandingRequestsMemory(-1, *info); 1007 // We always need to move the memory stats to the new process. In contrast,
1008 OustandingRequestsStats empty_stats = { 0, 0 }; 1008 // stats.num_requests is only sometimes tracked.
1009 OustandingRequestsStats old_stats = GetOutstandingRequestsStats(*info); 1009 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(-1, *info);
1010 UpdateOutstandingRequestsStats(*info, empty_stats); 1010 bool should_update_count = stats.num_requests > 0;
davidben 2014/10/13 17:40:04 Hrm. Is this the right criteria? OutstandingReques
Charlie Reis 2014/10/14 23:54:12 Oops-- you're totally right. Awkward that we don'
1011 if (should_update_count)
1012 IncrementOutstandingRequestsCount(-1, *info);
1011 pending_loaders_.erase(old_request_id); 1013 pending_loaders_.erase(old_request_id);
1012 1014
1013 // ResourceHandlers should always get state related to the request from the 1015 // ResourceHandlers should always get state related to the request from the
1014 // ResourceRequestInfo rather than caching it locally. This lets us update 1016 // ResourceRequestInfo rather than caching it locally. This lets us update
1015 // the info object when a transfer occurs. 1017 // the info object when a transfer occurs.
1016 info->UpdateForTransfer(child_id, route_id, request_data.origin_pid, 1018 info->UpdateForTransfer(child_id, route_id, request_data.origin_pid,
1017 request_id, request_data.parent_render_frame_id, 1019 request_id, request_data.parent_render_frame_id,
1018 filter_->GetWeakPtr()); 1020 filter_->GetWeakPtr());
1019 1021
1020 // Update maps that used the old IDs, if necessary. Some transfers in tests 1022 // Update maps that used the old IDs, if necessary. Some transfers in tests
1021 // do not actually use a different ID, so not all maps need to be updated. 1023 // do not actually use a different ID, so not all maps need to be updated.
1022 pending_loaders_[new_request_id] = loader; 1024 pending_loaders_[new_request_id] = loader;
1023 UpdateOutstandingRequestsStats(*info, old_stats);
1024 IncrementOutstandingRequestsMemory(1, *info); 1025 IncrementOutstandingRequestsMemory(1, *info);
1026 if (should_update_count)
1027 IncrementOutstandingRequestsCount(1, *info);
1025 if (old_routing_id != new_routing_id) { 1028 if (old_routing_id != new_routing_id) {
1026 if (blocked_loaders_map_.find(old_routing_id) != 1029 if (blocked_loaders_map_.find(old_routing_id) !=
1027 blocked_loaders_map_.end()) { 1030 blocked_loaders_map_.end()) {
1028 blocked_loaders_map_[new_routing_id] = 1031 blocked_loaders_map_[new_routing_id] =
1029 blocked_loaders_map_[old_routing_id]; 1032 blocked_loaders_map_[old_routing_id];
1030 blocked_loaders_map_.erase(old_routing_id); 1033 blocked_loaders_map_.erase(old_routing_id);
1031 } 1034 }
1032 } 1035 }
1033 if (old_request_id != new_request_id) { 1036 if (old_request_id != new_request_id) {
1034 DelegateMap::iterator it = delegate_map_.find(old_request_id); 1037 DelegateMap::iterator it = delegate_map_.find(old_request_id);
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 2152
2150 // Add a flag to selectively bypass the data reduction proxy if the resource 2153 // Add a flag to selectively bypass the data reduction proxy if the resource
2151 // type is not an image. 2154 // type is not an image.
2152 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2155 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2153 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2156 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2154 2157
2155 return load_flags; 2158 return load_flags;
2156 } 2159 }
2157 2160
2158 } // namespace content 2161 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698