From 664a8fdbd60bded25e75df544dec29ec7e1ce794 Mon Sep 17 00:00:00 2001 From: mmenke Date: Fri, 12 Jun 2015 17:08:51 -0700 Subject: [PATCH] Rename BufferedResourceHandler to MimeTypeResourceHandler. The old name had little to do with the purpose of the class, which was confusing. Also update comments slightly. BUG=none Review URL: https://codereview.chromium.org/1165323003 Cr-Commit-Position: refs/heads/master@{#334290} --- .../browser/frame_host/render_frame_host_manager.h | 2 +- .../browser/loader/detachable_resource_handler.cc | 2 +- ...ce_handler.cc => mime_type_resource_handler.cc} | 54 +++++++++++----------- ...urce_handler.h => mime_type_resource_handler.h} | 28 +++++++---- ...t.cc => mime_type_resource_handler_unittest.cc} | 18 ++++---- .../browser/loader/navigation_resource_handler.cc | 4 +- .../loader/redirect_to_file_resource_handler.cc | 6 +-- .../loader/resource_dispatcher_host_impl.cc | 7 ++- .../browser/loader/resource_dispatcher_host_impl.h | 2 +- .../loader/resource_dispatcher_host_unittest.cc | 26 +++++------ content/browser/loader/resource_loader.cc | 4 +- content/browser/loader/stream_writer.h | 2 +- content/content_browser.gypi | 4 +- content/content_tests.gypi | 2 +- 14 files changed, 84 insertions(+), 77 deletions(-) rename content/browser/loader/{buffered_resource_handler.cc => mime_type_resource_handler.cc} (90%) rename content/browser/loader/{buffered_resource_handler.h => mime_type_resource_handler.h} (74%) rename content/browser/loader/{buffered_resource_handler_unittest.cc => mime_type_resource_handler_unittest.cc} (94%) diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h index 9b28575a1ab9..5f68a13d8a20 100644 --- a/content/browser/frame_host/render_frame_host_manager.h +++ b/content/browser/frame_host/render_frame_host_manager.h @@ -70,7 +70,7 @@ struct FrameReplicationState; // CrossSiteResourceHandler to check whether a process transfer is needed when // the request is ready to commit. // -// - When RDH receives a response, the BufferedResourceHandler determines +// - When RDH receives a response, the MimeTypeResourceHandler determines // whether it is a navigation type that doesn't commit (e.g. download, 204 or // error page). If so, it sends a message to the new renderer causing it to // cancel the request, and the request (e.g. the download) proceeds. In this diff --git a/content/browser/loader/detachable_resource_handler.cc b/content/browser/loader/detachable_resource_handler.cc index ab7e240b1ee0..faff31cc0ea4 100644 --- a/content/browser/loader/detachable_resource_handler.cc +++ b/content/browser/loader/detachable_resource_handler.cc @@ -49,7 +49,7 @@ void DetachableResourceHandler::Detach() { DCHECK(!defer_ignored); // If |next_handler_| were to defer its shutdown in OnResponseCompleted, // this would destroy it anyway. Fortunately, AsyncResourceHandler never - // does this anyway, so DCHECK it. BufferedResourceHandler and RVH shutdown + // does this anyway, so DCHECK it. MimeTypeResourceHandler and RVH shutdown // already ignore deferred ResourceHandler shutdown, but // DetachableResourceHandler and the detach-on-renderer-cancel logic // introduces a case where this occurs when the renderer cancels a resource. diff --git a/content/browser/loader/buffered_resource_handler.cc b/content/browser/loader/mime_type_resource_handler.cc similarity index 90% rename from content/browser/loader/buffered_resource_handler.cc rename to content/browser/loader/mime_type_resource_handler.cc index 5a18072c677f..576d81fa9423 100644 --- a/content/browser/loader/buffered_resource_handler.cc +++ b/content/browser/loader/mime_type_resource_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/loader/buffered_resource_handler.h" +#include "content/browser/loader/mime_type_resource_handler.h" #include @@ -81,7 +81,7 @@ class DependentIOBuffer : public net::WrappedIOBuffer { } // namespace -BufferedResourceHandler::BufferedResourceHandler( +MimeTypeResourceHandler::MimeTypeResourceHandler( scoped_ptr next_handler, ResourceDispatcherHostImpl* host, PluginService* plugin_service, @@ -97,10 +97,10 @@ BufferedResourceHandler::BufferedResourceHandler( weak_ptr_factory_(this) { } -BufferedResourceHandler::~BufferedResourceHandler() { +MimeTypeResourceHandler::~MimeTypeResourceHandler() { } -void BufferedResourceHandler::SetController(ResourceController* controller) { +void MimeTypeResourceHandler::SetController(ResourceController* controller) { ResourceHandler::SetController(controller); // Downstream handlers see us as their ResourceController, which allows us to @@ -110,7 +110,7 @@ void BufferedResourceHandler::SetController(ResourceController* controller) { next_handler_->SetController(this); } -bool BufferedResourceHandler::OnResponseStarted(ResourceResponse* response, +bool MimeTypeResourceHandler::OnResponseStarted(ResourceResponse* response, bool* defer) { response_ = response; @@ -142,9 +142,7 @@ bool BufferedResourceHandler::OnResponseStarted(ResourceResponse* response, return ProcessResponse(defer); } -// We'll let the original event handler provide a buffer, and reuse it for -// subsequent reads until we're done buffering. -bool BufferedResourceHandler::OnWillRead(scoped_refptr* buf, +bool MimeTypeResourceHandler::OnWillRead(scoped_refptr* buf, int* buf_size, int min_size) { if (state_ == STATE_STREAMING) @@ -167,7 +165,7 @@ bool BufferedResourceHandler::OnWillRead(scoped_refptr* buf, return true; } -bool BufferedResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { +bool MimeTypeResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { if (state_ == STATE_STREAMING) return next_handler_->OnReadCompleted(bytes_read, defer); @@ -181,7 +179,7 @@ bool BufferedResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { return ProcessResponse(defer); } -void BufferedResourceHandler::OnResponseCompleted( +void MimeTypeResourceHandler::OnResponseCompleted( const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -192,7 +190,7 @@ void BufferedResourceHandler::OnResponseCompleted( next_handler_->OnResponseCompleted(status, security_info, defer); } -void BufferedResourceHandler::Resume() { +void MimeTypeResourceHandler::Resume() { switch (state_) { case STATE_BUFFERING: case STATE_PROCESSING: @@ -201,7 +199,7 @@ void BufferedResourceHandler::Resume() { case STATE_REPLAYING: base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind(&BufferedResourceHandler::CallReplayReadCompleted, + base::Bind(&MimeTypeResourceHandler::CallReplayReadCompleted, weak_ptr_factory_.GetWeakPtr())); break; case STATE_STARTING: @@ -211,19 +209,19 @@ void BufferedResourceHandler::Resume() { } } -void BufferedResourceHandler::Cancel() { +void MimeTypeResourceHandler::Cancel() { controller()->Cancel(); } -void BufferedResourceHandler::CancelAndIgnore() { +void MimeTypeResourceHandler::CancelAndIgnore() { controller()->CancelAndIgnore(); } -void BufferedResourceHandler::CancelWithError(int error_code) { +void MimeTypeResourceHandler::CancelWithError(int error_code) { controller()->CancelWithError(error_code); } -bool BufferedResourceHandler::ProcessResponse(bool* defer) { +bool MimeTypeResourceHandler::ProcessResponse(bool* defer) { DCHECK_EQ(STATE_PROCESSING, state_); // TODO(darin): Stop special-casing 304 responses. @@ -251,7 +249,7 @@ bool BufferedResourceHandler::ProcessResponse(bool* defer) { return true; } -bool BufferedResourceHandler::ShouldSniffContent() { +bool MimeTypeResourceHandler::ShouldSniffContent() { const std::string& mime_type = response_->head.mime_type; std::string content_type_options; @@ -276,7 +274,7 @@ bool BufferedResourceHandler::ShouldSniffContent() { return false; } -bool BufferedResourceHandler::DetermineMimeType() { +bool MimeTypeResourceHandler::DetermineMimeType() { DCHECK_EQ(STATE_BUFFERING, state_); const std::string& type_hint = response_->head.mime_type; @@ -294,7 +292,7 @@ bool BufferedResourceHandler::DetermineMimeType() { return made_final_decision; } -bool BufferedResourceHandler::SelectNextHandler(bool* defer) { +bool MimeTypeResourceHandler::SelectNextHandler(bool* defer) { DCHECK(!response_->head.mime_type.empty()); ResourceRequestInfoImpl* info = GetRequestInfo(); @@ -347,9 +345,9 @@ bool BufferedResourceHandler::SelectNextHandler(bool* defer) { if (stale) { // Refresh the plugins asynchronously. plugin_service_->GetPlugins( - base::Bind(&BufferedResourceHandler::OnPluginsLoaded, + base::Bind(&MimeTypeResourceHandler::OnPluginsLoaded, weak_ptr_factory_.GetWeakPtr())); - request()->LogBlockedBy("BufferedResourceHandler"); + request()->LogBlockedBy("MimeTypeResourceHandler"); *defer = true; return true; } @@ -371,7 +369,7 @@ bool BufferedResourceHandler::SelectNextHandler(bool* defer) { return UseAlternateNextHandler(handler.Pass(), std::string()); } -bool BufferedResourceHandler::UseAlternateNextHandler( +bool MimeTypeResourceHandler::UseAlternateNextHandler( scoped_ptr new_handler, const std::string& payload_for_old_handler) { if (response_->head.headers.get() && // Can be NULL if FTP. @@ -426,7 +424,7 @@ bool BufferedResourceHandler::UseAlternateNextHandler( return CopyReadBufferToNextHandler(); } -bool BufferedResourceHandler::ReplayReadCompleted(bool* defer) { +bool MimeTypeResourceHandler::ReplayReadCompleted(bool* defer) { DCHECK(read_buffer_.get()); bool result = next_handler_->OnReadCompleted(bytes_read_, defer); @@ -440,7 +438,7 @@ bool BufferedResourceHandler::ReplayReadCompleted(bool* defer) { return result; } -void BufferedResourceHandler::CallReplayReadCompleted() { +void MimeTypeResourceHandler::CallReplayReadCompleted() { bool defer = false; if (!ReplayReadCompleted(&defer)) { controller()->Cancel(); @@ -450,7 +448,7 @@ void BufferedResourceHandler::CallReplayReadCompleted() { } } -bool BufferedResourceHandler::MustDownload() { +bool MimeTypeResourceHandler::MustDownload() { if (must_download_is_set_) return must_download_; @@ -472,7 +470,7 @@ bool BufferedResourceHandler::MustDownload() { return must_download_; } -bool BufferedResourceHandler::HasSupportingPlugin(bool* stale) { +bool MimeTypeResourceHandler::HasSupportingPlugin(bool* stale) { #if defined(ENABLE_PLUGINS) ResourceRequestInfoImpl* info = GetRequestInfo(); @@ -489,7 +487,7 @@ bool BufferedResourceHandler::HasSupportingPlugin(bool* stale) { #endif } -bool BufferedResourceHandler::CopyReadBufferToNextHandler() { +bool MimeTypeResourceHandler::CopyReadBufferToNextHandler() { if (!read_buffer_.get()) return true; @@ -503,7 +501,7 @@ bool BufferedResourceHandler::CopyReadBufferToNextHandler() { return true; } -void BufferedResourceHandler::OnPluginsLoaded( +void MimeTypeResourceHandler::OnPluginsLoaded( const std::vector& plugins) { request()->LogUnblocked(); bool defer = false; diff --git a/content/browser/loader/buffered_resource_handler.h b/content/browser/loader/mime_type_resource_handler.h similarity index 74% rename from content/browser/loader/buffered_resource_handler.h rename to content/browser/loader/mime_type_resource_handler.h index 4e80ec53bd58..549d8cf3c9ff 100644 --- a/content/browser/loader/buffered_resource_handler.h +++ b/content/browser/loader/mime_type_resource_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ -#define CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ +#ifndef CONTENT_BROWSER_LOADER_MIME_TYPE_RESOURCE_HANDLER_H_ +#define CONTENT_BROWSER_LOADER_MIME_TYPE_RESOURCE_HANDLER_H_ #include #include @@ -22,17 +22,27 @@ class PluginService; class ResourceDispatcherHostImpl; struct WebPluginInfo; -// Used to buffer a request until enough data has been received. -class CONTENT_EXPORT BufferedResourceHandler +// ResourceHandler that, if necessary, buffers a response body without passing +// it to the next ResourceHandler until it can perform mime sniffing on it. +// Once a response's MIME type is known, initiates special handling of the +// response if needed (starts downloads, sends data to some plugin types via a +// special channel). +// +// Uses the buffer provided by the original event handler for buffering, and +// continues to reuses it until it can determine the MIME type +// subsequent reads until it's done buffering. As a result, the buffer +// returned by the next ResourceHandler must have a capacity of at least +// net::kMaxBytesToSniff * 2. +class CONTENT_EXPORT MimeTypeResourceHandler : public LayeredResourceHandler, public ResourceController { public: // If ENABLE_PLUGINS is defined, |plugin_service| must not be NULL. - BufferedResourceHandler(scoped_ptr next_handler, + MimeTypeResourceHandler(scoped_ptr next_handler, ResourceDispatcherHostImpl* host, PluginService* plugin_service, net::URLRequest* request); - ~BufferedResourceHandler() override; + ~MimeTypeResourceHandler() override; private: // ResourceHandler implementation: @@ -104,11 +114,11 @@ class CONTENT_EXPORT BufferedResourceHandler bool must_download_; bool must_download_is_set_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler); + DISALLOW_COPY_AND_ASSIGN(MimeTypeResourceHandler); }; } // namespace content -#endif // CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ +#endif // CONTENT_BROWSER_LOADER_MIME_TYPE_RESOURCE_HANDLER_H_ diff --git a/content/browser/loader/buffered_resource_handler_unittest.cc b/content/browser/loader/mime_type_resource_handler_unittest.cc similarity index 94% rename from content/browser/loader/buffered_resource_handler_unittest.cc rename to content/browser/loader/mime_type_resource_handler_unittest.cc index e4d3668c371f..fe79dc5409c4 100644 --- a/content/browser/loader/buffered_resource_handler_unittest.cc +++ b/content/browser/loader/mime_type_resource_handler_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/loader/buffered_resource_handler.h" +#include "content/browser/loader/mime_type_resource_handler.h" #include "base/logging.h" #include "base/macros.h" @@ -151,9 +151,9 @@ class TestResourceController : public ResourceController { } }; -class BufferedResourceHandlerTest : public testing::Test { +class MimeTypeResourceHandlerTest : public testing::Test { public: - BufferedResourceHandlerTest() : stream_has_handler_(false) {} + MimeTypeResourceHandlerTest() : stream_has_handler_(false) {} void set_stream_has_handler(bool stream_has_handler) { stream_has_handler_ = stream_has_handler; @@ -170,7 +170,7 @@ class BufferedResourceHandlerTest : public testing::Test { TestBrowserThreadBundle thread_bundle_; }; -bool BufferedResourceHandlerTest::TestStreamIsIntercepted( +bool MimeTypeResourceHandlerTest::TestStreamIsIntercepted( bool allow_download, bool must_download, ResourceType request_resource_type) { @@ -195,21 +195,21 @@ bool BufferedResourceHandlerTest::TestStreamIsIntercepted( host.SetDelegate(&host_delegate); FakePluginService plugin_service; - scoped_ptr buffered_handler( - new BufferedResourceHandler( + scoped_ptr mime_sniffing_handler( + new MimeTypeResourceHandler( scoped_ptr(new TestResourceHandler()).Pass(), &host, &plugin_service, request.get())); TestResourceController resource_controller; - buffered_handler->SetController(&resource_controller); + mime_sniffing_handler->SetController(&resource_controller); scoped_refptr response(new ResourceResponse); // The MIME type isn't important but it shouldn't be empty. response->head.mime_type = "application/pdf"; bool defer = false; - buffered_handler->OnResponseStarted(response.get(), &defer); + mime_sniffing_handler->OnResponseStarted(response.get(), &defer); content::RunAllPendingInMessageLoop(); @@ -218,7 +218,7 @@ bool BufferedResourceHandlerTest::TestStreamIsIntercepted( // Test that stream requests are correctly intercepted under the right // circumstances. -TEST_F(BufferedResourceHandlerTest, StreamHandling) { +TEST_F(MimeTypeResourceHandlerTest, StreamHandling) { bool allow_download; bool must_download; ResourceType resource_type; diff --git a/content/browser/loader/navigation_resource_handler.cc b/content/browser/loader/navigation_resource_handler.cc index ec6119a830cd..5e8343c4357f 100644 --- a/content/browser/loader/navigation_resource_handler.cc +++ b/content/browser/loader/navigation_resource_handler.cc @@ -72,11 +72,11 @@ bool NavigationResourceHandler::OnResponseStarted(ResourceResponse* response, ResourceRequestInfoImpl* info = GetRequestInfo(); - // If the BufferedResourceHandler intercepted this request and converted it + // If the MimeTypeResourceHandler intercepted this request and converted it // into a download, it will still call OnResponseStarted and immediately // cancel. Ignore the call; OnReadCompleted will happen shortly. // - // TODO(davidben): Move the dispatch out of BufferedResourceHandler. Perhaps + // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps // all the way to the UI thread. Downloads, user certificates, etc., should be // dispatched at the navigation layer. if (info->IsDownload() || info->is_stream()) diff --git a/content/browser/loader/redirect_to_file_resource_handler.cc b/content/browser/loader/redirect_to_file_resource_handler.cc index e87a23bf916f..12fd7d38e544 100644 --- a/content/browser/loader/redirect_to_file_resource_handler.cc +++ b/content/browser/loader/redirect_to_file_resource_handler.cc @@ -22,8 +22,8 @@ using storage::ShareableFileReference; namespace { // This class is similar to identically named classes in AsyncResourceHandler -// and BufferedResourceHandler, but not quite. -// TODO(ncbray) generalize and unify these cases? +// and MimeTypeResourceHandler, but not quite. +// TODO(ncbray): generalize and unify these cases? // In general, it's a bad idea to point to a subbuffer (particularly with // GrowableIOBuffer) because the backing IOBuffer may realloc its data. In this // particular case we know RedirectToFileResourceHandler will not realloc its @@ -351,7 +351,7 @@ bool RedirectToFileResourceHandler::WriteMore() { } bool RedirectToFileResourceHandler::BufIsFull() const { - // This is a hack to workaround BufferedResourceHandler's inability to + // This is a hack to workaround MimeTypeResourceHandler's inability to // deal with a ResourceHandler that returns a buffer size of less than // 2 * net::kMaxBytesToSniff from its OnWillRead method. // TODO(darin): Fix this retardation! diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc index c69bcdbb232f..d75ac724aeca 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -37,9 +37,9 @@ #include "content/browser/frame_host/navigation_request_info.h" #include "content/browser/frame_host/navigator.h" #include "content/browser/loader/async_resource_handler.h" -#include "content/browser/loader/buffered_resource_handler.h" #include "content/browser/loader/cross_site_resource_handler.h" #include "content/browser/loader/detachable_resource_handler.h" +#include "content/browser/loader/mime_type_resource_handler.h" #include "content/browser/loader/navigation_resource_handler.h" #include "content/browser/loader/navigation_url_loader_impl_core.h" #include "content/browser/loader/power_save_block_resource_throttle.h" @@ -1418,9 +1418,8 @@ scoped_ptr ResourceDispatcherHostImpl::AddStandardHandlers( plugin_service = PluginService::GetInstance(); #endif // Insert a buffered event handler before the actual one. - handler.reset( - new BufferedResourceHandler( - handler.Pass(), this, plugin_service, request)); + handler.reset(new MimeTypeResourceHandler(handler.Pass(), this, + plugin_service, request)); ScopedVector throttles; if (delegate_) { diff --git a/content/browser/loader/resource_dispatcher_host_impl.h b/content/browser/loader/resource_dispatcher_host_impl.h index 31d94aa422f8..b454955737e8 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.h +++ b/content/browser/loader/resource_dispatcher_host_impl.h @@ -434,7 +434,7 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl ResourceContext* resource_context); // Wraps |handler| in the standard resource handlers for normal resource - // loading and navigation requests. This adds BufferedResourceHandler and + // loading and navigation requests. This adds MimeTypeResourceHandler and // ResourceThrottles. scoped_ptr AddStandardHandlers( net::URLRequest* request, diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc index 5df1109cb8ba..345a30096f10 100644 --- a/content/browser/loader/resource_dispatcher_host_unittest.cc +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc @@ -2154,11 +2154,11 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { "Content-disposition: attachment; filename=foo\n\n"); std::string response_data("01234567890123456789\x01foobar"); - // Get past sniffing metrics in the BufferedResourceHandler. Note that + // Get past sniffing metrics in the MimeTypeResourceHandler. Note that // if we don't get past the sniffing metrics, the result will be that - // the BufferedResourceHandler won't have figured out that it's a download, - // won't have constructed a DownloadResourceHandler, and and the request - // will be successfully canceled below, failing the test. + // the MimeTypeResourceHandler won't have figured out that it's a download, + // won't have constructed a DownloadResourceHandler, and and the request will + // be successfully canceled below, failing the test. response_data.resize(1025, ' '); SetResponse(raw_headers, response_data); @@ -2331,7 +2331,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationHtml) { base::MessageLoop::current()->RunUntilIdle(); // Flush all the pending requests to get the response through the - // BufferedResourceHandler. + // MimeTypeResourceHandler. while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} // Restore, now that we've set up a transfer. @@ -2401,7 +2401,7 @@ TEST_F(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { RESOURCE_TYPE_MAIN_FRAME); // Flush all the pending requests to get the response through the - // BufferedResourceHandler. + // MimeTypeResourceHandler. while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} // Restore, now that we've set up a transfer. @@ -2446,8 +2446,8 @@ TEST_F(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { } // Test transferred navigations with text/plain, which causes -// BufferedResourceHandler to buffer the response to sniff the content -// before the transfer occurs. +// MimeTypeResourceHandler to buffer the response to sniff the content before +// the transfer occurs. TEST_F(ResourceDispatcherHostTest, TransferNavigationText) { // This test expects the cross site request to be leaked, so it can transfer // the request directly. @@ -2475,7 +2475,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationText) { // Now that we're blocked on the redirect, update the response and unblock by // telling the AsyncResourceHandler to follow the redirect. Use a text/plain - // MIME type, which causes BufferedResourceHandler to buffer it before the + // MIME type, which causes MimeTypeResourceHandler to buffer it before the // transfer occurs. const std::string kResponseBody = "hello world"; SetResponse("HTTP/1.1 200 OK\n" @@ -2486,7 +2486,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationText) { base::MessageLoop::current()->RunUntilIdle(); // Flush all the pending requests to get the response through the - // BufferedResourceHandler. + // MimeTypeResourceHandler. while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} // Restore, now that we've set up a transfer. @@ -2565,7 +2565,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) { base::MessageLoop::current()->RunUntilIdle(); // Flush all the pending requests to get the response through the - // BufferedResourceHandler. + // MimeTypeResourceHandler. while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} } // The first filter is now deleted, as if the child process died. @@ -2638,7 +2638,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { // Now that we're blocked on the second redirect, update the response and // unblock by telling the AsyncResourceHandler to follow the redirect. - // Again, use text/plain to force BufferedResourceHandler to buffer before + // Again, use text/plain to force MimeTypeResourceHandler to buffer before // the transfer. const std::string kResponseBody = "hello world"; SetResponse("HTTP/1.1 200 OK\n" @@ -2649,7 +2649,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { base::MessageLoop::current()->RunUntilIdle(); // Flush all the pending requests to get the response through the - // BufferedResourceHandler. + // MimeTypeResourceHandler. while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} // Restore. diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index ba39867c8a0b..e792d5c76d2e 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -184,8 +184,8 @@ void ResourceLoader::MarkAsTransferring() { void ResourceLoader::CompleteTransfer() { // Although CrossSiteResourceHandler defers at OnResponseStarted // (DEFERRED_READ), it may be seeing a replay of events via - // BufferedResourceHandler, and so the request itself is actually deferred at - // a later read stage. + // MimeTypeResourceHandler, and so the request itself is actually deferred + // at a later read stage. DCHECK(DEFERRED_READ == deferred_stage_ || DEFERRED_RESPONSE_COMPLETE == deferred_stage_); DCHECK(is_transferring_); diff --git a/content/browser/loader/stream_writer.h b/content/browser/loader/stream_writer.h index a611e26dde69..130a974bd186 100644 --- a/content/browser/loader/stream_writer.h +++ b/content/browser/loader/stream_writer.h @@ -50,7 +50,7 @@ class StreamWriter : public StreamWriteObserver { // is not -1, it is the minimum size of the returned buffer. // // OnWillRead may be called before the stream is initialized. This is to - // support BufferedResourceHandler which reads the initial chunk of data + // support MimeTypeResourceHandler which reads the initial chunk of data // early. void OnWillRead(scoped_refptr* buf, int* buf_size, diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 18a6b1398286..b924b5393bf7 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -925,8 +925,6 @@ 'browser/indexed_db/leveldb/leveldb_write_batch.h', 'browser/loader/async_resource_handler.cc', 'browser/loader/async_resource_handler.h', - 'browser/loader/buffered_resource_handler.cc', - 'browser/loader/buffered_resource_handler.h', 'browser/loader/certificate_resource_handler.cc', 'browser/loader/certificate_resource_handler.h', 'browser/loader/cross_site_resource_handler.cc', @@ -936,6 +934,8 @@ 'browser/loader/global_routing_id.h', 'browser/loader/layered_resource_handler.cc', 'browser/loader/layered_resource_handler.h', + 'browser/loader/mime_type_resource_handler.cc', + 'browser/loader/mime_type_resource_handler.h', 'browser/loader/navigation_resource_handler.cc', 'browser/loader/navigation_resource_handler.h', 'browser/loader/navigation_url_loader.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index bdd665a008f5..b5a7a30759b7 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -464,7 +464,7 @@ 'browser/indexed_db/mock_indexed_db_database_callbacks.h', 'browser/indexed_db/mock_indexed_db_factory.cc', 'browser/indexed_db/mock_indexed_db_factory.h', - 'browser/loader/buffered_resource_handler_unittest.cc', + 'browser/loader/mime_type_resource_handler_unittest.cc', 'browser/loader/navigation_url_loader_unittest.cc', 'browser/loader/resource_buffer_unittest.cc', 'browser/loader/resource_dispatcher_host_unittest.cc', -- 2.11.4.GIT