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

Unified 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: Addressed comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index fb12a9b95407a2d9276c7bbe9279646f22f837d8..fb587bd22889f7dfa2f937eb7b1c5fafca5706d5 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -49,8 +49,9 @@
#include "content/browser/loader/async_revalidation_manager.h"
#include "content/browser/loader/cross_site_resource_handler.h"
#include "content/browser/loader/detachable_resource_handler.h"
+#include "content/browser/loader/intercepting_resource_handler.h"
#include "content/browser/loader/loader_delegate.h"
-#include "content/browser/loader/mime_type_resource_handler.h"
+#include "content/browser/loader/mime_sniffing_resource_handler.h"
#include "content/browser/loader/navigation_resource_handler.h"
#include "content/browser/loader/navigation_resource_throttle.h"
#include "content/browser/loader/navigation_url_loader_impl_core.h"
@@ -1656,13 +1657,12 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
return handler;
}
- PluginService* plugin_service = nullptr;
-#if defined(ENABLE_PLUGINS)
- plugin_service = PluginService::GetInstance();
-#endif
- // Insert a buffered event handler before the actual one.
- handler.reset(new MimeTypeResourceHandler(std::move(handler), this,
- plugin_service, request));
+ // The InterceptingResourceHandler will replace its next handler with an
+ // appropriate one based on the MIME type of the response if needed. It
+ // should be placed at the end of the chain, just before |handler|.
+ handler.reset(new InterceptingResourceHandler(std::move(handler), request));
+ InterceptingResourceHandler* intercepting_handler =
+ static_cast<InterceptingResourceHandler*>(handler.get());
ScopedVector<ResourceThrottle> throttles;
@@ -1696,6 +1696,18 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
std::move(throttles)));
+ PluginService* plugin_service = nullptr;
+#if defined(ENABLE_PLUGINS)
+ plugin_service = PluginService::GetInstance();
+#endif
+
+ // Insert a buffered event handler to sniff the mime type first.
+ // Note: all ResourceHandler following the MimeSniffingResourceHandler should
+ // expect OnWillRead to be called *before* OnResponseStarted as part of the
+ // mime sniffing process.
+ handler.reset(new MimeSniffingResourceHandler(
+ std::move(handler), this, plugin_service, intercepting_handler, request));
+
return handler;
}

Powered by Google App Engine
This is Rietveld 408576698