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

Unified Diff: net/url_request/url_request_job.cc

Issue 6881106: Treat ERR_CONNECTION_CLOSED as end-of-data marker for downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed issues with tracking number of bytes received & decompressed. Created 9 years, 7 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: net/url_request/url_request_job.cc
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 3073414d421426aa7e3b086300840e6069007db1..c87e7615157107c19fbd91e28e626c759f96b849 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -306,12 +306,14 @@ void URLRequestJob::NotifyReadComplete(int bytes_read) {
return;
// When notifying the delegate, the delegate can release the request
- // (and thus release 'this'). After calling to the delgate, we must
+ // (and thus release 'this'). After calling to the delegate, we must
// check the request pointer to see if it still exists, and return
// immediately if it has been destroyed. self_preservation ensures our
// survival until we can get out of this method.
scoped_refptr<URLRequestJob> self_preservation(this);
+ // If we get here, |prefilter_bytes_read_| was not updated in
+ // |ReadRawDataHelper()|.
prefilter_bytes_read_ += bytes_read;
if (filter_.get()) {
// Tell the filter that it has more data
@@ -320,13 +322,19 @@ void URLRequestJob::NotifyReadComplete(int bytes_read) {
// Filter the data.
int filter_bytes_read = 0;
if (ReadFilteredData(&filter_bytes_read)) {
- postfilter_bytes_read_ += filter_bytes_read;
request_->delegate()->OnReadCompleted(request_, filter_bytes_read);
}
} else {
+ // If we get here, |postfilter_bytes_read_| was not updated in
+ // |ReadRawDataHelper()|.
postfilter_bytes_read_ += bytes_read;
request_->delegate()->OnReadCompleted(request_, bytes_read);
}
+ VLOG(21) << __FUNCTION__ << "() "
+ << "\"" << (request_ ? request_->url().spec() : "???") << "\""
+ << " pre bytes read = " << bytes_read
+ << " pre total = " << prefilter_bytes_read_
+ << " post total = " << postfilter_bytes_read_;
}
void URLRequestJob::NotifyStartError(const URLRequestStatus &status) {
@@ -468,6 +476,7 @@ bool URLRequestJob::ReadFilteredData(int* bytes_read) {
case Filter::FILTER_DONE: {
filter_needs_more_output_space_ = false;
*bytes_read = filtered_data_len;
+ postfilter_bytes_read_ += filtered_data_len;
rv = true;
break;
}
@@ -482,6 +491,7 @@ bool URLRequestJob::ReadFilteredData(int* bytes_read) {
// We can revisit this issue if there is a real perf need.
if (filtered_data_len > 0) {
*bytes_read = filtered_data_len;
+ postfilter_bytes_read_ += filtered_data_len;
rv = true;
} else {
// Read again since we haven't received enough data yet (e.g., we may
@@ -494,6 +504,7 @@ bool URLRequestJob::ReadFilteredData(int* bytes_read) {
filter_needs_more_output_space_ =
(filtered_data_len == output_buffer_size);
*bytes_read = filtered_data_len;
+ postfilter_bytes_read_ += filtered_data_len;
rv = true;
break;
}
@@ -511,6 +522,13 @@ bool URLRequestJob::ReadFilteredData(int* bytes_read) {
break;
}
}
+ VLOG(21) << __FUNCTION__ << "() "
+ << "\"" << (request_ ? request_->url().spec() : "???") << "\""
+ << " rv = " << rv
+ << " post bytes read = " << filtered_data_len
+ << " pre total = " << prefilter_bytes_read_
+ << " post total = "
+ << postfilter_bytes_read_;
} else {
// we are done, or there is no data left.
rv = true;
@@ -568,6 +586,24 @@ bool URLRequestJob::ReadRawDataHelper(IOBuffer* buf, int buf_size,
raw_read_buffer_ = buf;
bool rv = ReadRawData(buf, buf_size, bytes_read);
+ // If |*bytes_read == 0|, that means we have data pending, so we will need to
+ // update |prefilter_bytes_read_| in |NotifyReadComplete()|.
+ if (*bytes_read > 0) {
rvargas (doing something else) 2011/05/19 19:30:36 You cannot evaluate bytes_read without first looki
ahendrickson 2011/05/19 22:29:34 Done.
+ prefilter_bytes_read_ += *bytes_read;
+ if (!filter_.get())
+ postfilter_bytes_read_ += *bytes_read;
+ VLOG(21) << __FUNCTION__ << "() "
+ << "\"" << (request_ ? request_->url().spec() : "???") << "\""
+ << " pre bytes read = " << *bytes_read
+ << " pre total = " << prefilter_bytes_read_
+ << " post total = " << postfilter_bytes_read_;
+ } else {
+ VLOG(21) << __FUNCTION__ << "() "
+ << "\"" << (request_ ? request_->url().spec() : "???") << "\""
+ << " error code = " << *bytes_read
+ << " io pending = " << request_->status().is_io_pending();
+ }
+
if (!request_->status().is_io_pending()) {
// If the read completes synchronously, either success or failure,
// invoke the OnRawReadComplete callback so we can account for the
« net/url_request/url_request_http_job.cc ('K') | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698