Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_impl.cc

Issue 10825073: Stop using ScopedAllowIO in content::ResourceDispatcherHostImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/renderer_host/resource_dispatcher_host_impl.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/debug/alias.h" 16 #include "base/debug/alias.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/shared_memory.h" 21 #include "base/shared_memory.h"
22 #include "base/stl_util.h" 22 #include "base/stl_util.h"
23 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 23 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
24 #include "base/threading/thread_restrictions.h"
25 #include "content/browser/appcache/chrome_appcache_service.h" 24 #include "content/browser/appcache/chrome_appcache_service.h"
26 #include "content/browser/cert_store_impl.h" 25 #include "content/browser/cert_store_impl.h"
27 #include "content/browser/child_process_security_policy_impl.h" 26 #include "content/browser/child_process_security_policy_impl.h"
28 #include "content/browser/cross_site_request_manager.h" 27 #include "content/browser/cross_site_request_manager.h"
29 #include "content/browser/download/download_file_manager.h" 28 #include "content/browser/download/download_file_manager.h"
30 #include "content/browser/download/download_resource_handler.h" 29 #include "content/browser/download/download_resource_handler.h"
31 #include "content/browser/download/save_file_manager.h" 30 #include "content/browser/download/save_file_manager.h"
32 #include "content/browser/download/save_file_resource_handler.h" 31 #include "content/browser/download/save_file_resource_handler.h"
33 #include "content/browser/fileapi/chrome_blob_storage_context.h" 32 #include "content/browser/fileapi/chrome_blob_storage_context.h"
34 #include "content/browser/plugin_service_impl.h" 33 #include "content/browser/plugin_service_impl.h"
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 950 }
952 951
953 // TODO(darin): Do we really need all of these URLRequest setters in the 952 // TODO(darin): Do we really need all of these URLRequest setters in the
954 // transferred navigation case? 953 // transferred navigation case?
955 954
956 request->set_load_flags(load_flags); 955 request->set_load_flags(load_flags);
957 956
958 request->set_priority(DetermineRequestPriority(request_data.resource_type)); 957 request->set_priority(DetermineRequestPriority(request_data.resource_type));
959 958
960 // Resolve elements from request_body and prepare upload data. 959 // Resolve elements from request_body and prepare upload data.
961 uint64 upload_size = 0;
962 if (request_data.request_body) { 960 if (request_data.request_body) {
963 request->set_upload( 961 request->set_upload(
964 request_data.request_body->ResolveElementsAndCreateUploadData( 962 request_data.request_body->ResolveElementsAndCreateUploadData(
965 GetBlobStorageControllerForResourceContext(resource_context))); 963 GetBlobStorageControllerForResourceContext(resource_context)));
966 // This results in performing file IO. crbug.com/112607.
967 base::ThreadRestrictions::ScopedAllowIO allow_io;
968 upload_size = request->get_upload_mutable()->GetContentLengthSync();
969 } 964 }
970 965
971 bool allow_download = request_data.allow_download && 966 bool allow_download = request_data.allow_download &&
972 ResourceType::IsFrame(request_data.resource_type); 967 ResourceType::IsFrame(request_data.resource_type);
973 968
974 // Make extra info and read footer (contains request ID). 969 // Make extra info and read footer (contains request ID).
975 ResourceRequestInfoImpl* extra_info = 970 ResourceRequestInfoImpl* extra_info =
976 new ResourceRequestInfoImpl( 971 new ResourceRequestInfoImpl(
977 process_type, 972 process_type,
978 child_id, 973 child_id,
979 route_id, 974 route_id,
980 request_data.origin_pid, 975 request_data.origin_pid,
981 request_id, 976 request_id,
982 request_data.is_main_frame, 977 request_data.is_main_frame,
983 request_data.frame_id, 978 request_data.frame_id,
984 request_data.parent_is_main_frame, 979 request_data.parent_is_main_frame,
985 request_data.parent_frame_id, 980 request_data.parent_frame_id,
986 request_data.resource_type, 981 request_data.resource_type,
987 request_data.transition_type, 982 request_data.transition_type,
988 upload_size,
989 false, // is download 983 false, // is download
990 allow_download, 984 allow_download,
991 request_data.has_user_gesture, 985 request_data.has_user_gesture,
992 request_data.referrer_policy, 986 request_data.referrer_policy,
993 resource_context); 987 resource_context);
994 extra_info->AssociateWithRequest(request); // Request takes ownership. 988 extra_info->AssociateWithRequest(request); // Request takes ownership.
995 989
996 if (request->url().SchemeIs(chrome::kBlobScheme)) { 990 if (request->url().SchemeIs(chrome::kBlobScheme)) {
997 // Hang on to a reference to ensure the blob is not released prior 991 // Hang on to a reference to ensure the blob is not released prior
998 // to the job being started. 992 // to the job being started.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 child_id, 1172 child_id,
1179 route_id, 1173 route_id,
1180 0, 1174 0,
1181 request_id_, 1175 request_id_,
1182 false, // is_main_frame 1176 false, // is_main_frame
1183 -1, // frame_id 1177 -1, // frame_id
1184 false, // parent_is_main_frame 1178 false, // parent_is_main_frame
1185 -1, // parent_frame_id 1179 -1, // parent_frame_id
1186 ResourceType::SUB_RESOURCE, 1180 ResourceType::SUB_RESOURCE,
1187 PAGE_TRANSITION_LINK, 1181 PAGE_TRANSITION_LINK,
1188 0, // upload_size
1189 download, // is_download 1182 download, // is_download
1190 download, // allow_download 1183 download, // allow_download
1191 false, // has_user_gesture 1184 false, // has_user_gesture
1192 WebKit::WebReferrerPolicyDefault, 1185 WebKit::WebReferrerPolicyDefault,
1193 context); 1186 context);
1194 } 1187 }
1195 1188
1196 void ResourceDispatcherHostImpl::OnSwapOutACK( 1189 void ResourceDispatcherHostImpl::OnSwapOutACK(
1197 const ViewMsg_SwapOut_Params& params) { 1190 const ViewMsg_SwapOut_Params& params) {
1198 // Closes for cross-site transitions are handled such that the cross-site 1191 // Closes for cross-site transitions are handled such that the cross-site
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 LoadInfoMap info_map; 1578 LoadInfoMap info_map;
1586 1579
1587 LoaderMap::const_iterator i; 1580 LoaderMap::const_iterator i;
1588 1581
1589 // Determine the largest upload size of all requests 1582 // Determine the largest upload size of all requests
1590 // in each View (good chance it's zero). 1583 // in each View (good chance it's zero).
1591 std::map<std::pair<int, int>, uint64> largest_upload_size; 1584 std::map<std::pair<int, int>, uint64> largest_upload_size;
1592 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { 1585 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) {
1593 net::URLRequest* request = i->second->request(); 1586 net::URLRequest* request = i->second->request();
1594 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); 1587 ResourceRequestInfoImpl* info = i->second->GetRequestInfo();
1595 uint64 upload_size = info->GetUploadSize(); 1588 uint64 upload_size = request->GetUploadProgress().size;
1596 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) 1589 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST)
1597 upload_size = 0; 1590 upload_size = 0;
1598 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); 1591 std::pair<int, int> key(info->GetChildID(), info->GetRouteID());
1599 if (upload_size && largest_upload_size[key] < upload_size) 1592 if (upload_size && largest_upload_size[key] < upload_size)
1600 largest_upload_size[key] = upload_size; 1593 largest_upload_size[key] = upload_size;
1601 } 1594 }
1602 1595
1603 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { 1596 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) {
1604 net::URLRequest* request = i->second->request(); 1597 net::URLRequest* request = i->second->request();
1605 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); 1598 ResourceRequestInfoImpl* info = i->second->GetRequestInfo();
1606 net::LoadStateWithParam load_state = request->GetLoadState(); 1599 net::LoadStateWithParam load_state = request->GetLoadState();
1600 const net::UploadProgress progress = request->GetUploadProgress();
darin (slow to review) 2012/08/29 22:36:16 nit: no need for 'const' here.
hashimoto 2012/08/29 22:48:55 Done.
1607 1601
1608 // We also poll for upload progress on this timer and send upload 1602 // We also poll for upload progress on this timer and send upload
1609 // progress ipc messages to the plugin process. 1603 // progress ipc messages to the plugin process.
1610 i->second->ReportUploadProgress(); 1604 i->second->ReportUploadProgress();
1611 1605
1612 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); 1606 std::pair<int, int> key(info->GetChildID(), info->GetRouteID());
1613 1607
1614 // If a request is uploading data, ignore all other requests so that the 1608 // If a request is uploading data, ignore all other requests so that the
1615 // upload progress takes priority for being shown in the status bar. 1609 // upload progress takes priority for being shown in the status bar.
1616 if (largest_upload_size.find(key) != largest_upload_size.end() && 1610 if (largest_upload_size.find(key) != largest_upload_size.end() &&
1617 info->GetUploadSize() < largest_upload_size[key]) 1611 progress.size < largest_upload_size[key])
1618 continue; 1612 continue;
1619 1613
1620 net::LoadStateWithParam to_insert = load_state; 1614 net::LoadStateWithParam to_insert = load_state;
1621 LoadInfoMap::iterator existing = info_map.find(key); 1615 LoadInfoMap::iterator existing = info_map.find(key);
1622 if (existing != info_map.end()) { 1616 if (existing != info_map.end()) {
1623 to_insert = 1617 to_insert =
1624 MoreInterestingLoadState(existing->second.load_state, load_state); 1618 MoreInterestingLoadState(existing->second.load_state, load_state);
1625 if (to_insert.state == existing->second.load_state.state) 1619 if (to_insert.state == existing->second.load_state.state)
1626 continue; 1620 continue;
1627 } 1621 }
1628 LoadInfo& load_info = info_map[key]; 1622 LoadInfo& load_info = info_map[key];
1629 load_info.url = request->url(); 1623 load_info.url = request->url();
1630 load_info.load_state = to_insert; 1624 load_info.load_state = to_insert;
1631 load_info.upload_size = info->GetUploadSize(); 1625 load_info.upload_size = progress.size;
1632 load_info.upload_position = request->GetUploadProgress(); 1626 load_info.upload_position = progress.position;
1633 } 1627 }
1634 1628
1635 if (info_map.empty()) 1629 if (info_map.empty())
1636 return; 1630 return;
1637 1631
1638 BrowserThread::PostTask( 1632 BrowserThread::PostTask(
1639 BrowserThread::UI, FROM_HERE, 1633 BrowserThread::UI, FROM_HERE,
1640 base::Bind(&LoadInfoUpdateCallback, info_map)); 1634 base::Bind(&LoadInfoUpdateCallback, info_map));
1641 } 1635 }
1642 1636
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1722
1729 return i->second.get(); 1723 return i->second.get();
1730 } 1724 }
1731 1725
1732 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 1726 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
1733 int request_id) const { 1727 int request_id) const {
1734 return GetLoader(GlobalRequestID(child_id, request_id)); 1728 return GetLoader(GlobalRequestID(child_id, request_id));
1735 } 1729 }
1736 1730
1737 } // namespace content 1731 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698