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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.cc

Issue 164305: Ensure we don't load plugins on the IO thread (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 : ui_loop_(MessageLoop::current()), 247 : ui_loop_(MessageLoop::current()),
248 io_loop_(io_loop), 248 io_loop_(io_loop),
249 ALLOW_THIS_IN_INITIALIZER_LIST( 249 ALLOW_THIS_IN_INITIALIZER_LIST(
250 download_file_manager_(new DownloadFileManager(ui_loop_, this))), 250 download_file_manager_(new DownloadFileManager(ui_loop_, this))),
251 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)), 251 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)),
252 ALLOW_THIS_IN_INITIALIZER_LIST( 252 ALLOW_THIS_IN_INITIALIZER_LIST(
253 save_file_manager_(new SaveFileManager(ui_loop_, io_loop, this))), 253 save_file_manager_(new SaveFileManager(ui_loop_, io_loop, this))),
254 safe_browsing_(new SafeBrowsingService), 254 safe_browsing_(new SafeBrowsingService),
255 webkit_thread_(new WebKitThread), 255 webkit_thread_(new WebKitThread),
256 request_id_(-1), 256 request_id_(-1),
257 plugin_service_(PluginService::GetInstance()),
258 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), 257 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)),
259 is_shutdown_(false), 258 is_shutdown_(false),
260 max_outstanding_requests_cost_per_process_( 259 max_outstanding_requests_cost_per_process_(
261 kMaxOutstandingRequestsCostPerProcess), 260 kMaxOutstandingRequestsCostPerProcess),
262 receiver_(NULL) { 261 receiver_(NULL) {
263 } 262 }
264 263
265 ResourceDispatcherHost::~ResourceDispatcherHost() { 264 ResourceDispatcherHost::~ResourceDispatcherHost() {
266 AsyncResourceHandler::GlobalCleanup(); 265 AsyncResourceHandler::GlobalCleanup();
267 STLDeleteValues(&pending_requests_); 266 STLDeleteValues(&pending_requests_);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 std::string())); 458 std::string()));
460 } 459 }
461 } 460 }
462 return; 461 return;
463 } 462 }
464 463
465 // Ensure the Chrome plugins are loaded, as they may intercept network 464 // Ensure the Chrome plugins are loaded, as they may intercept network
466 // requests. Does nothing if they are already loaded. 465 // requests. Does nothing if they are already loaded.
467 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by 466 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by
468 // starting the load earlier in a BG thread. 467 // starting the load earlier in a BG thread.
469 plugin_service_->LoadChromePlugins(this); 468 PluginService::GetInstance()->LoadChromePlugins(this);
470 469
471 // Construct the event handler. 470 // Construct the event handler.
472 scoped_refptr<ResourceHandler> handler; 471 scoped_refptr<ResourceHandler> handler;
473 if (sync_result) { 472 if (sync_result) {
474 handler = new SyncResourceHandler(receiver_, request_data.url, sync_result); 473 handler = new SyncResourceHandler(receiver_, request_data.url, sync_result);
475 } else { 474 } else {
476 handler = new AsyncResourceHandler(receiver_, 475 handler = new AsyncResourceHandler(receiver_,
477 process_id, 476 process_id,
478 route_id, 477 route_id,
479 receiver_->handle(), 478 receiver_->handle(),
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // Check if the renderer is permitted to request the requested URL. 658 // Check if the renderer is permitted to request the requested URL.
660 if (!ChildProcessSecurityPolicy::GetInstance()-> 659 if (!ChildProcessSecurityPolicy::GetInstance()->
661 CanRequestURL(process_id, url)) { 660 CanRequestURL(process_id, url)) {
662 LOG(INFO) << "Denied unauthorized download request for " << 661 LOG(INFO) << "Denied unauthorized download request for " <<
663 url.possibly_invalid_spec(); 662 url.possibly_invalid_spec();
664 return; 663 return;
665 } 664 }
666 665
667 // Ensure the Chrome plugins are loaded, as they may intercept network 666 // Ensure the Chrome plugins are loaded, as they may intercept network
668 // requests. Does nothing if they are already loaded. 667 // requests. Does nothing if they are already loaded.
669 plugin_service_->LoadChromePlugins(this); 668 PluginService::GetInstance()->LoadChromePlugins(this);
670 URLRequest* request = new URLRequest(url, this); 669 URLRequest* request = new URLRequest(url, this);
671 670
672 request_id_--; 671 request_id_--;
673 672
674 scoped_refptr<ResourceHandler> handler = 673 scoped_refptr<ResourceHandler> handler =
675 new DownloadResourceHandler(this, 674 new DownloadResourceHandler(this,
676 process_id, 675 process_id,
677 route_id, 676 route_id,
678 request_id_, 677 request_id_,
679 url, 678 url,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 void ResourceDispatcherHost::BeginSaveFile(const GURL& url, 724 void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
726 const GURL& referrer, 725 const GURL& referrer,
727 int process_id, 726 int process_id,
728 int route_id, 727 int route_id,
729 URLRequestContext* request_context) { 728 URLRequestContext* request_context) {
730 if (is_shutdown_) 729 if (is_shutdown_)
731 return; 730 return;
732 731
733 // Ensure the Chrome plugins are loaded, as they may intercept network 732 // Ensure the Chrome plugins are loaded, as they may intercept network
734 // requests. Does nothing if they are already loaded. 733 // requests. Does nothing if they are already loaded.
735 plugin_service_->LoadChromePlugins(this); 734 PluginService::GetInstance()->LoadChromePlugins(this);
736 735
737 scoped_refptr<ResourceHandler> handler = 736 scoped_refptr<ResourceHandler> handler =
738 new SaveFileResourceHandler(process_id, 737 new SaveFileResourceHandler(process_id,
739 route_id, 738 route_id,
740 url, 739 url,
741 save_file_manager_.get()); 740 save_file_manager_.get());
742 request_id_--; 741 request_id_--;
743 742
744 bool known_proto = URLRequest::IsHandledURL(url); 743 bool known_proto = URLRequest::IsHandledURL(url);
745 if (!known_proto) { 744 if (!known_proto) {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 request->Start(); 1250 request->Start();
1252 1251
1253 // Make sure we have the load state monitor running 1252 // Make sure we have the load state monitor running
1254 if (!update_load_states_timer_.IsRunning()) { 1253 if (!update_load_states_timer_.IsRunning()) {
1255 update_load_states_timer_.Start( 1254 update_load_states_timer_.Start(
1256 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), 1255 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec),
1257 this, &ResourceDispatcherHost::UpdateLoadStates); 1256 this, &ResourceDispatcherHost::UpdateLoadStates);
1258 } 1257 }
1259 } 1258 }
1260 1259
1261 // This test mirrors the decision that WebKit makes in
1262 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType.
1263 // static.
1264 bool ResourceDispatcherHost::ShouldDownload(
1265 const std::string& mime_type, const std::string& content_disposition) {
1266 std::string type = StringToLowerASCII(mime_type);
1267 std::string disposition = StringToLowerASCII(content_disposition);
1268
1269 // First, examine content-disposition.
1270 if (!disposition.empty()) {
1271 bool should_download = true;
1272
1273 // Some broken sites just send ...
1274 // Content-Disposition: ; filename="file"
1275 // ... screen those out here.
1276 if (disposition[0] == ';')
1277 should_download = false;
1278
1279 if (disposition.compare(0, 6, "inline") == 0)
1280 should_download = false;
1281
1282 // Some broken sites just send ...
1283 // Content-Disposition: filename="file"
1284 // ... without a disposition token... Screen those out.
1285 if (disposition.compare(0, 8, "filename") == 0)
1286 should_download = false;
1287
1288 // Also in use is Content-Disposition: name="file"
1289 if (disposition.compare(0, 4, "name") == 0)
1290 should_download = false;
1291
1292 // We have a content-disposition of "attachment" or unknown.
1293 // RFC 2183, section 2.8 says that an unknown disposition
1294 // value should be treated as "attachment".
1295 if (should_download)
1296 return true;
1297 }
1298
1299 // MIME type checking.
1300 if (net::IsSupportedMimeType(type))
1301 return false;
1302
1303 // Finally, check the plugin service.
1304 bool allow_wildcard = false;
1305 return !plugin_service_->HavePluginFor(type, allow_wildcard);
1306 }
1307
1308 bool ResourceDispatcherHost::PauseRequestIfNeeded(ExtraRequestInfo* info) { 1260 bool ResourceDispatcherHost::PauseRequestIfNeeded(ExtraRequestInfo* info) {
1309 if (info->pause_count > 0) 1261 if (info->pause_count > 0)
1310 info->is_paused = true; 1262 info->is_paused = true;
1311 1263
1312 return info->is_paused; 1264 return info->is_paused;
1313 } 1265 }
1314 1266
1315 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) { 1267 void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) {
1316 PendingRequestList::iterator i = pending_requests_.find(request_id); 1268 PendingRequestList::iterator i = pending_requests_.find(request_id);
1317 if (i == pending_requests_.end()) // The request may have been destroyed 1269 if (i == pending_requests_.end()) // The request may have been destroyed
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 case ViewHostMsg_UploadProgress_ACK::ID: 1691 case ViewHostMsg_UploadProgress_ACK::ID:
1740 case ViewHostMsg_SyncLoad::ID: 1692 case ViewHostMsg_SyncLoad::ID:
1741 return true; 1693 return true;
1742 1694
1743 default: 1695 default:
1744 break; 1696 break;
1745 } 1697 }
1746 1698
1747 return false; 1699 return false;
1748 } 1700 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_dispatcher_host.h ('k') | chrome/browser/renderer_host/resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698