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/download/download_resource_handler.cc

Issue 10578055: Rewrite guts of ResourceLoader and BufferedResourceHandler to suck less. (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/download/download_resource_handler.cc
===================================================================
--- content/browser/download/download_resource_handler.cc (revision 144275)
+++ content/browser/download/download_resource_handler.cc (working copy)
@@ -247,16 +247,10 @@
}
// Pass the buffer to the download file writer.
-bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read,
+bool DownloadResourceHandler::OnReadCompleted(int request_id, int bytes_read,
bool* defer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!read_buffer_) {
- // Ignore spurious OnReadCompleted! Deferring from OnReadCompleted tells
- // the ResourceDispatcherHost that we did not consume the data.
- // ResumeDeferredRequest then repeats the last OnReadCompleted call.
- // TODO(darin): Fix the ResourceDispatcherHost to avoid this hack!
- return true;
- }
+ DCHECK(read_buffer_);
if (pause_count_ > 0) {
*defer = was_deferred_ = true;
@@ -271,20 +265,20 @@
// divide-by-zero error and still record a very high potential bandwidth.
seconds_since_last_read = 0.00001;
- double actual_bandwidth = (*bytes_read)/seconds_since_last_read;
+ double actual_bandwidth = (bytes_read)/seconds_since_last_read;
double potential_bandwidth = last_buffer_size_/seconds_since_last_read;
download_stats::RecordBandwidth(actual_bandwidth, potential_bandwidth);
}
last_read_time_ = now;
- if (!*bytes_read)
+ if (!bytes_read)
return true;
- bytes_read_ += *bytes_read;
+ bytes_read_ += bytes_read;
DCHECK(read_buffer_);
// Take the data ship it down the stream. If the stream is full, pause the
// request; the stream callback will resume it.
- if (!stream_writer_->Write(read_buffer_, *bytes_read)) {
+ if (!stream_writer_->Write(read_buffer_, bytes_read)) {
PauseRequest();
*defer = was_deferred_ = true;
last_stream_pause_time_ = now;
« no previous file with comments | « content/browser/download/download_resource_handler.h ('k') | content/browser/download/save_file_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698