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

Unified 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: Track count on request info 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index a1cb1f1c15e8c7a0499e157d2e19c6ae16234193..502f15c6b8890ba722b1574782cf70f107d00b7a 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1004,10 +1004,13 @@ void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
GlobalRequestID new_request_id(child_id, request_id);
// Clear out data that depends on |info| before updating it.
+ // We always need to move the memory stats to the new process. In contrast,
+ // stats.num_requests is only tracked for some requests (those that require
+ // file descriptors for their shared memory buffer).
IncrementOutstandingRequestsMemory(-1, *info);
- OustandingRequestsStats empty_stats = { 0, 0 };
- OustandingRequestsStats old_stats = GetOutstandingRequestsStats(*info);
- UpdateOutstandingRequestsStats(*info, empty_stats);
+ bool should_update_count = info->counted_as_in_flight_request();
+ if (should_update_count)
+ IncrementOutstandingRequestsCount(-1, *info);
pending_loaders_.erase(old_request_id);
// ResourceHandlers should always get state related to the request from the
@@ -1020,8 +1023,9 @@ void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
// Update maps that used the old IDs, if necessary. Some transfers in tests
// do not actually use a different ID, so not all maps need to be updated.
pending_loaders_[new_request_id] = loader;
- UpdateOutstandingRequestsStats(*info, old_stats);
IncrementOutstandingRequestsMemory(1, *info);
+ if (should_update_count)
+ IncrementOutstandingRequestsCount(1, *info);
if (old_routing_id != new_routing_id) {
if (blocked_loaders_map_.find(old_routing_id) !=
blocked_loaders_map_.end()) {
@@ -1727,10 +1731,16 @@ ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemory(
ResourceDispatcherHostImpl::OustandingRequestsStats
ResourceDispatcherHostImpl::IncrementOutstandingRequestsCount(
int count,
- const ResourceRequestInfoImpl& info) {
+ ResourceRequestInfoImpl& info) {
davidben 2014/10/15 19:15:12 Nit: probably should be passed in as pointer.
Charlie Reis 2014/10/15 19:48:00 Yep.
DCHECK_EQ(1, abs(count));
num_in_flight_requests_ += count;
+ // Keep track of whether this request is counting toward the number of
+ // in-flight requests for this process, in case we need to transfer it to
+ // another process. This should be a toggle.
+ DCHECK_NE(info.counted_as_in_flight_request(), count > 0);
+ info.set_counted_as_in_flight_request(count > 0);
+
OustandingRequestsStats stats = GetOutstandingRequestsStats(info);
stats.num_requests += count;
DCHECK_GE(stats.num_requests, 0);
@@ -1740,9 +1750,8 @@ ResourceDispatcherHostImpl::IncrementOutstandingRequestsCount(
}
bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest(
- const net::URLRequest* request_) {
- const ResourceRequestInfoImpl* info =
- ResourceRequestInfoImpl::ForRequest(request_);
+ net::URLRequest* request) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, *info);
if (stats.num_requests > max_num_in_flight_requests_per_process_)
@@ -1754,9 +1763,8 @@ bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest(
}
void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
- const net::URLRequest* request_) {
- const ResourceRequestInfoImpl* info =
- ResourceRequestInfoImpl::ForRequest(request_);
+ net::URLRequest* request) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
IncrementOutstandingRequestsCount(-1, *info);
}

Powered by Google App Engine
This is Rietveld 408576698