Chromium Code Reviews| 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 #include <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "content/browser/loader/resource_scheduler.h" | 7 #include "content/browser/loader/resource_scheduler.h" |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 pending_requests_.Erase(request); | 330 pending_requests_.Erase(request); |
| 331 DCHECK(!ContainsKey(in_flight_requests_, request)); | 331 DCHECK(!ContainsKey(in_flight_requests_, request)); |
| 332 } else { | 332 } else { |
| 333 EraseInFlightRequest(request); | 333 EraseInFlightRequest(request); |
| 334 | 334 |
| 335 // Removing this request may have freed up another to load. | 335 // Removing this request may have freed up another to load. |
| 336 LoadAnyStartablePendingRequests(); | 336 LoadAnyStartablePendingRequests(); |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 RequestSet RemoveAllRequests() { | 340 RequestSet StartAndRemoveAllRequests() { |
| 341 // First start any pending requests so that they will be moved into | |
| 342 // in_flight_requests_. This may exceed the limits | |
| 343 // kMaxNumDelayableRequestsPerClient, kMaxNumDelayableRequestsPerHost and | |
| 344 // kMaxNumThrottledRequestsPerClient, so this method must not do anything | |
| 345 // that depends on those limits before calling ClearInFlightRequests() | |
| 346 // below. | |
| 347 while (!pending_requests_.IsEmpty()) { | |
| 348 ScheduledResourceRequest* request = | |
| 349 *pending_requests_.GetNextHighestIterator(); | |
| 350 pending_requests_.Erase(request); | |
| 351 // StartRequest() may modify pending_requests_. TODO(ricea): Does it? | |
| 352 StartRequest(request); | |
| 353 } | |
| 341 RequestSet unowned_requests; | 354 RequestSet unowned_requests; |
| 342 for (RequestSet::iterator it = in_flight_requests_.begin(); | 355 for (RequestSet::iterator it = in_flight_requests_.begin(); |
| 343 it != in_flight_requests_.end(); ++it) { | 356 it != in_flight_requests_.end(); ++it) { |
| 344 unowned_requests.insert(*it); | 357 unowned_requests.insert(*it); |
| 345 (*it)->set_classification(NORMAL_REQUEST); | 358 (*it)->set_classification(NORMAL_REQUEST); |
| 346 } | 359 } |
| 347 ClearInFlightRequests(); | 360 ClearInFlightRequests(); |
| 348 return unowned_requests; | 361 return unowned_requests; |
| 349 } | 362 } |
| 350 | 363 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 | 924 |
| 912 void ResourceScheduler::OnClientDeleted(int child_id, int route_id) { | 925 void ResourceScheduler::OnClientDeleted(int child_id, int route_id) { |
| 913 DCHECK(CalledOnValidThread()); | 926 DCHECK(CalledOnValidThread()); |
| 914 ClientId client_id = MakeClientId(child_id, route_id); | 927 ClientId client_id = MakeClientId(child_id, route_id); |
| 915 DCHECK(ContainsKey(client_map_, client_id)); | 928 DCHECK(ContainsKey(client_map_, client_id)); |
| 916 ClientMap::iterator it = client_map_.find(client_id); | 929 ClientMap::iterator it = client_map_.find(client_id); |
| 917 if (it == client_map_.end()) | 930 if (it == client_map_.end()) |
| 918 return; | 931 return; |
| 919 | 932 |
| 920 Client* client = it->second; | 933 Client* client = it->second; |
| 921 // FYI, ResourceDispatcherHost cancels all of the requests after this function | 934 // ResourceDispatcherHost cancels all requests except for cross-renderer |
| 922 // is called. It should end up canceling all of the requests except for a | 935 // navigations, async revalidations and detachable requests after |
| 923 // cross-renderer navigation. | 936 // OnClientDeleted() returns. |
|
mmenke
2015/06/18 14:49:26
Wait...So we start a bunch of requests, and then w
Adam Rice
2015/06/19 13:06:53
Even without this CL up to 10 requests will be sta
mmenke
2015/06/19 15:10:16
You mean in the destructor, when we call UpdateThr
Adam Rice
2015/06/23 17:06:52
Sorry, I was confused because throttling is enable
| |
| 924 RequestSet client_unowned_requests = client->RemoveAllRequests(); | 937 RequestSet client_unowned_requests = client->StartAndRemoveAllRequests(); |
| 925 for (RequestSet::iterator it = client_unowned_requests.begin(); | 938 for (RequestSet::iterator it = client_unowned_requests.begin(); |
| 926 it != client_unowned_requests.end(); ++it) { | 939 it != client_unowned_requests.end(); ++it) { |
| 927 unowned_requests_.insert(*it); | 940 unowned_requests_.insert(*it); |
| 928 } | 941 } |
| 929 | 942 |
| 930 delete client; | 943 delete client; |
| 931 client_map_.erase(it); | 944 client_map_.erase(it); |
| 932 } | 945 } |
| 933 | 946 |
| 934 void ResourceScheduler::OnLoadingStateChanged(int child_id, | 947 void ResourceScheduler::OnLoadingStateChanged(int child_id, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 client->ReprioritizeRequest( | 1161 client->ReprioritizeRequest( |
| 1149 request, old_priority_params, new_priority_params); | 1162 request, old_priority_params, new_priority_params); |
| 1150 } | 1163 } |
| 1151 | 1164 |
| 1152 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1165 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
| 1153 int child_id, int route_id) { | 1166 int child_id, int route_id) { |
| 1154 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1167 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
| 1155 } | 1168 } |
| 1156 | 1169 |
| 1157 } // namespace content | 1170 } // namespace content |
| OLD | NEW |