| 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 "content/browser/loader/resource_scheduler.h" | 5 #include "content/browser/loader/resource_scheduler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | |
| 9 #include <set> | 8 #include <set> |
| 10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
| 19 #include "base/supports_user_data.h" | 19 #include "base/supports_user_data.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 RequestPriorityParams(url_request->priority(), 0), is_async)); | 1077 RequestPriorityParams(url_request->priority(), 0), is_async)); |
| 1078 | 1078 |
| 1079 ClientMap::iterator it = client_map_.find(client_id); | 1079 ClientMap::iterator it = client_map_.find(client_id); |
| 1080 if (it == client_map_.end()) { | 1080 if (it == client_map_.end()) { |
| 1081 // There are several ways this could happen: | 1081 // There are several ways this could happen: |
| 1082 // 1. <a ping> requests don't have a route_id. | 1082 // 1. <a ping> requests don't have a route_id. |
| 1083 // 2. Most unittests don't send the IPCs needed to register Clients. | 1083 // 2. Most unittests don't send the IPCs needed to register Clients. |
| 1084 // 3. The tab is closed while a RequestResource IPC is in flight. | 1084 // 3. The tab is closed while a RequestResource IPC is in flight. |
| 1085 unowned_requests_.insert(request.get()); | 1085 unowned_requests_.insert(request.get()); |
| 1086 request->Start(START_SYNC); | 1086 request->Start(START_SYNC); |
| 1087 return request.Pass(); | 1087 return std::move(request); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 Client* client = it->second; | 1090 Client* client = it->second; |
| 1091 client->ScheduleRequest(url_request, request.get()); | 1091 client->ScheduleRequest(url_request, request.get()); |
| 1092 return request.Pass(); | 1092 return std::move(request); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 void ResourceScheduler::RemoveRequest(ScheduledResourceRequest* request) { | 1095 void ResourceScheduler::RemoveRequest(ScheduledResourceRequest* request) { |
| 1096 DCHECK(CalledOnValidThread()); | 1096 DCHECK(CalledOnValidThread()); |
| 1097 if (ContainsKey(unowned_requests_, request)) { | 1097 if (ContainsKey(unowned_requests_, request)) { |
| 1098 unowned_requests_.erase(request); | 1098 unowned_requests_.erase(request); |
| 1099 return; | 1099 return; |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 ClientMap::iterator client_it = client_map_.find(request->client_id()); | 1102 ClientMap::iterator client_it = client_map_.find(request->client_id()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params, | 1367 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params, |
| 1368 new_priority_params); | 1368 new_priority_params); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1371 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
| 1372 int child_id, int route_id) { | 1372 int child_id, int route_id) { |
| 1373 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1373 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 } // namespace content | 1376 } // namespace content |
| OLD | NEW |