OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 filter_->Send(new ViewMsg_Resource_RequestComplete( | 386 filter_->Send(new ViewMsg_Resource_RequestComplete( |
387 route_id, | 387 route_id, |
388 request_id, | 388 request_id, |
389 status, | 389 status, |
390 std::string(), // No security info needed, connection was not | 390 std::string(), // No security info needed, connection was not |
391 base::Time())); // established. | 391 base::Time())); // established. |
392 } | 392 } |
393 return; | 393 return; |
394 } | 394 } |
395 | 395 |
396 // Ensure the Chrome plugins are loaded, as they may intercept network | |
397 // requests. Does nothing if they are already loaded. | |
398 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by | |
399 // starting the load earlier in a BG thread. | |
400 PluginService::GetInstance()->LoadChromePlugins(this); | |
401 | |
402 // Construct the event handler. | 396 // Construct the event handler. |
403 scoped_refptr<ResourceHandler> handler; | 397 scoped_refptr<ResourceHandler> handler; |
404 if (sync_result) { | 398 if (sync_result) { |
405 handler = new SyncResourceHandler( | 399 handler = new SyncResourceHandler( |
406 filter_, request_data.url, sync_result, this); | 400 filter_, request_data.url, sync_result, this); |
407 } else { | 401 } else { |
408 handler = new AsyncResourceHandler( | 402 handler = new AsyncResourceHandler( |
409 filter_, route_id, request_data.url, this); | 403 filter_, route_id, request_data.url, this); |
410 } | 404 } |
411 | 405 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 new ResourceDispatcherHostRequestInfo( | 505 new ResourceDispatcherHostRequestInfo( |
512 handler, | 506 handler, |
513 process_type, | 507 process_type, |
514 child_id, | 508 child_id, |
515 route_id, | 509 route_id, |
516 request_id, | 510 request_id, |
517 request_data.resource_type, | 511 request_data.resource_type, |
518 upload_size, | 512 upload_size, |
519 false, // is download | 513 false, // is download |
520 ResourceType::IsFrame(request_data.resource_type), // allow_download | 514 ResourceType::IsFrame(request_data.resource_type), // allow_download |
521 request_data.has_user_gesture, | 515 request_data.has_user_gesture); |
522 request_data.host_renderer_id, | |
523 request_data.host_render_view_id); | |
524 ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type, | 516 ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type, |
525 extra_info); | 517 extra_info); |
526 SetRequestInfo(request, extra_info); // Request takes ownership. | 518 SetRequestInfo(request, extra_info); // Request takes ownership. |
527 chrome_browser_net::SetOriginPIDForRequest( | 519 chrome_browser_net::SetOriginPIDForRequest( |
528 request_data.origin_pid, request); | 520 request_data.origin_pid, request); |
529 | 521 |
530 if (request->url().SchemeIs(chrome::kBlobScheme) && context) { | 522 if (request->url().SchemeIs(chrome::kBlobScheme) && context) { |
531 // Hang on to a reference to ensure the blob is not released prior | 523 // Hang on to a reference to ensure the blob is not released prior |
532 // to the job being started. | 524 // to the job being started. |
533 webkit_blob::BlobStorageController* controller = | 525 webkit_blob::BlobStorageController* controller = |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 ResourceHandler* handler, int child_id, int route_id, bool download) { | 634 ResourceHandler* handler, int child_id, int route_id, bool download) { |
643 return new ResourceDispatcherHostRequestInfo(handler, | 635 return new ResourceDispatcherHostRequestInfo(handler, |
644 ChildProcessInfo::RENDER_PROCESS, | 636 ChildProcessInfo::RENDER_PROCESS, |
645 child_id, | 637 child_id, |
646 route_id, | 638 route_id, |
647 request_id_, | 639 request_id_, |
648 ResourceType::SUB_RESOURCE, | 640 ResourceType::SUB_RESOURCE, |
649 0, // upload_size | 641 0, // upload_size |
650 download, // is_download | 642 download, // is_download |
651 download, // allow_download | 643 download, // allow_download |
652 false, // has_user_gesture | 644 false); // has_user_gesture |
653 -1, // host renderer id | |
654 -1); // host render view id | |
655 } | 645 } |
656 | 646 |
657 void ResourceDispatcherHost::OnClosePageACK( | 647 void ResourceDispatcherHost::OnClosePageACK( |
658 const ViewMsg_ClosePage_Params& params) { | 648 const ViewMsg_ClosePage_Params& params) { |
659 if (params.for_cross_site_transition) { | 649 if (params.for_cross_site_transition) { |
660 // Closes for cross-site transitions are handled such that the cross-site | 650 // Closes for cross-site transitions are handled such that the cross-site |
661 // transition continues. | 651 // transition continues. |
662 GlobalRequestID global_id(params.new_render_process_host_id, | 652 GlobalRequestID global_id(params.new_render_process_host_id, |
663 params.new_request_id); | 653 params.new_request_id); |
664 PendingRequestList::iterator i = pending_requests_.find(global_id); | 654 PendingRequestList::iterator i = pending_requests_.find(global_id); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 VLOG(1) << "Denied unauthorized download request for " | 686 VLOG(1) << "Denied unauthorized download request for " |
697 << url.possibly_invalid_spec(); | 687 << url.possibly_invalid_spec(); |
698 return; | 688 return; |
699 } | 689 } |
700 | 690 |
701 BrowserThread::PostTask( | 691 BrowserThread::PostTask( |
702 BrowserThread::UI, FROM_HERE, | 692 BrowserThread::UI, FROM_HERE, |
703 NewRunnableFunction(&download_util::NotifyDownloadInitiated, | 693 NewRunnableFunction(&download_util::NotifyDownloadInitiated, |
704 child_id, route_id)); | 694 child_id, route_id)); |
705 | 695 |
706 // Ensure the Chrome plugins are loaded, as they may intercept network | |
707 // requests. Does nothing if they are already loaded. | |
708 PluginService::GetInstance()->LoadChromePlugins(this); | |
709 net::URLRequest* request = new net::URLRequest(url, this); | 696 net::URLRequest* request = new net::URLRequest(url, this); |
710 | 697 |
711 request_id_--; | 698 request_id_--; |
712 | 699 |
713 scoped_refptr<ResourceHandler> handler( | 700 scoped_refptr<ResourceHandler> handler( |
714 new DownloadResourceHandler(this, | 701 new DownloadResourceHandler(this, |
715 child_id, | 702 child_id, |
716 route_id, | 703 route_id, |
717 request_id_, | 704 request_id_, |
718 url, | 705 url, |
(...skipping 30 matching lines...) Expand all Loading... |
749 // This function is only used for saving feature. | 736 // This function is only used for saving feature. |
750 void ResourceDispatcherHost::BeginSaveFile( | 737 void ResourceDispatcherHost::BeginSaveFile( |
751 const GURL& url, | 738 const GURL& url, |
752 const GURL& referrer, | 739 const GURL& referrer, |
753 int child_id, | 740 int child_id, |
754 int route_id, | 741 int route_id, |
755 net::URLRequestContext* request_context) { | 742 net::URLRequestContext* request_context) { |
756 if (is_shutdown_) | 743 if (is_shutdown_) |
757 return; | 744 return; |
758 | 745 |
759 // Ensure the Chrome plugins are loaded, as they may intercept network | |
760 // requests. Does nothing if they are already loaded. | |
761 PluginService::GetInstance()->LoadChromePlugins(this); | |
762 | |
763 scoped_refptr<ResourceHandler> handler( | 746 scoped_refptr<ResourceHandler> handler( |
764 new SaveFileResourceHandler(child_id, | 747 new SaveFileResourceHandler(child_id, |
765 route_id, | 748 route_id, |
766 url, | 749 url, |
767 save_file_manager_.get())); | 750 save_file_manager_.get())); |
768 request_id_--; | 751 request_id_--; |
769 | 752 |
770 bool known_proto = net::URLRequest::IsHandledURL(url); | 753 bool known_proto = net::URLRequest::IsHandledURL(url); |
771 if (!known_proto) { | 754 if (!known_proto) { |
772 // Since any URLs which have non-standard scheme have been filtered | 755 // Since any URLs which have non-standard scheme have been filtered |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 return is_prefetch_enabled_; | 1927 return is_prefetch_enabled_; |
1945 } | 1928 } |
1946 | 1929 |
1947 // static | 1930 // static |
1948 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1931 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
1949 is_prefetch_enabled_ = value; | 1932 is_prefetch_enabled_ = value; |
1950 } | 1933 } |
1951 | 1934 |
1952 // static | 1935 // static |
1953 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1936 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
OLD | NEW |