OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/websockets/websocket_stream.h" | 5 #include "net/websockets/websocket_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 explicit Delegate(StreamRequestImpl* owner) | 49 explicit Delegate(StreamRequestImpl* owner) |
50 : owner_(owner), result_(INCOMPLETE) {} | 50 : owner_(owner), result_(INCOMPLETE) {} |
51 virtual ~Delegate() { | 51 virtual ~Delegate() { |
52 UMA_HISTOGRAM_ENUMERATION( | 52 UMA_HISTOGRAM_ENUMERATION( |
53 "Net.WebSocket.HandshakeResult", result_, NUM_HANDSHAKE_RESULT_TYPES); | 53 "Net.WebSocket.HandshakeResult", result_, NUM_HANDSHAKE_RESULT_TYPES); |
54 } | 54 } |
55 | 55 |
56 // Implementation of URLRequest::Delegate methods. | 56 // Implementation of URLRequest::Delegate methods. |
57 virtual void OnReceivedRedirect(URLRequest* request, | 57 virtual void OnReceivedRedirect(URLRequest* request, |
58 const RedirectInfo& redirect_info, | 58 const RedirectInfo& redirect_info, |
59 bool* defer_redirect) OVERRIDE { | 59 bool* defer_redirect) override { |
60 // HTTP status codes returned by HttpStreamParser are filtered by | 60 // HTTP status codes returned by HttpStreamParser are filtered by |
61 // WebSocketBasicHandshakeStream, and only 101, 401 and 407 are permitted | 61 // WebSocketBasicHandshakeStream, and only 101, 401 and 407 are permitted |
62 // back up the stack to HttpNetworkTransaction. In particular, redirect | 62 // back up the stack to HttpNetworkTransaction. In particular, redirect |
63 // codes are never allowed, and so URLRequest never sees a redirect on a | 63 // codes are never allowed, and so URLRequest never sees a redirect on a |
64 // WebSocket request. | 64 // WebSocket request. |
65 NOTREACHED(); | 65 NOTREACHED(); |
66 } | 66 } |
67 | 67 |
68 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; | 68 virtual void OnResponseStarted(URLRequest* request) override; |
69 | 69 |
70 virtual void OnAuthRequired(URLRequest* request, | 70 virtual void OnAuthRequired(URLRequest* request, |
71 AuthChallengeInfo* auth_info) OVERRIDE; | 71 AuthChallengeInfo* auth_info) override; |
72 | 72 |
73 virtual void OnCertificateRequested(URLRequest* request, | 73 virtual void OnCertificateRequested(URLRequest* request, |
74 SSLCertRequestInfo* cert_request_info) | 74 SSLCertRequestInfo* cert_request_info) |
75 OVERRIDE; | 75 override; |
76 | 76 |
77 virtual void OnSSLCertificateError(URLRequest* request, | 77 virtual void OnSSLCertificateError(URLRequest* request, |
78 const SSLInfo& ssl_info, | 78 const SSLInfo& ssl_info, |
79 bool fatal) OVERRIDE; | 79 bool fatal) override; |
80 | 80 |
81 virtual void OnReadCompleted(URLRequest* request, int bytes_read) OVERRIDE; | 81 virtual void OnReadCompleted(URLRequest* request, int bytes_read) override; |
82 | 82 |
83 private: | 83 private: |
84 StreamRequestImpl* owner_; | 84 StreamRequestImpl* owner_; |
85 HandshakeResult result_; | 85 HandshakeResult result_; |
86 }; | 86 }; |
87 | 87 |
88 class StreamRequestImpl : public WebSocketStreamRequest { | 88 class StreamRequestImpl : public WebSocketStreamRequest { |
89 public: | 89 public: |
90 StreamRequestImpl( | 90 StreamRequestImpl( |
91 const GURL& url, | 91 const GURL& url, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // A timer for handshake timeout. | 200 // A timer for handshake timeout. |
201 scoped_ptr<base::Timer> timer_; | 201 scoped_ptr<base::Timer> timer_; |
202 }; | 202 }; |
203 | 203 |
204 class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks { | 204 class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks { |
205 public: | 205 public: |
206 explicit SSLErrorCallbacks(URLRequest* url_request) | 206 explicit SSLErrorCallbacks(URLRequest* url_request) |
207 : url_request_(url_request) {} | 207 : url_request_(url_request) {} |
208 | 208 |
209 virtual void CancelSSLRequest(int error, const SSLInfo* ssl_info) OVERRIDE { | 209 virtual void CancelSSLRequest(int error, const SSLInfo* ssl_info) override { |
210 if (ssl_info) { | 210 if (ssl_info) { |
211 url_request_->CancelWithSSLError(error, *ssl_info); | 211 url_request_->CancelWithSSLError(error, *ssl_info); |
212 } else { | 212 } else { |
213 url_request_->CancelWithError(error); | 213 url_request_->CancelWithError(error); |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 virtual void ContinueSSLRequest() OVERRIDE { | 217 virtual void ContinueSSLRequest() override { |
218 url_request_->ContinueDespiteLastError(); | 218 url_request_->ContinueDespiteLastError(); |
219 } | 219 } |
220 | 220 |
221 private: | 221 private: |
222 URLRequest* url_request_; | 222 URLRequest* url_request_; |
223 }; | 223 }; |
224 | 224 |
225 void Delegate::OnResponseStarted(URLRequest* request) { | 225 void Delegate::OnResponseStarted(URLRequest* request) { |
226 // All error codes, including OK and ABORTED, as with | 226 // All error codes, including OK and ABORTED, as with |
227 // Net.ErrorCodesForMainFrame3 | 227 // Net.ErrorCodesForMainFrame3 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr( | 348 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr( |
349 new WebSocketHandshakeResponseInfo(url, | 349 new WebSocketHandshakeResponseInfo(url, |
350 headers->response_code(), | 350 headers->response_code(), |
351 headers->GetStatusText(), | 351 headers->GetStatusText(), |
352 headers, | 352 headers, |
353 response_time))); | 353 response_time))); |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 } // namespace net | 357 } // namespace net |
OLD | NEW |