OLD | NEW |
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/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "content/browser/download/download_resource_handler.h" | 42 #include "content/browser/download/download_resource_handler.h" |
43 #include "content/browser/download/save_file_manager.h" | 43 #include "content/browser/download/save_file_manager.h" |
44 #include "content/browser/download/save_file_resource_handler.h" | 44 #include "content/browser/download/save_file_resource_handler.h" |
45 #include "content/browser/frame_host/frame_tree.h" | 45 #include "content/browser/frame_host/frame_tree.h" |
46 #include "content/browser/frame_host/navigation_request_info.h" | 46 #include "content/browser/frame_host/navigation_request_info.h" |
47 #include "content/browser/frame_host/navigator.h" | 47 #include "content/browser/frame_host/navigator.h" |
48 #include "content/browser/loader/async_resource_handler.h" | 48 #include "content/browser/loader/async_resource_handler.h" |
49 #include "content/browser/loader/async_revalidation_manager.h" | 49 #include "content/browser/loader/async_revalidation_manager.h" |
50 #include "content/browser/loader/cross_site_resource_handler.h" | 50 #include "content/browser/loader/cross_site_resource_handler.h" |
51 #include "content/browser/loader/detachable_resource_handler.h" | 51 #include "content/browser/loader/detachable_resource_handler.h" |
| 52 #include "content/browser/loader/intercepting_resource_handler.h" |
52 #include "content/browser/loader/loader_delegate.h" | 53 #include "content/browser/loader/loader_delegate.h" |
53 #include "content/browser/loader/mime_type_resource_handler.h" | 54 #include "content/browser/loader/mime_sniffing_resource_handler.h" |
54 #include "content/browser/loader/navigation_resource_handler.h" | 55 #include "content/browser/loader/navigation_resource_handler.h" |
55 #include "content/browser/loader/navigation_resource_throttle.h" | 56 #include "content/browser/loader/navigation_resource_throttle.h" |
56 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 57 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
57 #include "content/browser/loader/power_save_block_resource_throttle.h" | 58 #include "content/browser/loader/power_save_block_resource_throttle.h" |
58 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 59 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
59 #include "content/browser/loader/resource_message_filter.h" | 60 #include "content/browser/loader/resource_message_filter.h" |
60 #include "content/browser/loader/resource_request_info_impl.h" | 61 #include "content/browser/loader/resource_request_info_impl.h" |
61 #include "content/browser/loader/stream_resource_handler.h" | 62 #include "content/browser/loader/stream_resource_handler.h" |
62 #include "content/browser/loader/sync_resource_handler.h" | 63 #include "content/browser/loader/sync_resource_handler.h" |
63 #include "content/browser/loader/throttling_resource_handler.h" | 64 #include "content/browser/loader/throttling_resource_handler.h" |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 std::unique_ptr<ResourceHandler> handler) { | 1650 std::unique_ptr<ResourceHandler> handler) { |
1650 // PlzNavigate: do not add ResourceThrottles for main resource requests from | 1651 // PlzNavigate: do not add ResourceThrottles for main resource requests from |
1651 // the renderer. Decisions about the navigation should have been done in the | 1652 // the renderer. Decisions about the navigation should have been done in the |
1652 // initial request. | 1653 // initial request. |
1653 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) && | 1654 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) && |
1654 child_id != -1) { | 1655 child_id != -1) { |
1655 DCHECK(request->url().SchemeIs(url::kBlobScheme)); | 1656 DCHECK(request->url().SchemeIs(url::kBlobScheme)); |
1656 return handler; | 1657 return handler; |
1657 } | 1658 } |
1658 | 1659 |
1659 PluginService* plugin_service = nullptr; | 1660 // The InterceptingResourceHandler will replace its next handler with an |
1660 #if defined(ENABLE_PLUGINS) | 1661 // appropriate one based on the MIME type of the response if needed. It |
1661 plugin_service = PluginService::GetInstance(); | 1662 // should be placed at the end of the chain, just before |handler|. |
1662 #endif | 1663 handler.reset(new InterceptingResourceHandler(std::move(handler), request)); |
1663 // Insert a buffered event handler before the actual one. | 1664 InterceptingResourceHandler* intercepting_handler = |
1664 handler.reset(new MimeTypeResourceHandler(std::move(handler), this, | 1665 static_cast<InterceptingResourceHandler*>(handler.get()); |
1665 plugin_service, request)); | |
1666 | 1666 |
1667 ScopedVector<ResourceThrottle> throttles; | 1667 ScopedVector<ResourceThrottle> throttles; |
1668 | 1668 |
1669 // Add a NavigationResourceThrottle for navigations. | 1669 // Add a NavigationResourceThrottle for navigations. |
1670 // PlzNavigate: the throttle is unnecessary as communication with the UI | 1670 // PlzNavigate: the throttle is unnecessary as communication with the UI |
1671 // thread is handled by the NavigationURLloader. | 1671 // thread is handled by the NavigationURLloader. |
1672 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) | 1672 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) |
1673 throttles.push_back(new NavigationResourceThrottle(request, delegate())); | 1673 throttles.push_back(new NavigationResourceThrottle(request, delegate())); |
1674 | 1674 |
1675 if (delegate_) { | 1675 if (delegate_) { |
(...skipping 13 matching lines...) Expand all Loading... |
1689 } | 1689 } |
1690 | 1690 |
1691 // TODO(ricea): Stop looking this up so much. | 1691 // TODO(ricea): Stop looking this up so much. |
1692 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1692 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1693 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, | 1693 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, |
1694 info->IsAsync(), request)); | 1694 info->IsAsync(), request)); |
1695 | 1695 |
1696 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 1696 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
1697 std::move(throttles))); | 1697 std::move(throttles))); |
1698 | 1698 |
| 1699 PluginService* plugin_service = nullptr; |
| 1700 #if defined(ENABLE_PLUGINS) |
| 1701 plugin_service = PluginService::GetInstance(); |
| 1702 #endif |
| 1703 |
| 1704 // Insert a buffered event handler to sniff the mime type first. |
| 1705 // Note: all ResourceHandler following the MimeSniffingResourceHandler should |
| 1706 // expect OnWillRead to be called *before* OnResponseStarted as part of the |
| 1707 // mime sniffing process. |
| 1708 handler.reset(new MimeSniffingResourceHandler( |
| 1709 std::move(handler), this, plugin_service, intercepting_handler, request)); |
| 1710 |
1699 return handler; | 1711 return handler; |
1700 } | 1712 } |
1701 | 1713 |
1702 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1714 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
1703 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1715 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
1704 } | 1716 } |
1705 | 1717 |
1706 void ResourceDispatcherHostImpl::OnDidChangePriority( | 1718 void ResourceDispatcherHostImpl::OnDidChangePriority( |
1707 int request_id, | 1719 int request_id, |
1708 net::RequestPriority new_priority, | 1720 net::RequestPriority new_priority, |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2608 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
2597 response->head.security_info = SerializeSecurityInfo(ssl); | 2609 response->head.security_info = SerializeSecurityInfo(ssl); |
2598 } | 2610 } |
2599 | 2611 |
2600 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2612 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2601 return cert_store_for_testing_ ? cert_store_for_testing_ | 2613 return cert_store_for_testing_ ? cert_store_for_testing_ |
2602 : CertStore::GetInstance(); | 2614 : CertStore::GetInstance(); |
2603 } | 2615 } |
2604 | 2616 |
2605 } // namespace content | 2617 } // namespace content |
OLD | NEW |