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

Unified Diff: net/url_request/url_request_simple_job.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « net/url_request/url_request_simple_job.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_simple_job.cc
diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc
index 060a90e6a44518d7c86abefef53e58ecbaa099c1..ebc2b5dfe44800f50f2489466f5145eebceaa3be 100644
--- a/net/url_request/url_request_simple_job.cc
+++ b/net/url_request/url_request_simple_job.cc
@@ -53,9 +53,9 @@ bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size,
"422489 URLRequestSimpleJob::ReadRawData"));
DCHECK(bytes_read);
- int remaining = byte_range_.last_byte_position() - data_offset_ + 1;
- if (buf_size > remaining)
- buf_size = remaining;
+ buf_size = static_cast<int>(std::min(
+ static_cast<int64>(buf_size),
+ byte_range_.last_byte_position() - data_offset_ + 1));
memcpy(buf->data(), data_->front() + data_offset_, buf_size);
data_offset_ += buf_size;
*bytes_read = buf_size;
@@ -138,9 +138,8 @@ void URLRequestSimpleJob::OnGetDataCompleted(int result) {
}
data_offset_ = byte_range_.first_byte_position();
- int remaining_bytes = byte_range_.last_byte_position() -
- byte_range_.first_byte_position() + 1;
- set_expected_content_size(remaining_bytes);
+ set_expected_content_size(
+ byte_range_.last_byte_position() - data_offset_ + 1);
NotifyHeadersComplete();
} else {
NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
« no previous file with comments | « net/url_request/url_request_simple_job.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698