| 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..05a7a73b8be98a699feacefa5d571c95e54bb6eb 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,23 +1731,28 @@ ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemory(
|
| ResourceDispatcherHostImpl::OustandingRequestsStats
|
| ResourceDispatcherHostImpl::IncrementOutstandingRequestsCount(
|
| int count,
|
| - const ResourceRequestInfoImpl& info) {
|
| + ResourceRequestInfoImpl* info) {
|
| DCHECK_EQ(1, abs(count));
|
| num_in_flight_requests_ += count;
|
|
|
| - OustandingRequestsStats stats = GetOutstandingRequestsStats(info);
|
| + // 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);
|
| - UpdateOutstandingRequestsStats(info, stats);
|
| + UpdateOutstandingRequestsStats(*info, stats);
|
|
|
| return stats;
|
| }
|
|
|
| bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest(
|
| - const net::URLRequest* request_) {
|
| - const ResourceRequestInfoImpl* info =
|
| - ResourceRequestInfoImpl::ForRequest(request_);
|
| - OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, *info);
|
| + net::URLRequest* request) {
|
| + ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
|
| + OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, info);
|
|
|
| if (stats.num_requests > max_num_in_flight_requests_per_process_)
|
| return false;
|
| @@ -1754,10 +1763,9 @@ bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest(
|
| }
|
|
|
| void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
|
| - const net::URLRequest* request_) {
|
| - const ResourceRequestInfoImpl* info =
|
| - ResourceRequestInfoImpl::ForRequest(request_);
|
| - IncrementOutstandingRequestsCount(-1, *info);
|
| + net::URLRequest* request) {
|
| + ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
|
| + IncrementOutstandingRequestsCount(-1, info);
|
| }
|
|
|
| void ResourceDispatcherHostImpl::StartNavigationRequest(
|
|
|