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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/shared_memory.h" | 19 #include "base/shared_memory.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "chrome/browser/download/download_request_limiter.h" | |
22 #include "chrome/browser/download/download_util.h" | 21 #include "chrome/browser/download/download_util.h" |
23 #include "content/browser/appcache/chrome_appcache_service.h" | 22 #include "content/browser/appcache/chrome_appcache_service.h" |
24 #include "content/browser/cert_store.h" | 23 #include "content/browser/cert_store.h" |
25 #include "content/browser/child_process_security_policy.h" | 24 #include "content/browser/child_process_security_policy.h" |
26 #include "content/browser/chrome_blob_storage_context.h" | 25 #include "content/browser/chrome_blob_storage_context.h" |
27 #include "content/browser/content_browser_client.h" | 26 #include "content/browser/content_browser_client.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_manager.h" | 29 #include "content/browser/download/download_manager.h" |
31 #include "content/browser/download/download_resource_handler.h" | 30 #include "content/browser/download/download_resource_handler.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 #pragma optimize("", on) | 233 #pragma optimize("", on) |
235 #pragma warning(default: 4748) | 234 #pragma warning(default: 4748) |
236 #endif | 235 #endif |
237 | 236 |
238 } // namespace | 237 } // namespace |
239 | 238 |
240 ResourceDispatcherHost::ResourceDispatcherHost( | 239 ResourceDispatcherHost::ResourceDispatcherHost( |
241 const ResourceQueue::DelegateSet& resource_queue_delegates) | 240 const ResourceQueue::DelegateSet& resource_queue_delegates) |
242 : ALLOW_THIS_IN_INITIALIZER_LIST( | 241 : ALLOW_THIS_IN_INITIALIZER_LIST( |
243 download_file_manager_(new DownloadFileManager(this))), | 242 download_file_manager_(new DownloadFileManager(this))), |
244 download_request_limiter_(new DownloadRequestLimiter()), | |
245 ALLOW_THIS_IN_INITIALIZER_LIST( | 243 ALLOW_THIS_IN_INITIALIZER_LIST( |
246 save_file_manager_(new SaveFileManager(this))), | 244 save_file_manager_(new SaveFileManager(this))), |
247 webkit_thread_(new WebKitThread), | 245 webkit_thread_(new WebKitThread), |
248 request_id_(-1), | 246 request_id_(-1), |
249 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), | 247 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), |
250 is_shutdown_(false), | 248 is_shutdown_(false), |
251 max_outstanding_requests_cost_per_process_( | 249 max_outstanding_requests_cost_per_process_( |
252 kMaxOutstandingRequestsCostPerProcess), | 250 kMaxOutstandingRequestsCostPerProcess), |
253 filter_(NULL), | 251 filter_(NULL), |
254 delegate_(NULL), | 252 delegate_(NULL), |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 child_id, | 736 child_id, |
739 route_id, | 737 route_id, |
740 request_id_, | 738 request_id_, |
741 url, | 739 url, |
742 download_file_manager_.get(), | 740 download_file_manager_.get(), |
743 request, | 741 request, |
744 prompt_for_save_location, | 742 prompt_for_save_location, |
745 save_info)); | 743 save_info)); |
746 | 744 |
747 if (delegate_) { | 745 if (delegate_) { |
748 handler = delegate_->DownloadStarting(handler, context, child_id, | 746 handler = delegate_->DownloadStarting( |
749 route_id); | 747 handler, context, request, child_id, route_id, request_id_, true, |
| 748 false); |
750 } | 749 } |
751 | 750 |
752 const net::URLRequestContext* request_context = context.request_context(); | 751 const net::URLRequestContext* request_context = context.request_context(); |
753 | 752 |
754 if (!request_context->job_factory()->IsHandledURL(url)) { | 753 if (!request_context->job_factory()->IsHandledURL(url)) { |
755 VLOG(1) << "Download request for unsupported protocol: " | 754 VLOG(1) << "Download request for unsupported protocol: " |
756 << url.possibly_invalid_spec(); | 755 << url.possibly_invalid_spec(); |
757 return; | 756 return; |
758 } | 757 } |
759 | 758 |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 security_info)) { | 1680 security_info)) { |
1682 | 1681 |
1683 // The request is complete so we can remove it. | 1682 // The request is complete so we can remove it. |
1684 RemovePendingRequest(info->child_id(), info->request_id()); | 1683 RemovePendingRequest(info->child_id(), info->request_id()); |
1685 } | 1684 } |
1686 // If the handler's OnResponseCompleted returns false, we are deferring the | 1685 // If the handler's OnResponseCompleted returns false, we are deferring the |
1687 // call until later. We will notify the world and clean up when we resume. | 1686 // call until later. We will notify the world and clean up when we resume. |
1688 } | 1687 } |
1689 | 1688 |
1690 void ResourceDispatcherHost::OnUserGesture(TabContents* tab) { | 1689 void ResourceDispatcherHost::OnUserGesture(TabContents* tab) { |
1691 download_request_limiter()->OnUserGesture(tab); | |
1692 | |
1693 last_user_gesture_time_ = TimeTicks::Now(); | 1690 last_user_gesture_time_ = TimeTicks::Now(); |
1694 } | 1691 } |
1695 | 1692 |
1696 // static | 1693 // static |
1697 ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( | 1694 ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( |
1698 net::URLRequest* request) { | 1695 net::URLRequest* request) { |
1699 // Avoid writing this function twice by casting the const version. | 1696 // Avoid writing this function twice by casting the const version. |
1700 const net::URLRequest* const_request = request; | 1697 const net::URLRequest* const_request = request; |
1701 return const_cast<ResourceDispatcherHostRequestInfo*>( | 1698 return const_cast<ResourceDispatcherHostRequestInfo*>( |
1702 InfoForRequest(const_request)); | 1699 InfoForRequest(const_request)); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; | 2113 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; |
2117 } | 2114 } |
2118 | 2115 |
2119 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { | 2116 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
2120 return allow_cross_origin_auth_prompt_; | 2117 return allow_cross_origin_auth_prompt_; |
2121 } | 2118 } |
2122 | 2119 |
2123 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { | 2120 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
2124 allow_cross_origin_auth_prompt_ = value; | 2121 allow_cross_origin_auth_prompt_ = value; |
2125 } | 2122 } |
OLD | NEW |