| 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 69df993843453e1105111ba1193f1c8dc8fe3edd..357ad63cf70f87314d5bd8ce1919db3e8893e266 100644
|
| --- a/content/browser/loader/async_resource_handler.cc
|
| +++ b/content/browser/loader/async_resource_handler.cc
|
| @@ -296,17 +296,19 @@ void AsyncResourceHandler::ReportUploadProgress() {
|
| }
|
| }
|
|
|
| -bool AsyncResourceHandler::OnRequestRedirected(
|
| +void AsyncResourceHandler::OnRequestRedirected(
|
| const net::RedirectInfo& redirect_info,
|
| ResourceResponse* response,
|
| - bool* defer) {
|
| - const ResourceRequestInfoImpl* info = GetRequestInfo();
|
| - if (!info->filter())
|
| - return false;
|
| -
|
| - *defer = did_defer_ = true;
|
| + bool* defer_or_cancel) {
|
| + *defer_or_cancel = did_defer_ = true;
|
| OnDefer();
|
|
|
| + const ResourceRequestInfoImpl* info = GetRequestInfo();
|
| + if (!info->filter()) {
|
| + controller()->Cancel();
|
| + return;
|
| + }
|
| +
|
| NetLogObserver::PopulateResponseInfo(request(), response);
|
| response->head.encoded_data_length = request()->GetTotalReceivedBytes();
|
| reported_transfer_size_ = 0;
|
| @@ -316,12 +318,14 @@ bool AsyncResourceHandler::OnRequestRedirected(
|
| // cookies? The only case where it can change is top-level navigation requests
|
| // and hopefully those will eventually all be owned by the browser. It's
|
| // possible this is still needed while renderer-owned ones exist.
|
| - return info->filter()->Send(new ResourceMsg_ReceivedRedirect(
|
| - GetRequestID(), redirect_info, response->head));
|
| + if (!info->filter()->Send(new ResourceMsg_ReceivedRedirect(
|
| + GetRequestID(), redirect_info, response->head))) {
|
| + controller()->Cancel();
|
| + }
|
| }
|
|
|
| -bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response,
|
| - bool* defer) {
|
| +void AsyncResourceHandler::OnResponseStarted(ResourceResponse* response,
|
| + bool* defer_or_cancel) {
|
| // For changes to the main frame, inform the renderer of the new URL's
|
| // per-host settings before the request actually commits. This way the
|
| // renderer will be able to set these precisely at the time the
|
| @@ -332,8 +336,11 @@ bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response,
|
|
|
| progress_timer_.Stop();
|
| const ResourceRequestInfoImpl* info = GetRequestInfo();
|
| - if (!info->filter())
|
| - return false;
|
| + if (!info->filter()) {
|
| + controller()->Cancel();
|
| + *defer_or_cancel = true;
|
| + return;
|
| + }
|
|
|
| // We want to send a final upload progress message prior to sending the
|
| // response complete message even if we're waiting for an ack to to a
|
| @@ -374,10 +381,9 @@ bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response,
|
| }
|
|
|
| inlining_helper_->OnResponseReceived(*response);
|
| - return true;
|
| }
|
|
|
| -bool AsyncResourceHandler::OnWillStart(const GURL& url, bool* defer) {
|
| +void AsyncResourceHandler::OnWillStart(const GURL& url, bool* defer_or_cancel) {
|
| if (GetRequestInfo()->is_upload_progress_enabled() &&
|
| request()->has_upload()) {
|
| ReportUploadProgress();
|
| @@ -387,7 +393,6 @@ bool AsyncResourceHandler::OnWillStart(const GURL& url, bool* defer) {
|
| this,
|
| &AsyncResourceHandler::ReportUploadProgress);
|
| }
|
| - return true;
|
| }
|
|
|
| bool AsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
|
| @@ -416,15 +421,19 @@ bool AsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
|
| return true;
|
| }
|
|
|
| -bool AsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
|
| +void AsyncResourceHandler::OnReadCompleted(int bytes_read,
|
| + bool* defer_or_cancel) {
|
| DCHECK_GE(bytes_read, 0);
|
|
|
| if (!bytes_read)
|
| - return true;
|
| + return;
|
|
|
| ResourceMessageFilter* filter = GetFilter();
|
| - if (!filter)
|
| - return false;
|
| + if (!filter) {
|
| + controller()->Cancel();
|
| + *defer_or_cancel = true;
|
| + return;
|
| + }
|
|
|
| int encoded_data_length = CalculateEncodedDataLengthToReport();
|
| if (!first_chunk_read_)
|
| @@ -436,16 +445,20 @@ bool AsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
|
| // Return early if InliningHelper handled the received data.
|
| if (inlining_helper_->SendInlinedDataIfApplicable(
|
| bytes_read, encoded_data_length, encoded_body_length, filter,
|
| - GetRequestID()))
|
| - return true;
|
| + GetRequestID())) {
|
| + return;
|
| + }
|
|
|
| buffer_->ShrinkLastAllocation(bytes_read);
|
|
|
| if (!sent_data_buffer_msg_) {
|
| base::SharedMemoryHandle handle = base::SharedMemory::DuplicateHandle(
|
| buffer_->GetSharedMemory().handle());
|
| - if (!base::SharedMemory::IsHandleValid(handle))
|
| - return false;
|
| + if (!base::SharedMemory::IsHandleValid(handle)) {
|
| + controller()->Cancel();
|
| + *defer_or_cancel = true;
|
| + return;
|
| + }
|
| filter->Send(new ResourceMsg_SetDataBuffer(
|
| GetRequestID(), handle, buffer_->GetSharedMemory().mapped_size(),
|
| filter->peer_pid()));
|
| @@ -460,11 +473,9 @@ bool AsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
|
| ++pending_data_count_;
|
|
|
| if (!buffer_->CanAllocate()) {
|
| - *defer = did_defer_ = true;
|
| + *defer_or_cancel = did_defer_ = true;
|
| OnDefer();
|
| }
|
| -
|
| - return true;
|
| }
|
|
|
| void AsyncResourceHandler::OnDataDownloaded(int bytes_downloaded) {
|
|
|