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

Unified Diff: net/websockets/websocket_stream.cc

Issue 2265873002: Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 4 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
Index: net/websockets/websocket_stream.cc
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc
index 62ce35bb3e78921c6dab3f291fef3d3a7786cd92..9ec6f5c9344674b46ec0f87cbaa5d350465d6960 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -61,7 +61,7 @@ class Delegate : public URLRequest::Delegate {
const RedirectInfo& redirect_info,
bool* defer_redirect) override;
- void OnResponseStarted(URLRequest* request) override;
+ void OnResponseStarted(URLRequest* request, int net_error) override;
void OnAuthRequired(URLRequest* request,
AuthChallengeInfo* auth_info) override;
@@ -153,9 +153,8 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequest {
connect_delegate_->OnSuccess(handshake_stream->Upgrade());
}
- std::string FailureMessageFromNetError() {
- int error = url_request_->status().error();
- if (error == ERR_TUNNEL_CONNECTION_FAILED) {
+ std::string FailureMessageFromNetError(int net_error) {
+ if (net_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
@@ -163,26 +162,26 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequest {
return "Establishing a tunnel via proxy server failed.";
} else {
return std::string("Error in connection establishment: ") +
- ErrorToString(url_request_->status().error());
+ ErrorToString(net_error);
}
}
- void ReportFailure() {
+ void ReportFailure(int net_error) {
DCHECK(timer_);
timer_->Stop();
if (failure_message_.empty()) {
- switch (url_request_->status().status()) {
- case URLRequestStatus::SUCCESS:
- case URLRequestStatus::IO_PENDING:
+ switch (net_error) {
+ case OK:
+ case ERR_IO_PENDING:
break;
- 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";
+ case ERR_ABORTED:
+ failure_message_ = "WebSocket opening handshake was canceled";
break;
- case URLRequestStatus::FAILED:
- failure_message_ = FailureMessageFromNetError();
+ case ERR_TIMED_OUT:
+ failure_message_ = "WebSocket opening handshake timed out";
+ break;
+ default:
+ failure_message_ = FailureMessageFromNetError(net_error);
break;
}
}
@@ -282,14 +281,14 @@ void Delegate::OnReceivedRedirect(URLRequest* request,
}
}
-void Delegate::OnResponseStarted(URLRequest* request) {
+void Delegate::OnResponseStarted(URLRequest* request, int net_error) {
+ DCHECK_NE(ERR_IO_PENDING, net_error);
// All error codes, including OK and ABORTED, as with
// Net.ErrorCodesForMainFrame3
- UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes",
- -request->status().error());
- if (!request->status().is_success()) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes", -net_error);
+ if (net_error != OK) {
DVLOG(3) << "OnResponseStarted (request failed)";
- owner_->ReportFailure();
+ owner_->ReportFailure(net_error);
return;
}
const int response_code = request->GetResponseCode();
@@ -315,7 +314,7 @@ void Delegate::OnResponseStarted(URLRequest* request) {
default:
result_ = FAILED;
- owner_->ReportFailure();
+ owner_->ReportFailure(net_error);
}
}

Powered by Google App Engine
This is Rietveld 408576698