| Index: net/url_request/url_request_test_job.cc
|
| diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc
|
| index bd1c9052baa2a9b2744458bb80bc5d207faba767..8a293c38617b5a7ab6c81245baa0cfb9b2e2703a 100644
|
| --- a/net/url_request/url_request_test_job.cc
|
| +++ b/net/url_request/url_request_test_job.cc
|
| @@ -210,8 +210,7 @@ void URLRequestTestJob::StartAsync() {
|
| // unexpected url, return error
|
| // FIXME(brettw) we may want to use WININET errors or have some more types
|
| // of errors
|
| - NotifyStartError(
|
| - URLRequestStatus(URLRequestStatus::FAILED, ERR_INVALID_URL));
|
| + NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, ERR_INVALID_URL));
|
| // FIXME(brettw): this should emulate a network error, and not just fail
|
| // initiating a connection
|
| return;
|
| @@ -223,15 +222,22 @@ void URLRequestTestJob::StartAsync() {
|
| this->NotifyHeadersComplete();
|
| }
|
|
|
| -int URLRequestTestJob::ReadRawData(IOBuffer* buf, int buf_size) {
|
| +bool URLRequestTestJob::ReadRawData(IOBuffer* buf,
|
| + int buf_size,
|
| + int* bytes_read) {
|
| if (stage_ == WAITING) {
|
| async_buf_ = buf;
|
| async_buf_size_ = buf_size;
|
| - return ERR_IO_PENDING;
|
| + SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
|
| + return false;
|
| }
|
|
|
| - if (offset_ >= static_cast<int>(response_data_.length()))
|
| - return 0; // done reading
|
| + DCHECK(bytes_read);
|
| + *bytes_read = 0;
|
| +
|
| + if (offset_ >= static_cast<int>(response_data_.length())) {
|
| + return true; // done reading
|
| + }
|
|
|
| int to_read = buf_size;
|
| if (to_read + offset_ > static_cast<int>(response_data_.length()))
|
| @@ -240,7 +246,8 @@ int URLRequestTestJob::ReadRawData(IOBuffer* buf, int buf_size) {
|
| memcpy(buf->data(), &response_data_.c_str()[offset_], to_read);
|
| offset_ += to_read;
|
|
|
| - return to_read;
|
| + *bytes_read = to_read;
|
| + return true;
|
| }
|
|
|
| void URLRequestTestJob::GetResponseInfo(HttpResponseInfo* info) {
|
| @@ -298,15 +305,16 @@ void URLRequestTestJob::ProcessNextOperation() {
|
| stage_ = DATA_AVAILABLE;
|
| // OK if ReadRawData wasn't called yet.
|
| if (async_buf_) {
|
| - int result = ReadRawData(async_buf_, async_buf_size_);
|
| - if (result < 0)
|
| - NOTREACHED() << "Reads should not fail in DATA_AVAILABLE.";
|
| + int bytes_read;
|
| + if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read))
|
| + NOTREACHED() << "This should not return false in DATA_AVAILABLE.";
|
| + SetStatus(URLRequestStatus()); // clear the io pending flag
|
| if (NextReadAsync()) {
|
| // Make all future reads return io pending until the next
|
| // ProcessNextOperation().
|
| stage_ = WAITING;
|
| }
|
| - ReadRawDataComplete(result);
|
| + NotifyReadComplete(bytes_read);
|
| }
|
| break;
|
| case DATA_AVAILABLE:
|
|
|