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 <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 filter_ = filter; | 971 filter_ = filter; |
972 bool handled = true; | 972 bool handled = true; |
973 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message) | 973 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message) |
974 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 974 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
975 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 975 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
976 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 976 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
977 OnReleaseDownloadedFile) | 977 OnReleaseDownloadedFile) |
978 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 978 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
979 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 979 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
980 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 980 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
981 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) | |
981 IPC_MESSAGE_UNHANDLED(handled = false) | 982 IPC_MESSAGE_UNHANDLED(handled = false) |
982 IPC_END_MESSAGE_MAP() | 983 IPC_END_MESSAGE_MAP() |
983 | 984 |
984 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { | 985 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { |
985 base::PickleIterator iter(message); | 986 base::PickleIterator iter(message); |
986 int request_id = -1; | 987 int request_id = -1; |
987 bool ok = iter.ReadInt(&request_id); | 988 bool ok = iter.ReadInt(&request_id); |
988 DCHECK(ok); | 989 DCHECK(ok); |
989 GlobalRequestID id(filter_->child_id(), request_id); | 990 GlobalRequestID id(filter_->child_id(), request_id); |
990 DelegateMap::iterator it = delegate_map_.find(id); | 991 DelegateMap::iterator it = delegate_map_.find(id); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1428 appcache_service, | 1429 appcache_service, |
1429 resource_type, | 1430 resource_type, |
1430 &throttles); | 1431 &throttles); |
1431 } | 1432 } |
1432 | 1433 |
1433 if (request->has_upload()) { | 1434 if (request->has_upload()) { |
1434 // Block power save while uploading data. | 1435 // Block power save while uploading data. |
1435 throttles.push_back(new PowerSaveBlockResourceThrottle()); | 1436 throttles.push_back(new PowerSaveBlockResourceThrottle()); |
1436 } | 1437 } |
1437 | 1438 |
1438 throttles.push_back( | 1439 // TODO(ricea): Stop looking this up so much. |
1439 scheduler_->ScheduleRequest(child_id, route_id, request).release()); | 1440 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1441 scoped_ptr<ScheduledResourceRequest> scheduled_resource_request( | |
1442 scheduler_->ScheduleRequest(child_id, route_id, info->IsAsync(), | |
1443 request)); | |
1444 info->set_scheduled_resource_request(scheduled_resource_request.get()); | |
davidben
2015/08/12 23:58:11
There is a sliiiiight awkwardness in that it's not
Adam Rice
2015/08/13 21:21:02
If we can guarantee that no-one forges a DidChange
davidben
2015/08/13 23:08:52
Yeah, I think right now we are guaranteed to not h
Adam Rice
2015/08/13 23:42:28
The only think that actually looked at that field
| |
1445 throttles.push_back(scheduled_resource_request.Pass()); | |
1440 | 1446 |
1441 handler.reset( | 1447 handler.reset( |
1442 new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); | 1448 new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); |
1443 | 1449 |
1444 return handler.Pass(); | 1450 return handler.Pass(); |
1445 } | 1451 } |
1446 | 1452 |
1447 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1453 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
1448 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1454 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
1449 } | 1455 } |
1450 | 1456 |
1457 void ResourceDispatcherHostImpl::OnDidChangePriority( | |
1458 int request_id, | |
1459 net::RequestPriority new_priority, | |
1460 int intra_priority_value) { | |
davidben
2015/08/12 23:58:11
Since this is coming from the renderer, it should
Adam Rice
2015/08/13 21:21:02
I should have spotted that. Done.
| |
1461 ScheduledResourceRequest* scheduled_resource_request = | |
1462 GetLoader(filter_->child_id(), request_id) | |
1463 ->GetRequestInfo() | |
1464 ->scheduled_resource_request(); | |
1465 DCHECK(scheduled_resource_request); | |
1466 scheduled_resource_request->ChangePriority(new_priority, | |
1467 intra_priority_value); | |
1468 } | |
1469 | |
1451 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { | 1470 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { |
1452 // TODO(michaeln): maybe throttle DataDownloaded messages | 1471 // TODO(michaeln): maybe throttle DataDownloaded messages |
1453 } | 1472 } |
1454 | 1473 |
1455 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( | 1474 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( |
1456 int child_id, int request_id, const base::FilePath& file_path) { | 1475 int child_id, int request_id, const base::FilePath& file_path) { |
1457 scoped_refptr<ShareableFileReference> reference = | 1476 scoped_refptr<ShareableFileReference> reference = |
1458 ShareableFileReference::Get(file_path); | 1477 ShareableFileReference::Get(file_path); |
1459 DCHECK(reference.get()); | 1478 DCHECK(reference.get()); |
1460 | 1479 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2354 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 2373 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
2355 && !policy->CanReadRawCookies(child_id)) { | 2374 && !policy->CanReadRawCookies(child_id)) { |
2356 VLOG(1) << "Denied unauthorized request for raw headers"; | 2375 VLOG(1) << "Denied unauthorized request for raw headers"; |
2357 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 2376 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
2358 } | 2377 } |
2359 | 2378 |
2360 return load_flags; | 2379 return load_flags; |
2361 } | 2380 } |
2362 | 2381 |
2363 } // namespace content | 2382 } // namespace content |
OLD | NEW |