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

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: Chrome Frame fix Created 8 years, 4 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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 954 }
956 955
957 // TODO(darin): Do we really need all of these URLRequest setters in the 956 // TODO(darin): Do we really need all of these URLRequest setters in the
958 // transferred navigation case? 957 // transferred navigation case?
959 958
960 request->set_load_flags(load_flags); 959 request->set_load_flags(load_flags);
961 960
962 request->set_priority(DetermineRequestPriority(request_data.resource_type)); 961 request->set_priority(DetermineRequestPriority(request_data.resource_type));
963 962
964 // Set upload data. 963 // Set upload data.
965 uint64 upload_size = 0; 964 if (request_data.upload_data)
966 if (request_data.upload_data) {
967 request->set_upload(request_data.upload_data); 965 request->set_upload(request_data.upload_data);
968 // This results in performing file IO. crbug.com/112607.
969 base::ThreadRestrictions::ScopedAllowIO allow_io;
970 upload_size = request_data.upload_data->GetContentLengthSync();
971 }
972 966
973 bool allow_download = request_data.allow_download && 967 bool allow_download = request_data.allow_download &&
974 ResourceType::IsFrame(request_data.resource_type); 968 ResourceType::IsFrame(request_data.resource_type);
975 969
976 // Make extra info and read footer (contains request ID). 970 // Make extra info and read footer (contains request ID).
977 ResourceRequestInfoImpl* extra_info = 971 ResourceRequestInfoImpl* extra_info =
978 new ResourceRequestInfoImpl( 972 new ResourceRequestInfoImpl(
979 process_type, 973 process_type,
980 child_id, 974 child_id,
981 route_id, 975 route_id,
982 request_data.origin_pid, 976 request_data.origin_pid,
983 request_id, 977 request_id,
984 request_data.is_main_frame, 978 request_data.is_main_frame,
985 request_data.frame_id, 979 request_data.frame_id,
986 request_data.parent_is_main_frame, 980 request_data.parent_is_main_frame,
987 request_data.parent_frame_id, 981 request_data.parent_frame_id,
988 request_data.resource_type, 982 request_data.resource_type,
989 request_data.transition_type, 983 request_data.transition_type,
990 upload_size,
991 false, // is download 984 false, // is download
992 allow_download, 985 allow_download,
993 request_data.has_user_gesture, 986 request_data.has_user_gesture,
994 request_data.referrer_policy, 987 request_data.referrer_policy,
995 resource_context); 988 resource_context);
996 extra_info->AssociateWithRequest(request); // Request takes ownership. 989 extra_info->AssociateWithRequest(request); // Request takes ownership.
997 990
998 if (request->url().SchemeIs(chrome::kBlobScheme)) { 991 if (request->url().SchemeIs(chrome::kBlobScheme)) {
999 // Hang on to a reference to ensure the blob is not released prior 992 // Hang on to a reference to ensure the blob is not released prior
1000 // to the job being started. 993 // to the job being started.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 child_id, 1173 child_id,
1181 route_id, 1174 route_id,
1182 0, 1175 0,
1183 request_id_, 1176 request_id_,
1184 false, // is_main_frame 1177 false, // is_main_frame
1185 -1, // frame_id 1178 -1, // frame_id
1186 false, // parent_is_main_frame 1179 false, // parent_is_main_frame
1187 -1, // parent_frame_id 1180 -1, // parent_frame_id
1188 ResourceType::SUB_RESOURCE, 1181 ResourceType::SUB_RESOURCE,
1189 PAGE_TRANSITION_LINK, 1182 PAGE_TRANSITION_LINK,
1190 0, // upload_size
1191 download, // is_download 1183 download, // is_download
1192 download, // allow_download 1184 download, // allow_download
1193 false, // has_user_gesture 1185 false, // has_user_gesture
1194 WebKit::WebReferrerPolicyDefault, 1186 WebKit::WebReferrerPolicyDefault,
1195 context); 1187 context);
1196 } 1188 }
1197 1189
1198 void ResourceDispatcherHostImpl::OnSwapOutACK( 1190 void ResourceDispatcherHostImpl::OnSwapOutACK(
1199 const ViewMsg_SwapOut_Params& params) { 1191 const ViewMsg_SwapOut_Params& params) {
1200 // Closes for cross-site transitions are handled such that the cross-site 1192 // Closes for cross-site transitions are handled such that the cross-site
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 LoadInfoMap info_map; 1579 LoadInfoMap info_map;
1588 1580
1589 LoaderMap::const_iterator i; 1581 LoaderMap::const_iterator i;
1590 1582
1591 // Determine the largest upload size of all requests 1583 // Determine the largest upload size of all requests
1592 // in each View (good chance it's zero). 1584 // in each View (good chance it's zero).
1593 std::map<std::pair<int, int>, uint64> largest_upload_size; 1585 std::map<std::pair<int, int>, uint64> largest_upload_size;
1594 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { 1586 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) {
1595 net::URLRequest* request = i->second->request(); 1587 net::URLRequest* request = i->second->request();
1596 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); 1588 ResourceRequestInfoImpl* info = i->second->GetRequestInfo();
1597 uint64 upload_size = info->GetUploadSize(); 1589 uint64 upload_size = i->second->upload_size();
1598 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) 1590 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST)
1599 upload_size = 0; 1591 upload_size = 0;
1600 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); 1592 std::pair<int, int> key(info->GetChildID(), info->GetRouteID());
1601 if (upload_size && largest_upload_size[key] < upload_size) 1593 if (upload_size && largest_upload_size[key] < upload_size)
1602 largest_upload_size[key] = upload_size; 1594 largest_upload_size[key] = upload_size;
1603 } 1595 }
1604 1596
1605 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { 1597 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) {
1606 net::URLRequest* request = i->second->request(); 1598 net::URLRequest* request = i->second->request();
1607 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); 1599 ResourceRequestInfoImpl* info = i->second->GetRequestInfo();
1608 net::LoadStateWithParam load_state = request->GetLoadState(); 1600 net::LoadStateWithParam load_state = request->GetLoadState();
1609 1601
1610 // 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
1611 // progress ipc messages to the plugin process. 1603 // progress ipc messages to the plugin process.
1612 i->second->ReportUploadProgress(); 1604 i->second->ReportUploadProgress();
1613 1605
1614 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); 1606 std::pair<int, int> key(info->GetChildID(), info->GetRouteID());
1615 1607
1616 // 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
1617 // upload progress takes priority for being shown in the status bar. 1609 // upload progress takes priority for being shown in the status bar.
1618 if (largest_upload_size.find(key) != largest_upload_size.end() && 1610 if (largest_upload_size.find(key) != largest_upload_size.end() &&
1619 info->GetUploadSize() < largest_upload_size[key]) 1611 i->second->upload_size() < largest_upload_size[key])
1620 continue; 1612 continue;
1621 1613
1622 net::LoadStateWithParam to_insert = load_state; 1614 net::LoadStateWithParam to_insert = load_state;
1623 LoadInfoMap::iterator existing = info_map.find(key); 1615 LoadInfoMap::iterator existing = info_map.find(key);
1624 if (existing != info_map.end()) { 1616 if (existing != info_map.end()) {
1625 to_insert = 1617 to_insert =
1626 MoreInterestingLoadState(existing->second.load_state, load_state); 1618 MoreInterestingLoadState(existing->second.load_state, load_state);
1627 if (to_insert.state == existing->second.load_state.state) 1619 if (to_insert.state == existing->second.load_state.state)
1628 continue; 1620 continue;
1629 } 1621 }
1630 LoadInfo& load_info = info_map[key]; 1622 LoadInfo& load_info = info_map[key];
1631 load_info.url = request->url(); 1623 load_info.url = request->url();
1632 load_info.load_state = to_insert; 1624 load_info.load_state = to_insert;
1633 load_info.upload_size = info->GetUploadSize(); 1625 load_info.upload_size = i->second->upload_size();
1634 load_info.upload_position = request->GetUploadProgress(); 1626 load_info.upload_position = request->GetUploadProgress();
1635 } 1627 }
1636 1628
1637 if (info_map.empty()) 1629 if (info_map.empty())
1638 return; 1630 return;
1639 1631
1640 BrowserThread::PostTask( 1632 BrowserThread::PostTask(
1641 BrowserThread::UI, FROM_HERE, 1633 BrowserThread::UI, FROM_HERE,
1642 base::Bind(&LoadInfoUpdateCallback, info_map)); 1634 base::Bind(&LoadInfoUpdateCallback, info_map));
1643 } 1635 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 1722
1731 return i->second.get(); 1723 return i->second.get();
1732 } 1724 }
1733 1725
1734 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 1726 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
1735 int request_id) const { 1727 int request_id) const {
1736 return GetLoader(GlobalRequestID(child_id, request_id)); 1728 return GetLoader(GlobalRequestID(child_id, request_id));
1737 } 1729 }
1738 1730
1739 } // namespace content 1731 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698