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 e4ac6a675d0f459b96fa4ba1538def7372968be3..d7c479b14f719842b43379380cac89f9f7fe0c90 100644 |
--- a/net/test/url_request/url_request_failed_job.cc |
+++ b/net/test/url_request/url_request_failed_job.cc |
@@ -97,40 +97,20 @@ URLRequestFailedJob::URLRequestFailedJob(URLRequest* request, |
} |
void URLRequestFailedJob::Start() { |
- 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(); |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&URLRequestFailedJob::StartAsync, weak_factory_.GetWeakPtr())); |
} |
-bool URLRequestFailedJob::ReadRawData(IOBuffer* buf, |
- int buf_size, |
- int* bytes_read) { |
+int URLRequestFailedJob::ReadRawData(IOBuffer* buf, int buf_size) { |
CHECK(phase_ == READ_SYNC || phase_ == READ_ASYNC); |
- 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_); |
+ if (net_error_ == ERR_IO_PENDING || phase_ == READ_SYNC) |
+ return net_error_; |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, |
- base::Bind(&URLRequestFailedJob::NotifyDone, weak_factory_.GetWeakPtr(), |
- URLRequestStatus(URLRequestStatus::FAILED, net_error_))); |
- return false; |
+ FROM_HERE, base::Bind(&URLRequestFailedJob::ReadRawDataComplete, |
+ weak_factory_.GetWeakPtr(), net_error_)); |
+ return ERR_IO_PENDING; |
} |
int URLRequestFailedJob::GetResponseCode() const { |
@@ -195,4 +175,17 @@ 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 |