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

Unified Diff: net/test/url_request/url_request_failed_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/test/url_request/url_request_failed_job.h ('k') | net/test/url_request/url_request_mock_data_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/test/url_request/url_request_failed_job.h ('k') | net/test/url_request/url_request_mock_data_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698