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

Unified Diff: net/websockets/websocket_stream.cc

Issue 304093003: Support recovery from SSL errors for new WebSocket implementation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-for-pool-throttling
Patch Set: Add DCHECKs to websocket_host.cc Created 6 years, 7 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 546e01b852cb4a10230110b177a9aa4112d041e1..460a44b1e8b7e74942319b8bdc5b878800852f10 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -13,6 +13,7 @@
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/websockets/websocket_errors.h"
+#include "net/websockets/websocket_event_interface.h"
#include "net/websockets/websocket_handshake_constants.h"
#include "net/websockets/websocket_handshake_stream_base.h"
#include "net/websockets/websocket_handshake_stream_create_helper.h"
@@ -42,6 +43,12 @@ class Delegate : public URLRequest::Delegate {
}
// Implementation of URLRequest::Delegate methods.
+ virtual void OnReceivedRedirect(URLRequest* request,
tyoshino (SeeGerritForStatus) 2014/06/03 12:11:59 write a comment to roughly explain why we never re
Adam Rice 2014/06/03 12:59:51 Done.
+ const GURL& new_url,
+ bool* defer_redirect) OVERRIDE {
+ NOTREACHED();
+ }
+
virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
virtual void OnAuthRequired(URLRequest* request,
@@ -125,6 +132,10 @@ class StreamRequestImpl : public WebSocketStreamRequest {
connect_delegate_->OnFailure(failure_message);
}
+ WebSocketStream::ConnectDelegate* connect_delegate() const {
+ return connect_delegate_.get();
+ }
+
private:
// |delegate_| needs to be declared before |url_request_| so that it gets
// initialised first.
@@ -140,7 +151,35 @@ class StreamRequestImpl : public WebSocketStreamRequest {
WebSocketHandshakeStreamCreateHelper* create_helper_;
};
+class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks {
+ public:
+ explicit SSLErrorCallbacks(URLRequest* url_request)
+ : url_request_(url_request) {}
+
+ virtual void CancelSSLRequest(int error, const SSLInfo* ssl_info) OVERRIDE {
+ if (ssl_info) {
+ url_request_->CancelWithSSLError(error, *ssl_info);
+ } else {
+ url_request_->CancelWithError(error);
+ }
+ }
+
+ virtual void ContinueSSLRequest() OVERRIDE {
+ url_request_->ContinueDespiteLastError();
+ }
+
+ private:
+ URLRequest* url_request_;
+};
+
void Delegate::OnResponseStarted(URLRequest* request) {
+ if (!request->status().is_success()) {
+ DVLOG(3) << "OnResponseStarted (request failed)";
+ owner_->ReportFailure();
+ return;
+ }
+ DVLOG(3) << "OnResponseStarted (response code " << request->GetResponseCode()
+ << ")";
switch (request->GetResponseCode()) {
case HTTP_SWITCHING_PROTOCOLS:
result_ = CONNECTED;
@@ -159,18 +198,25 @@ void Delegate::OnResponseStarted(URLRequest* request) {
void Delegate::OnAuthRequired(URLRequest* request,
AuthChallengeInfo* auth_info) {
+ // This should only be called if credentials are not already stored.
request->CancelAuth();
}
void Delegate::OnCertificateRequested(URLRequest* request,
SSLCertRequestInfo* cert_request_info) {
- request->ContinueWithCertificate(NULL);
+ // URLRequest should handle the non-interactive cases, so there is nothing
+ // more for us to do here.
tyoshino (SeeGerritForStatus) 2014/06/03 12:11:59 could you please elaborate this comment?
Adam Rice 2014/06/03 12:59:51 Done.
+ request->Cancel();
}
void Delegate::OnSSLCertificateError(URLRequest* request,
const SSLInfo& ssl_info,
bool fatal) {
- request->Cancel();
+ owner_->connect_delegate()->OnSSLCertificateError(
+ scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks>(
+ new SSLErrorCallbacks(request)),
+ ssl_info,
+ fatal);
}
void Delegate::OnReadCompleted(URLRequest* request, int bytes_read) {

Powered by Google App Engine
This is Rietveld 408576698