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

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

Issue 7847027: DownloadId (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 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) 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 15 matching lines...) Expand all
26 #include "content/browser/chrome_blob_storage_context.h" 26 #include "content/browser/chrome_blob_storage_context.h"
27 #include "content/browser/content_browser_client.h" 27 #include "content/browser/content_browser_client.h"
28 #include "content/browser/cross_site_request_manager.h" 28 #include "content/browser/cross_site_request_manager.h"
29 #include "content/browser/download/download_file_manager.h" 29 #include "content/browser/download/download_file_manager.h"
30 #include "content/browser/download/download_manager.h" 30 #include "content/browser/download/download_manager.h"
31 #include "content/browser/download/download_resource_handler.h" 31 #include "content/browser/download/download_resource_handler.h"
32 #include "content/browser/download/save_file_manager.h" 32 #include "content/browser/download/save_file_manager.h"
33 #include "content/browser/download/save_file_resource_handler.h" 33 #include "content/browser/download/save_file_resource_handler.h"
34 #include "content/browser/in_process_webkit/webkit_thread.h" 34 #include "content/browser/in_process_webkit/webkit_thread.h"
35 #include "content/browser/plugin_service.h" 35 #include "content/browser/plugin_service.h"
36 #include "content/browser/resource_context.h"
37 #include "content/browser/renderer_host/async_resource_handler.h" 36 #include "content/browser/renderer_host/async_resource_handler.h"
38 #include "content/browser/renderer_host/buffered_resource_handler.h" 37 #include "content/browser/renderer_host/buffered_resource_handler.h"
39 #include "content/browser/renderer_host/cross_site_resource_handler.h" 38 #include "content/browser/renderer_host/cross_site_resource_handler.h"
40 #include "content/browser/renderer_host/global_request_id.h" 39 #include "content/browser/renderer_host/global_request_id.h"
41 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" 40 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h"
42 #include "content/browser/renderer_host/render_view_host.h" 41 #include "content/browser/renderer_host/render_view_host.h"
43 #include "content/browser/renderer_host/render_view_host_delegate.h" 42 #include "content/browser/renderer_host/render_view_host_delegate.h"
44 #include "content/browser/renderer_host/render_view_host_notification_task.h" 43 #include "content/browser/renderer_host/render_view_host_notification_task.h"
45 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" 44 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h"
46 #include "content/browser/renderer_host/resource_dispatcher_host_login_delegate. h" 45 #include "content/browser/renderer_host/resource_dispatcher_host_login_delegate. h"
47 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 46 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
48 #include "content/browser/renderer_host/resource_message_filter.h" 47 #include "content/browser/renderer_host/resource_message_filter.h"
49 #include "content/browser/renderer_host/resource_queue.h" 48 #include "content/browser/renderer_host/resource_queue.h"
50 #include "content/browser/renderer_host/resource_request_details.h" 49 #include "content/browser/renderer_host/resource_request_details.h"
51 #include "content/browser/renderer_host/sync_resource_handler.h" 50 #include "content/browser/renderer_host/sync_resource_handler.h"
51 #include "content/browser/resource_context.h"
52 #include "content/browser/ssl/ssl_client_auth_handler.h" 52 #include "content/browser/ssl/ssl_client_auth_handler.h"
53 #include "content/browser/ssl/ssl_manager.h" 53 #include "content/browser/ssl/ssl_manager.h"
54 #include "content/browser/worker_host/worker_service.h" 54 #include "content/browser/worker_host/worker_service.h"
55 #include "content/common/content_switches.h" 55 #include "content/common/content_switches.h"
56 #include "content/common/notification_service.h" 56 #include "content/common/notification_service.h"
57 #include "content/common/resource_messages.h" 57 #include "content/common/resource_messages.h"
58 #include "content/common/url_constants.h" 58 #include "content/common/url_constants.h"
59 #include "content/common/view_messages.h" 59 #include "content/common/view_messages.h"
60 #include "net/base/auth.h" 60 #include "net/base/auth.h"
61 #include "net/base/cert_status_flags.h" 61 #include "net/base/cert_status_flags.h"
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 794
795 // We are explicitly forcing the download of 'url'. 795 // We are explicitly forcing the download of 'url'.
796 void ResourceDispatcherHost::BeginDownload( 796 void ResourceDispatcherHost::BeginDownload(
797 net::URLRequest* request, 797 net::URLRequest* request,
798 const DownloadSaveInfo& save_info, 798 const DownloadSaveInfo& save_info,
799 bool prompt_for_save_location, 799 bool prompt_for_save_location,
800 const DownloadResourceHandler::OnStartedCallback& started_cb, 800 const DownloadResourceHandler::OnStartedCallback& started_cb,
801 int child_id, 801 int child_id,
802 int route_id, 802 int route_id,
803 const content::ResourceContext& context) { 803 const content::ResourceContext& context) {
804 static const int kInvalidDownloadId = -1;
805 scoped_ptr<net::URLRequest> delete_request(request); 804 scoped_ptr<net::URLRequest> delete_request(request);
806 // If DownloadResourceHandler is not begun, then started_cb must be called 805 // If DownloadResourceHandler is not begun, then started_cb must be called
807 // here in order to satisfy its semantics. 806 // here in order to satisfy its semantics.
808 if (is_shutdown_) { 807 if (is_shutdown_) {
809 if (!started_cb.is_null()) 808 if (!started_cb.is_null())
810 started_cb.Run(kInvalidDownloadId, net::ERR_INSUFFICIENT_RESOURCES); 809 started_cb.Run(DownloadId::Invalid(), net::ERR_INSUFFICIENT_RESOURCES);
811 // Time and RDH are resources that are running out. 810 // Time and RDH are resources that are running out.
812 return; 811 return;
813 } 812 }
814 const GURL& url = request->original_url(); 813 const GURL& url = request->original_url();
814 const net::URLRequestContext* request_context = context.request_context();
815 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); 815 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
816 request->set_method("GET");
817 request->set_context(request_context);
818 request->set_load_flags(request->load_flags() |
819 net::LOAD_IS_DOWNLOAD);
816 820
817 // Check if the renderer is permitted to request the requested URL. 821 // Check if the renderer is permitted to request the requested URL.
818 if (!ChildProcessSecurityPolicy::GetInstance()-> 822 if (!ChildProcessSecurityPolicy::GetInstance()->
819 CanRequestURL(child_id, url)) { 823 CanRequestURL(child_id, url)) {
820 VLOG(1) << "Denied unauthorized download request for " 824 VLOG(1) << "Denied unauthorized download request for "
821 << url.possibly_invalid_spec(); 825 << url.possibly_invalid_spec();
822 if (!started_cb.is_null()) 826 if (!started_cb.is_null())
823 started_cb.Run(kInvalidDownloadId, net::ERR_ACCESS_DENIED); 827 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED);
824 return; 828 return;
825 } 829 }
826 830
827 request_id_--; 831 request_id_--;
828 832
833 DownloadId dl_id = context.next_download_id_thunk().Run();
834
829 scoped_refptr<ResourceHandler> handler( 835 scoped_refptr<ResourceHandler> handler(
830 new DownloadResourceHandler(this, 836 new DownloadResourceHandler(this,
831 child_id, 837 child_id,
832 route_id, 838 route_id,
833 request_id_, 839 request_id_,
834 url, 840 url,
841 dl_id,
835 download_file_manager_.get(), 842 download_file_manager_.get(),
836 request, 843 request,
837 prompt_for_save_location, 844 prompt_for_save_location,
838 started_cb, 845 started_cb,
839 save_info)); 846 save_info));
840 847
841 if (delegate_) { 848 if (delegate_) {
842 handler = delegate_->DownloadStarting( 849 handler = delegate_->DownloadStarting(
843 handler, context, request, child_id, route_id, request_id_, true, 850 handler, context, request, child_id, route_id, request_id_, true,
844 false); 851 false);
845 } 852 }
846 853
847 const net::URLRequestContext* request_context = context.request_context();
848 if (!request_context->job_factory()->IsHandledURL(url)) { 854 if (!request_context->job_factory()->IsHandledURL(url)) {
849 VLOG(1) << "Download request for unsupported protocol: " 855 VLOG(1) << "Download request for unsupported protocol: "
850 << url.possibly_invalid_spec(); 856 << url.possibly_invalid_spec();
851 if (!started_cb.is_null()) 857 if (!started_cb.is_null())
852 started_cb.Run(kInvalidDownloadId, net::ERR_ACCESS_DENIED); 858 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED);
853 return; 859 return;
854 } 860 }
855 861
856 request->set_context(context.request_context());
857 request->set_load_flags(request->load_flags() |
858 net::LOAD_IS_DOWNLOAD);
859
860 ResourceDispatcherHostRequestInfo* extra_info = 862 ResourceDispatcherHostRequestInfo* extra_info =
861 CreateRequestInfo(handler, child_id, route_id, true, context); 863 CreateRequestInfo(handler, child_id, route_id, true, context);
862 SetRequestInfo(request, extra_info); // Request takes ownership. 864 SetRequestInfo(request, extra_info); // Request takes ownership.
863 865
864 BeginRequestInternal(delete_request.release()); 866 BeginRequestInternal(delete_request.release());
865 } 867 }
866 868
867 // This function is only used for saving feature. 869 // This function is only used for saving feature.
868 void ResourceDispatcherHost::BeginSaveFile( 870 void ResourceDispatcherHost::BeginSaveFile(
869 const GURL& url, 871 const GURL& url,
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; 2151 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS;
2150 } 2152 }
2151 2153
2152 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { 2154 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() {
2153 return allow_cross_origin_auth_prompt_; 2155 return allow_cross_origin_auth_prompt_;
2154 } 2156 }
2155 2157
2156 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { 2158 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) {
2157 allow_cross_origin_auth_prompt_ = value; 2159 allow_cross_origin_auth_prompt_ = value;
2158 } 2160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698