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

Unified Diff: net/url_request/url_request_simple_job.cc

Issue 1467603002: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add done_reading_called_ to MockNetworkTransaction Created 5 years, 1 month 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_status.h » ('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 bc1507915fb7919a95f44bb9d83b1f37ca6b44f5..c12555d4b08c37bd8d910baefee364c78d172cd6 100644
--- a/net/url_request/url_request_simple_job.cc
+++ b/net/url_request/url_request_simple_job.cc
@@ -65,33 +65,20 @@ bool URLRequestSimpleJob::GetCharset(std::string* charset) {
URLRequestSimpleJob::~URLRequestSimpleJob() {}
-bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf,
- int buf_size,
- int* bytes_read) {
- DCHECK(bytes_read);
- buf_size = static_cast<int>(
- std::min(static_cast<int64>(buf_size),
- byte_range_.last_byte_position() - next_data_offset_ + 1));
- DCHECK_GE(buf_size, 0);
- if (buf_size == 0) {
- *bytes_read = 0;
- return true;
- }
+int URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size) {
+ buf_size = std::min(static_cast<int64>(buf_size),
+ byte_range_.last_byte_position() - next_data_offset_ + 1);
+ if (buf_size == 0)
+ return 0;
// Do memory copy on a background thread. See crbug.com/422489.
GetTaskRunner()->PostTaskAndReply(
FROM_HERE, base::Bind(&CopyData, make_scoped_refptr(buf), buf_size, data_,
next_data_offset_),
- base::Bind(&URLRequestSimpleJob::OnReadCompleted,
+ base::Bind(&URLRequestSimpleJob::ReadRawDataComplete,
weak_factory_.GetWeakPtr(), buf_size));
next_data_offset_ += buf_size;
- SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
- return false;
-}
-
-void URLRequestSimpleJob::OnReadCompleted(int bytes_read) {
- SetStatus(URLRequestStatus());
- NotifyReadComplete(bytes_read);
+ return ERR_IO_PENDING;
}
base::TaskRunner* URLRequestSimpleJob::GetTaskRunner() const {
@@ -122,8 +109,8 @@ void URLRequestSimpleJob::StartAsync() {
return;
if (ranges().size() > 1) {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
- ERR_REQUEST_RANGE_NOT_SATISFIABLE));
+ NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED,
+ ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return;
}
@@ -143,8 +130,8 @@ void URLRequestSimpleJob::OnGetDataCompleted(int result) {
if (result == OK) {
// Notify that the headers are complete
if (!byte_range_.ComputeBounds(data_->size())) {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
- ERR_REQUEST_RANGE_NOT_SATISFIABLE));
+ NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED,
+ ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return;
}
« no previous file with comments | « net/url_request/url_request_simple_job.h ('k') | net/url_request/url_request_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698