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 // 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 <stddef.h> | 9 #include <stddef.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 info->GetResourceType()); | 1045 info->GetResourceType()); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 if (delegate_) | 1048 if (delegate_) |
| 1049 delegate_->RequestComplete(loader->request()); | 1049 delegate_->RequestComplete(loader->request()); |
| 1050 | 1050 |
| 1051 // Destroy the ResourceLoader. | 1051 // Destroy the ResourceLoader. |
| 1052 RemovePendingRequest(info->GetChildID(), info->GetRequestID()); | 1052 RemovePendingRequest(info->GetChildID(), info->GetRequestID()); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 void ResourceDispatcherHostImpl::LoaderDestroyed(ResourceLoader* loader) { | |
| 1056 request_ids_in_use_.erase(loader->GetRequestInfo()->GetGlobalRequestID()); | |
| 1057 } | |
| 1058 | |
| 1055 void ResourceDispatcherHostImpl::OnInit() { | 1059 void ResourceDispatcherHostImpl::OnInit() { |
| 1056 scheduler_.reset(new ResourceScheduler); | 1060 scheduler_.reset(new ResourceScheduler); |
| 1057 } | 1061 } |
| 1058 | 1062 |
| 1059 void ResourceDispatcherHostImpl::OnShutdown() { | 1063 void ResourceDispatcherHostImpl::OnShutdown() { |
| 1060 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1064 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1061 | 1065 |
| 1062 is_shutdown_ = true; | 1066 is_shutdown_ = true; |
| 1063 pending_loaders_.clear(); | 1067 pending_loaders_.clear(); |
| 1064 | 1068 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 1167 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
| 1164 // a normal asynchronous set of response messages will be generated. | 1168 // a normal asynchronous set of response messages will be generated. |
| 1165 void ResourceDispatcherHostImpl::OnSyncLoad( | 1169 void ResourceDispatcherHostImpl::OnSyncLoad( |
| 1166 int request_id, | 1170 int request_id, |
| 1167 const ResourceHostMsg_Request& request_data, | 1171 const ResourceHostMsg_Request& request_data, |
| 1168 IPC::Message* sync_result) { | 1172 IPC::Message* sync_result) { |
| 1169 BeginRequest(request_id, request_data, sync_result, | 1173 BeginRequest(request_id, request_data, sync_result, |
| 1170 sync_result->routing_id()); | 1174 sync_result->routing_id()); |
| 1171 } | 1175 } |
| 1172 | 1176 |
| 1173 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( | 1177 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( |
|
mmenke
2016/01/19 20:30:31
BUG: This changes the id of a request, so needs t
| |
| 1174 int child_id, | 1178 int child_id, |
| 1175 int route_id, | 1179 int route_id, |
| 1176 int request_id, | 1180 int request_id, |
| 1177 const ResourceHostMsg_Request& request_data, | 1181 const ResourceHostMsg_Request& request_data, |
| 1178 const linked_ptr<ResourceLoader>& loader) { | 1182 const linked_ptr<ResourceLoader>& loader) { |
| 1179 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1183 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 1180 GlobalRoutingID old_routing_id( | 1184 GlobalRoutingID old_routing_id( |
| 1181 request_data.transferred_request_child_id, info->GetRouteID()); | 1185 request_data.transferred_request_child_id, info->GetRouteID()); |
| 1182 GlobalRequestID old_request_id(request_data.transferred_request_child_id, | 1186 GlobalRequestID old_request_id(request_data.transferred_request_child_id, |
| 1183 request_data.transferred_request_request_id); | 1187 request_data.transferred_request_request_id); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 } | 1251 } |
| 1248 | 1252 |
| 1249 void ResourceDispatcherHostImpl::BeginRequest( | 1253 void ResourceDispatcherHostImpl::BeginRequest( |
| 1250 int request_id, | 1254 int request_id, |
| 1251 const ResourceHostMsg_Request& request_data, | 1255 const ResourceHostMsg_Request& request_data, |
| 1252 IPC::Message* sync_result, // only valid for sync | 1256 IPC::Message* sync_result, // only valid for sync |
| 1253 int route_id) { | 1257 int route_id) { |
| 1254 int process_type = filter_->process_type(); | 1258 int process_type = filter_->process_type(); |
| 1255 int child_id = filter_->child_id(); | 1259 int child_id = filter_->child_id(); |
| 1256 | 1260 |
| 1261 // Reject request id that's currently in use. | |
| 1262 if (request_ids_in_use_.count(GlobalRequestID(child_id, request_id))) { | |
| 1263 bad_message::ReceivedBadMessage( | |
| 1264 filter_, | |
| 1265 bad_message::RDH_INVALID_REQUEST_ID); | |
| 1266 return; | |
| 1267 } | |
| 1268 | |
| 1257 // PlzNavigate: reject invalid renderer main resource request. | 1269 // PlzNavigate: reject invalid renderer main resource request. |
| 1258 if (IsBrowserSideNavigationEnabled() && | 1270 if (IsBrowserSideNavigationEnabled() && |
| 1259 IsResourceTypeFrame(request_data.resource_type) && | 1271 IsResourceTypeFrame(request_data.resource_type) && |
| 1260 !request_data.url.SchemeIs(url::kBlobScheme)) { | 1272 !request_data.url.SchemeIs(url::kBlobScheme)) { |
| 1261 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_URL); | 1273 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_URL); |
| 1262 return; | 1274 return; |
| 1263 } | 1275 } |
| 1264 | 1276 |
| 1265 // Reject invalid priority. | 1277 // Reject invalid priority. |
| 1266 if (request_data.priority < net::MINIMUM_PRIORITY || | 1278 if (request_data.priority < net::MINIMUM_PRIORITY || |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2284 IncrementOutstandingRequestsMemory(-1, *info); | 2296 IncrementOutstandingRequestsMemory(-1, *info); |
| 2285 | 2297 |
| 2286 // A ResourceHandler must not outlive its associated URLRequest. | 2298 // A ResourceHandler must not outlive its associated URLRequest. |
| 2287 handler.reset(); | 2299 handler.reset(); |
| 2288 return; | 2300 return; |
| 2289 } | 2301 } |
| 2290 | 2302 |
| 2291 linked_ptr<ResourceLoader> loader( | 2303 linked_ptr<ResourceLoader> loader( |
| 2292 new ResourceLoader(std::move(request), std::move(handler), this)); | 2304 new ResourceLoader(std::move(request), std::move(handler), this)); |
| 2293 | 2305 |
| 2306 request_ids_in_use_.insert(info->GetGlobalRequestID()); | |
| 2307 | |
| 2294 GlobalRoutingID id(info->GetGlobalRoutingID()); | 2308 GlobalRoutingID id(info->GetGlobalRoutingID()); |
| 2295 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); | 2309 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); |
| 2296 if (iter != blocked_loaders_map_.end()) { | 2310 if (iter != blocked_loaders_map_.end()) { |
| 2297 // The request should be blocked. | 2311 // The request should be blocked. |
| 2298 iter->second->push_back(loader); | 2312 iter->second->push_back(loader); |
| 2299 return; | 2313 return; |
| 2300 } | 2314 } |
| 2301 | 2315 |
| 2302 StartLoading(info, loader); | 2316 StartLoading(info, loader); |
| 2303 } | 2317 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2549 load_flags |= net::LOAD_PREFETCH; | 2563 load_flags |= net::LOAD_PREFETCH; |
| 2550 } | 2564 } |
| 2551 | 2565 |
| 2552 if (is_sync_load) | 2566 if (is_sync_load) |
| 2553 load_flags |= net::LOAD_IGNORE_LIMITS; | 2567 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2554 | 2568 |
| 2555 return load_flags; | 2569 return load_flags; |
| 2556 } | 2570 } |
| 2557 | 2571 |
| 2558 } // namespace content | 2572 } // namespace content |
| OLD | NEW |