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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2005273002: Move MimeTypeResourceHandler before ThrottlingResourceHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed issue in ResourceDispatcherHostTests Created 4 years, 6 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
OLDNEW
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
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/mime_type_resource_handler.h" 52 #include "content/browser/loader/intercepting_resource_handler.h"
53 #include "content/browser/loader/mime_sniffing_resource_handler.h"
53 #include "content/browser/loader/navigation_resource_handler.h" 54 #include "content/browser/loader/navigation_resource_handler.h"
54 #include "content/browser/loader/navigation_resource_throttle.h" 55 #include "content/browser/loader/navigation_resource_throttle.h"
55 #include "content/browser/loader/navigation_url_loader_impl_core.h" 56 #include "content/browser/loader/navigation_url_loader_impl_core.h"
56 #include "content/browser/loader/power_save_block_resource_throttle.h" 57 #include "content/browser/loader/power_save_block_resource_throttle.h"
57 #include "content/browser/loader/redirect_to_file_resource_handler.h" 58 #include "content/browser/loader/redirect_to_file_resource_handler.h"
58 #include "content/browser/loader/resource_message_filter.h" 59 #include "content/browser/loader/resource_message_filter.h"
59 #include "content/browser/loader/resource_request_info_impl.h" 60 #include "content/browser/loader/resource_request_info_impl.h"
60 #include "content/browser/loader/stream_resource_handler.h" 61 #include "content/browser/loader/stream_resource_handler.h"
61 #include "content/browser/loader/sync_resource_handler.h" 62 #include "content/browser/loader/sync_resource_handler.h"
62 #include "content/browser/loader/throttling_resource_handler.h" 63 #include "content/browser/loader/throttling_resource_handler.h"
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) && 1680 if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) &&
1680 child_id != -1) { 1681 child_id != -1) {
1681 DCHECK(request->url().SchemeIs(url::kBlobScheme)); 1682 DCHECK(request->url().SchemeIs(url::kBlobScheme));
1682 return handler; 1683 return handler;
1683 } 1684 }
1684 1685
1685 PluginService* plugin_service = nullptr; 1686 PluginService* plugin_service = nullptr;
1686 #if defined(ENABLE_PLUGINS) 1687 #if defined(ENABLE_PLUGINS)
1687 plugin_service = PluginService::GetInstance(); 1688 plugin_service = PluginService::GetInstance();
1688 #endif 1689 #endif
1689 // Insert a buffered event handler before the actual one. 1690
1690 handler.reset(new MimeTypeResourceHandler(std::move(handler), this, 1691 // The InterceptingResourceHandler will replace its next handler with an
1691 plugin_service, request)); 1692 // appropriate one based on the MIME type of the response if needed. It
1693 // should be placed at the end of the chain, just before |handler|.
1694 handler.reset(new InterceptingResourceHandler(std::move(handler), this,
1695 plugin_service, request));
1692 1696
1693 ScopedVector<ResourceThrottle> throttles; 1697 ScopedVector<ResourceThrottle> throttles;
1694 1698
1695 // Add a NavigationResourceThrottle for navigations. 1699 // Add a NavigationResourceThrottle for navigations.
1696 // PlzNavigate: the throttle is unnecessary as communication with the UI 1700 // PlzNavigate: the throttle is unnecessary as communication with the UI
1697 // thread is handled by the NavigationURLloader. 1701 // thread is handled by the NavigationURLloader.
1698 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) 1702 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type))
1699 throttles.push_back(new NavigationResourceThrottle(request, delegate())); 1703 throttles.push_back(new NavigationResourceThrottle(request, delegate()));
1700 1704
1701 if (delegate_) { 1705 if (delegate_) {
(...skipping 11 matching lines...) Expand all
1713 } 1717 }
1714 1718
1715 // TODO(ricea): Stop looking this up so much. 1719 // TODO(ricea): Stop looking this up so much.
1716 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1720 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1717 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, 1721 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id,
1718 info->IsAsync(), request)); 1722 info->IsAsync(), request));
1719 1723
1720 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 1724 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
1721 std::move(throttles))); 1725 std::move(throttles)));
1722 1726
1727 // Insert a buffered event handler to sniff the mime type first.
1728 handler.reset(new MimeSniffingResourceHandler(std::move(handler), request));
asanka 2016/06/23 02:30:13 Note that this ResourceHandler is special. Every r
clamy 2016/06/28 16:20:41 Added documentation about this behavior in the com
1729
1723 return handler; 1730 return handler;
1724 } 1731 }
1725 1732
1726 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { 1733 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
1727 UnregisterDownloadedTempFile(filter_->child_id(), request_id); 1734 UnregisterDownloadedTempFile(filter_->child_id(), request_id);
1728 } 1735 }
1729 1736
1730 void ResourceDispatcherHostImpl::OnDidChangePriority( 1737 void ResourceDispatcherHostImpl::OnDidChangePriority(
1731 int request_id, 1738 int request_id,
1732 net::RequestPriority new_priority, 1739 net::RequestPriority new_priority,
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); 2647 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id);
2641 response->head.security_info = SerializeSecurityInfo(ssl); 2648 response->head.security_info = SerializeSecurityInfo(ssl);
2642 } 2649 }
2643 2650
2644 CertStore* ResourceDispatcherHostImpl::GetCertStore() { 2651 CertStore* ResourceDispatcherHostImpl::GetCertStore() {
2645 return cert_store_for_testing_ ? cert_store_for_testing_ 2652 return cert_store_for_testing_ ? cert_store_for_testing_
2646 : CertStore::GetInstance(); 2653 : CertStore::GetInstance();
2647 } 2654 }
2648 2655
2649 } // namespace content 2656 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698