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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 #if defined(OS_WIN) | 196 #if defined(OS_WIN) |
| 197 #pragma warning(disable: 4748) | 197 #pragma warning(disable: 4748) |
| 198 #pragma optimize("", off) | 198 #pragma optimize("", off) |
| 199 #endif | 199 #endif |
| 200 | 200 |
| 201 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
| 202 #pragma optimize("", on) | 202 #pragma optimize("", on) |
| 203 #pragma warning(default: 4748) | 203 #pragma warning(default: 4748) |
| 204 #endif | 204 #endif |
| 205 | 205 |
| 206 net::RequestPriority DetermineRequestPriority( | 206 net::RequestPriority ConvertWebKitPriorityToNetPriority( |
| 207 const ResourceHostMsg_Request& request_data) { | 207 const WebKit::WebURLRequest::Priority& priority) { |
| 208 switch (request_data.priority) { | 208 switch (priority) { |
| 209 case WebKit::WebURLRequest::PriorityVeryHigh: | 209 case WebKit::WebURLRequest::PriorityVeryHigh: |
| 210 return net::HIGHEST; | 210 return net::HIGHEST; |
| 211 | 211 |
| 212 case WebKit::WebURLRequest::PriorityHigh: | 212 case WebKit::WebURLRequest::PriorityHigh: |
| 213 return net::MEDIUM; | 213 return net::MEDIUM; |
| 214 | 214 |
| 215 case WebKit::WebURLRequest::PriorityMedium: | 215 case WebKit::WebURLRequest::PriorityMedium: |
| 216 return net::LOW; | 216 return net::LOW; |
| 217 | 217 |
| 218 case WebKit::WebURLRequest::PriorityLow: | 218 case WebKit::WebURLRequest::PriorityLow: |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHostImpl, message, *message_was_ok) | 785 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHostImpl, message, *message_was_ok) |
| 786 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 786 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
| 787 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 787 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
| 788 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 788 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
| 789 OnReleaseDownloadedFile) | 789 OnReleaseDownloadedFile) |
| 790 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) | 790 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) |
| 791 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 791 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
| 792 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 792 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| 793 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 793 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
| 794 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) | 794 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) |
| 795 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) | |
| 795 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) | 796 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) |
| 796 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 797 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 797 OnDidLoadResourceFromMemoryCache) | 798 OnDidLoadResourceFromMemoryCache) |
| 798 IPC_MESSAGE_UNHANDLED(handled = false) | 799 IPC_MESSAGE_UNHANDLED(handled = false) |
| 799 IPC_END_MESSAGE_MAP_EX() | 800 IPC_END_MESSAGE_MAP_EX() |
| 800 | 801 |
| 801 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { | 802 if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { |
| 802 // We just needed to peek at this message. We still want it to reach its | 803 // We just needed to peek at this message. We still want it to reach its |
| 803 // normal destination. | 804 // normal destination. |
| 804 handled = false; | 805 handled = false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 net::HttpRequestHeaders headers; | 916 net::HttpRequestHeaders headers; |
| 916 headers.AddHeadersFromString(request_data.headers); | 917 headers.AddHeadersFromString(request_data.headers); |
| 917 request->SetExtraRequestHeaders(headers); | 918 request->SetExtraRequestHeaders(headers); |
| 918 } | 919 } |
| 919 | 920 |
| 920 // TODO(darin): Do we really need all of these URLRequest setters in the | 921 // TODO(darin): Do we really need all of these URLRequest setters in the |
| 921 // transferred navigation case? | 922 // transferred navigation case? |
| 922 | 923 |
| 923 request->set_load_flags(load_flags); | 924 request->set_load_flags(load_flags); |
| 924 | 925 |
| 925 request->set_priority(DetermineRequestPriority(request_data)); | 926 request->set_priority(ConvertWebKitPriorityToNetPriority( |
| 927 request_data.priority)); | |
| 926 | 928 |
| 927 // Resolve elements from request_body and prepare upload data. | 929 // Resolve elements from request_body and prepare upload data. |
| 928 if (request_data.request_body) { | 930 if (request_data.request_body) { |
| 929 request->set_upload(make_scoped_ptr( | 931 request->set_upload(make_scoped_ptr( |
| 930 request_data.request_body->ResolveElementsAndCreateUploadDataStream( | 932 request_data.request_body->ResolveElementsAndCreateUploadDataStream( |
| 931 filter_->blob_storage_context()->controller(), | 933 filter_->blob_storage_context()->controller(), |
| 932 filter_->file_system_context(), | 934 filter_->file_system_context(), |
| 933 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)))); | 935 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)))); |
| 934 } | 936 } |
| 935 | 937 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 } | 1122 } |
| 1121 | 1123 |
| 1122 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1124 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 1123 if (info->async_handler()) { | 1125 if (info->async_handler()) { |
| 1124 info->async_handler()->OnFollowRedirect( | 1126 info->async_handler()->OnFollowRedirect( |
| 1125 has_new_first_party_for_cookies, | 1127 has_new_first_party_for_cookies, |
| 1126 new_first_party_for_cookies); | 1128 new_first_party_for_cookies); |
| 1127 } | 1129 } |
| 1128 } | 1130 } |
| 1129 | 1131 |
| 1132 void ResourceDispatcherHostImpl::OnDidChangePriority( | |
| 1133 int request_id, | |
| 1134 WebKit::WebURLRequest::Priority priority) { | |
| 1135 int child_id = filter_->child_id(); | |
| 1136 LoaderMap::iterator it = pending_loaders_.find( | |
| 1137 GlobalRequestID(child_id, request_id)); | |
| 1138 if (it == pending_loaders_.end()) { | |
| 1139 // PendingRequest likely removed while this IPC was in flight. | |
| 1140 return; | |
| 1141 } | |
| 1142 const linked_ptr<ResourceLoader>& loader = it->second; | |
| 1143 loader->ChangePriority(ConvertWebKitPriorityToNetPriority(priority)); | |
|
darin (slow to review)
2013/02/06 05:04:13
Maybe instead of routing this notification through
| |
| 1144 } | |
| 1145 | |
| 1130 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( | 1146 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( |
| 1131 int child_id, | 1147 int child_id, |
| 1132 int route_id, | 1148 int route_id, |
| 1133 bool download, | 1149 bool download, |
| 1134 ResourceContext* context) { | 1150 ResourceContext* context) { |
| 1135 return new ResourceRequestInfoImpl( | 1151 return new ResourceRequestInfoImpl( |
| 1136 PROCESS_TYPE_RENDERER, | 1152 PROCESS_TYPE_RENDERER, |
| 1137 child_id, | 1153 child_id, |
| 1138 route_id, | 1154 route_id, |
| 1139 0, | 1155 0, |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1700 | 1716 |
| 1701 return i->second.get(); | 1717 return i->second.get(); |
| 1702 } | 1718 } |
| 1703 | 1719 |
| 1704 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, | 1720 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, |
| 1705 int request_id) const { | 1721 int request_id) const { |
| 1706 return GetLoader(GlobalRequestID(child_id, request_id)); | 1722 return GetLoader(GlobalRequestID(child_id, request_id)); |
| 1707 } | 1723 } |
| 1708 | 1724 |
| 1709 } // namespace content | 1725 } // namespace content |
| OLD | NEW |