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

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

Issue 10501004: Refactor the guts of ResourceDispatcherHostImpl into a new class named (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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/renderer_host/redirect_to_file_resource_handler.cc
===================================================================
--- content/browser/renderer_host/redirect_to_file_resource_handler.cc (revision 141889)
+++ content/browser/renderer_host/redirect_to_file_resource_handler.cc (working copy)
@@ -39,6 +39,7 @@
buf_write_pending_(false),
write_cursor_(0),
write_callback_pending_(false),
+ did_defer_(false),
completed_during_write_(false) {
}
@@ -74,7 +75,7 @@
// Defer starting the request until we have created the temporary file.
// TODO(darin): This is sub-optimal. We should not delay starting the
// network request like this.
- *defer = true;
+ did_defer_ = *defer = true;
base::FileUtilProxy::CreateTemporary(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
base::PLATFORM_FILE_ASYNC,
@@ -127,7 +128,7 @@
buf_->set_offset(new_offset);
if (BufIsFull())
- *defer = true;
+ did_defer_ = *defer = true;
return WriteMore();
}
@@ -158,7 +159,7 @@
NULL));
host_->RegisterDownloadedTempFile(
process_id_, request_id_, deletable_file_.get());
- host_->StartDeferredRequest(process_id_, request_id_);
+ ResumeIfDeferred();
}
void RedirectToFileResourceHandler::DidWriteToFile(int result) {
@@ -174,13 +175,12 @@
}
if (failed) {
- host_->CancelRequest(process_id_, request_id_, false);
+ ResumeIfDeferred();
} else if (completed_during_write_) {
- next_handler_->OnResponseCompleted(request_id_, completed_status_,
- completed_security_info_);
- // TODO(darin): OnResponseCompleted can return false to defer
- // RemovePendingRequest.
- host_->RemovePendingRequest(process_id_, request_id_);
+ if (next_handler_->OnResponseCompleted(request_id_, completed_status_,
+ completed_security_info_)) {
+ ResumeIfDeferred();
+ }
}
}
@@ -192,7 +192,7 @@
// appending more data to the buffer.
if (!buf_write_pending_) {
if (BufIsFull())
- host_->ResumeDeferredRequest(process_id_, request_id_);
+ ResumeIfDeferred();
buf_->set_offset(0);
write_cursor_ = 0;
}
@@ -236,4 +236,11 @@
return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff);
}
+void RedirectToFileResourceHandler::ResumeIfDeferred() {
+ if (did_defer_) {
+ did_defer_ = false;
+ controller()->Resume();
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698