Index: content/browser/loader/async_resource_handler.cc |
diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc |
index 8168f1083a21946220a6fe746383aa9269146f91..facde3fb24f50dc9ee4cdfba78296eaa85b0dc12 100644 |
--- a/content/browser/loader/async_resource_handler.cc |
+++ b/content/browser/loader/async_resource_handler.cc |
@@ -367,21 +367,28 @@ void AsyncResourceHandler::OnWillStart( |
controller->Resume(); |
} |
-bool AsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
- int* buf_size) { |
+void AsyncResourceHandler::OnWillRead( |
+ scoped_refptr<net::IOBuffer>* buf, |
+ int* buf_size, |
+ std::unique_ptr<ResourceController> controller) { |
DCHECK(!has_controller()); |
- // TODO(mmenke): Should fail with ERR_INSUFFICIENT_RESOURCES here. |
- if (!CheckForSufficientResource()) |
- return false; |
+ if (!CheckForSufficientResource()) { |
+ controller->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); |
Charlie Harrison
2017/02/16 21:25:04
w00t!
|
+ return; |
+ } |
// Return early if InliningHelper allocates the buffer, so that we should |
// inline the data into the IPC message without allocating SharedMemory. |
- if (inlining_helper_->PrepareInlineBufferIfApplicable(buf, buf_size)) |
- return true; |
+ if (inlining_helper_->PrepareInlineBufferIfApplicable(buf, buf_size)) { |
+ controller->Resume(); |
+ return; |
+ } |
- if (!EnsureResourceBufferIsInitialized()) |
- return false; |
+ if (!EnsureResourceBufferIsInitialized()) { |
+ controller->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); |
+ return; |
+ } |
DCHECK(buffer_->CanAllocate()); |
char* memory = buffer_->Allocate(&allocation_size_); |
@@ -390,7 +397,7 @@ bool AsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
*buf = new DependentIOBuffer(buffer_.get(), memory); |
*buf_size = allocation_size_; |
- return true; |
+ controller->Resume(); |
} |
void AsyncResourceHandler::OnReadCompleted( |