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

Unified Diff: net/websockets/websocket_stream.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/websockets/websocket_end_to_end_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_stream.cc
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc
index 9ec6f5c9344674b46ec0f87cbaa5d350465d6960..62ce35bb3e78921c6dab3f291fef3d3a7786cd92 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -61,7 +61,7 @@
const RedirectInfo& redirect_info,
bool* defer_redirect) override;
- void OnResponseStarted(URLRequest* request, int net_error) override;
+ void OnResponseStarted(URLRequest* request) override;
void OnAuthRequired(URLRequest* request,
AuthChallengeInfo* auth_info) override;
@@ -153,8 +153,9 @@
connect_delegate_->OnSuccess(handshake_stream->Upgrade());
}
- std::string FailureMessageFromNetError(int net_error) {
- if (net_error == ERR_TUNNEL_CONNECTION_FAILED) {
+ std::string FailureMessageFromNetError() {
+ int error = url_request_->status().error();
+ if (error == ERR_TUNNEL_CONNECTION_FAILED) {
// This error is common and confusing, so special-case it.
// TODO(ricea): Include the HostPortPair of the selected proxy server in
// the error message. This is not currently possible because it isn't set
@@ -162,26 +163,26 @@
return "Establishing a tunnel via proxy server failed.";
} else {
return std::string("Error in connection establishment: ") +
- ErrorToString(net_error);
+ ErrorToString(url_request_->status().error());
}
}
- void ReportFailure(int net_error) {
+ void ReportFailure() {
DCHECK(timer_);
timer_->Stop();
if (failure_message_.empty()) {
- switch (net_error) {
- case OK:
- case ERR_IO_PENDING:
+ switch (url_request_->status().status()) {
+ case URLRequestStatus::SUCCESS:
+ case URLRequestStatus::IO_PENDING:
break;
- case ERR_ABORTED:
- failure_message_ = "WebSocket opening handshake was canceled";
+ case URLRequestStatus::CANCELED:
+ if (url_request_->status().error() == ERR_TIMED_OUT)
+ failure_message_ = "WebSocket opening handshake timed out";
+ else
+ failure_message_ = "WebSocket opening handshake was canceled";
break;
- case ERR_TIMED_OUT:
- failure_message_ = "WebSocket opening handshake timed out";
- break;
- default:
- failure_message_ = FailureMessageFromNetError(net_error);
+ case URLRequestStatus::FAILED:
+ failure_message_ = FailureMessageFromNetError();
break;
}
}
@@ -281,14 +282,14 @@
}
}
-void Delegate::OnResponseStarted(URLRequest* request, int net_error) {
- DCHECK_NE(ERR_IO_PENDING, net_error);
+void Delegate::OnResponseStarted(URLRequest* request) {
// All error codes, including OK and ABORTED, as with
// Net.ErrorCodesForMainFrame3
- UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes", -net_error);
- if (net_error != OK) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes",
+ -request->status().error());
+ if (!request->status().is_success()) {
DVLOG(3) << "OnResponseStarted (request failed)";
- owner_->ReportFailure(net_error);
+ owner_->ReportFailure();
return;
}
const int response_code = request->GetResponseCode();
@@ -314,7 +315,7 @@
default:
result_ = FAILED;
- owner_->ReportFailure(net_error);
+ owner_->ReportFailure();
}
}
« no previous file with comments | « net/websockets/websocket_end_to_end_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698