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

Unified Diff: net/test/spawned_test_server/spawner_communicator.cc

Issue 2313013002: Revert of Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: Created 4 years, 3 months 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/spawned_test_server/spawner_communicator.h ('k') | net/url_request/report_sender.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/spawned_test_server/spawner_communicator.cc
diff --git a/net/test/spawned_test_server/spawner_communicator.cc b/net/test/spawned_test_server/spawner_communicator.cc
index 3a1566db4cfd4928b727e83711ece46de357dffb..952b85c74bf76cf4096fe88d2bd31cc0a6bf7e6e 100644
--- a/net/test/spawned_test_server/spawner_communicator.cc
+++ b/net/test/spawned_test_server/spawner_communicator.cc
@@ -228,14 +228,12 @@
if (!data->DoesRequestIdMatch(id))
return;
// Set the result code and cancel the timed-out task.
- int result = cur_request_->CancelWithError(ERR_TIMED_OUT);
- OnSpawnerCommandCompleted(cur_request_.get(), result);
-}
-
-void SpawnerCommunicator::OnSpawnerCommandCompleted(URLRequest* request,
- int net_error) {
- DCHECK_NE(ERR_IO_PENDING, net_error);
-
+ data->SetResultCode(ERR_TIMED_OUT);
+ cur_request_->Cancel();
+ OnSpawnerCommandCompleted(cur_request_.get());
+}
+
+void SpawnerCommunicator::OnSpawnerCommandCompleted(URLRequest* request) {
if (!cur_request_.get())
return;
DCHECK_EQ(request, cur_request_.get());
@@ -244,11 +242,13 @@
DCHECK(data);
// If request is faild,return the error code.
- if (net_error != OK)
- data->SetResultCode(net_error);
+ if (!cur_request_->status().is_success())
+ data->SetResultCode(cur_request_->status().error());
if (!data->IsResultOK()) {
- LOG(ERROR) << "request failed, error: " << net_error;
+ LOG(ERROR) << "request failed, status: "
+ << static_cast<int>(request->status().status())
+ << ", error: " << request->status().error();
// Clear the buffer of received data if any net error happened.
data->ClearReceivedData();
} else {
@@ -275,35 +275,30 @@
IOBuffer* buf = data->buf();
// Read as many bytes as are available synchronously.
while (true) {
- int rv = request->Read(buf, kBufferSize);
- if (rv == ERR_IO_PENDING)
- return;
-
- if (rv < 0) {
- OnSpawnerCommandCompleted(request, rv);
+ int num_bytes;
+ if (!request->Read(buf, kBufferSize, &num_bytes)) {
+ // Check whether the read failed synchronously.
+ if (!request->status().is_io_pending())
+ OnSpawnerCommandCompleted(request);
return;
}
-
- if (!data->ConsumeBytesRead(rv)) {
- OnSpawnerCommandCompleted(request, rv);
+ if (!data->ConsumeBytesRead(num_bytes)) {
+ OnSpawnerCommandCompleted(request);
return;
}
}
}
-void SpawnerCommunicator::OnResponseStarted(URLRequest* request,
- int net_error) {
+void SpawnerCommunicator::OnResponseStarted(URLRequest* request) {
DCHECK_EQ(request, cur_request_.get());
- DCHECK_NE(ERR_IO_PENDING, net_error);
-
SpawnerRequestData* data =
static_cast<SpawnerRequestData*>(cur_request_->GetUserData(this));
DCHECK(data);
data->IncreaseResponseStartedCount();
- if (net_error != OK) {
- OnSpawnerCommandCompleted(request, net_error);
+ if (!request->status().is_success()) {
+ OnSpawnerCommandCompleted(request);
return;
}
@@ -313,7 +308,7 @@
<< request->response_headers()->GetStatusLine();
data->SetResultCode(ERR_FAILED);
request->Cancel();
- OnSpawnerCommandCompleted(request, ERR_ABORTED);
+ OnSpawnerCommandCompleted(request);
return;
}
@@ -321,8 +316,6 @@
}
void SpawnerCommunicator::OnReadCompleted(URLRequest* request, int num_bytes) {
- DCHECK_NE(ERR_IO_PENDING, num_bytes);
-
if (!cur_request_.get())
return;
DCHECK_EQ(request, cur_request_.get());
@@ -334,9 +327,7 @@
// Keep reading.
ReadResult(request);
} else {
- // |bytes_read| < 0
- int net_error = num_bytes;
- OnSpawnerCommandCompleted(request, net_error);
+ OnSpawnerCommandCompleted(request);
}
}
« no previous file with comments | « net/test/spawned_test_server/spawner_communicator.h ('k') | net/url_request/report_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698