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

Unified Diff: content/browser/loader/redirect_to_file_resource_handler.cc

Issue 2743723003: Add buffering to MimeSniffingResourceHandler.
Patch Set: Remove unused 'first_call' variable. Created 3 years, 9 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/redirect_to_file_resource_handler.cc
diff --git a/content/browser/loader/redirect_to_file_resource_handler.cc b/content/browser/loader/redirect_to_file_resource_handler.cc
index 3bddfd75d301dfebfb755ebc993036685ed506f7..83bfae59d5c3f8389a6d10783e1d2539fd312aa6 100644
--- a/content/browser/loader/redirect_to_file_resource_handler.cc
+++ b/content/browser/loader/redirect_to_file_resource_handler.cc
@@ -16,7 +16,6 @@
#include "content/public/common/resource_response.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
-#include "net/base/mime_sniffer.h"
#include "net/base/net_errors.h"
#include "storage/browser/blob/shareable_file_reference.h"
@@ -193,7 +192,7 @@ void RedirectToFileResourceHandler::OnWillRead(
buf_->SetCapacity(next_buffer_size_);
// We should have paused this network request already if the buffer is full.
- DCHECK(!BufIsFull());
+ DCHECK_GT(buf_->RemainingCapacity(), 0);
*buf = buf_.get();
*buf_size = buf_->RemainingCapacity();
@@ -355,19 +354,12 @@ bool RedirectToFileResourceHandler::WriteMore() {
// If the request was defered for a reason other than having been completed,
// and the buffer has space, resume the request.
- if (has_controller() && !completed_during_write_ && !BufIsFull()) {
+ if (has_controller() && !completed_during_write_ &&
+ buf_->RemainingCapacity() > 0) {
request()->LogUnblocked();
Resume();
}
return true;
}
-bool RedirectToFileResourceHandler::BufIsFull() const {
- // 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!
- return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff);
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698