Index: net/test/url_request/url_request_failed_job.cc |
diff --git a/net/test/url_request/url_request_failed_job.cc b/net/test/url_request/url_request_failed_job.cc |
index d7c479b14f719842b43379380cac89f9f7fe0c90..e4ac6a675d0f459b96fa4ba1538def7372968be3 100644 |
--- a/net/test/url_request/url_request_failed_job.cc |
+++ b/net/test/url_request/url_request_failed_job.cc |
@@ -97,20 +97,40 @@ URLRequestFailedJob::URLRequestFailedJob(URLRequest* request, |
} |
void URLRequestFailedJob::Start() { |
- base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, |
- base::Bind(&URLRequestFailedJob::StartAsync, weak_factory_.GetWeakPtr())); |
+ if (phase_ == START) { |
+ if (net_error_ != ERR_IO_PENDING) { |
+ NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, net_error_)); |
+ return; |
+ } |
+ SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
+ return; |
+ } |
+ response_info_.headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); |
+ NotifyHeadersComplete(); |
} |
-int URLRequestFailedJob::ReadRawData(IOBuffer* buf, int buf_size) { |
+bool URLRequestFailedJob::ReadRawData(IOBuffer* buf, |
+ int buf_size, |
+ int* bytes_read) { |
CHECK(phase_ == READ_SYNC || phase_ == READ_ASYNC); |
- if (net_error_ == ERR_IO_PENDING || phase_ == READ_SYNC) |
- return net_error_; |
+ if (net_error_ != ERR_IO_PENDING && phase_ == READ_SYNC) { |
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, net_error_)); |
+ return false; |
+ } |
+ |
+ SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
+ |
+ if (net_error_ == ERR_IO_PENDING) |
+ return false; |
+ |
+ DCHECK_EQ(READ_ASYNC, phase_); |
+ DCHECK_NE(ERR_IO_PENDING, net_error_); |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, base::Bind(&URLRequestFailedJob::ReadRawDataComplete, |
- weak_factory_.GetWeakPtr(), net_error_)); |
- return ERR_IO_PENDING; |
+ FROM_HERE, |
+ base::Bind(&URLRequestFailedJob::NotifyDone, weak_factory_.GetWeakPtr(), |
+ URLRequestStatus(URLRequestStatus::FAILED, net_error_))); |
+ return false; |
} |
int URLRequestFailedJob::GetResponseCode() const { |
@@ -175,17 +195,4 @@ GURL URLRequestFailedJob::GetMockHttpsUrlForHostname( |
URLRequestFailedJob::~URLRequestFailedJob() { |
} |
-void URLRequestFailedJob::StartAsync() { |
- if (phase_ == START) { |
- if (net_error_ != ERR_IO_PENDING) { |
- NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, net_error_)); |
- return; |
- } |
- SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
- return; |
- } |
- response_info_.headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); |
- NotifyHeadersComplete(); |
-} |
- |
} // namespace net |