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

Side by Side Diff: net/websockets/websocket_stream.cc

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « net/websockets/websocket_job_test.cc ('k') | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 public: 41 public:
42 enum HandshakeResult { 42 enum HandshakeResult {
43 INCOMPLETE, 43 INCOMPLETE,
44 CONNECTED, 44 CONNECTED,
45 FAILED, 45 FAILED,
46 NUM_HANDSHAKE_RESULT_TYPES, 46 NUM_HANDSHAKE_RESULT_TYPES,
47 }; 47 };
48 48
49 explicit Delegate(StreamRequestImpl* owner) 49 explicit Delegate(StreamRequestImpl* owner)
50 : owner_(owner), result_(INCOMPLETE) {} 50 : owner_(owner), result_(INCOMPLETE) {}
51 virtual ~Delegate() { 51 ~Delegate() override {
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 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 void OnResponseStarted(URLRequest* request) override;
69 69
70 virtual void OnAuthRequired(URLRequest* request, 70 void OnAuthRequired(URLRequest* request,
71 AuthChallengeInfo* auth_info) override; 71 AuthChallengeInfo* auth_info) override;
72 72
73 virtual void OnCertificateRequested(URLRequest* request, 73 void OnCertificateRequested(URLRequest* request,
74 SSLCertRequestInfo* cert_request_info) 74 SSLCertRequestInfo* cert_request_info) override;
75 override;
76 75
77 virtual void OnSSLCertificateError(URLRequest* request, 76 void OnSSLCertificateError(URLRequest* request,
78 const SSLInfo& ssl_info, 77 const SSLInfo& ssl_info,
79 bool fatal) override; 78 bool fatal) override;
80 79
81 virtual void OnReadCompleted(URLRequest* request, int bytes_read) override; 80 void OnReadCompleted(URLRequest* request, int bytes_read) override;
82 81
83 private: 82 private:
84 StreamRequestImpl* owner_; 83 StreamRequestImpl* owner_;
85 HandshakeResult result_; 84 HandshakeResult result_;
86 }; 85 };
87 86
88 class StreamRequestImpl : public WebSocketStreamRequest { 87 class StreamRequestImpl : public WebSocketStreamRequest {
89 public: 88 public:
90 StreamRequestImpl( 89 StreamRequestImpl(
91 const GURL& url, 90 const GURL& url,
(...skipping 19 matching lines...) Expand all
111 url_request_->SetUserData( 110 url_request_->SetUserData(
112 WebSocketHandshakeStreamBase::CreateHelper::DataKey(), 111 WebSocketHandshakeStreamBase::CreateHelper::DataKey(),
113 create_helper_); 112 create_helper_);
114 url_request_->SetLoadFlags(LOAD_DISABLE_CACHE | 113 url_request_->SetLoadFlags(LOAD_DISABLE_CACHE |
115 LOAD_BYPASS_CACHE | 114 LOAD_BYPASS_CACHE |
116 LOAD_DO_NOT_PROMPT_FOR_LOGIN); 115 LOAD_DO_NOT_PROMPT_FOR_LOGIN);
117 } 116 }
118 117
119 // Destroying this object destroys the URLRequest, which cancels the request 118 // Destroying this object destroys the URLRequest, which cancels the request
120 // and so terminates the handshake if it is incomplete. 119 // and so terminates the handshake if it is incomplete.
121 virtual ~StreamRequestImpl() {} 120 ~StreamRequestImpl() override {}
122 121
123 void Start(scoped_ptr<base::Timer> timer) { 122 void Start(scoped_ptr<base::Timer> timer) {
124 DCHECK(timer); 123 DCHECK(timer);
125 TimeDelta timeout(TimeDelta::FromSeconds( 124 TimeDelta timeout(TimeDelta::FromSeconds(
126 kHandshakeTimeoutIntervalInSeconds)); 125 kHandshakeTimeoutIntervalInSeconds));
127 timer_ = timer.Pass(); 126 timer_ = timer.Pass();
128 timer_->Start(FROM_HERE, timeout, 127 timer_->Start(FROM_HERE, timeout,
129 base::Bind(&StreamRequestImpl::OnTimeout, 128 base::Bind(&StreamRequestImpl::OnTimeout,
130 base::Unretained(this))); 129 base::Unretained(this)));
131 url_request_->Start(); 130 url_request_->Start();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 198
200 // A timer for handshake timeout. 199 // A timer for handshake timeout.
201 scoped_ptr<base::Timer> timer_; 200 scoped_ptr<base::Timer> timer_;
202 }; 201 };
203 202
204 class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks { 203 class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks {
205 public: 204 public:
206 explicit SSLErrorCallbacks(URLRequest* url_request) 205 explicit SSLErrorCallbacks(URLRequest* url_request)
207 : url_request_(url_request) {} 206 : url_request_(url_request) {}
208 207
209 virtual void CancelSSLRequest(int error, const SSLInfo* ssl_info) override { 208 void CancelSSLRequest(int error, const SSLInfo* ssl_info) override {
210 if (ssl_info) { 209 if (ssl_info) {
211 url_request_->CancelWithSSLError(error, *ssl_info); 210 url_request_->CancelWithSSLError(error, *ssl_info);
212 } else { 211 } else {
213 url_request_->CancelWithError(error); 212 url_request_->CancelWithError(error);
214 } 213 }
215 } 214 }
216 215
217 virtual void ContinueSSLRequest() override { 216 void ContinueSSLRequest() override {
218 url_request_->ContinueDespiteLastError(); 217 url_request_->ContinueDespiteLastError();
219 } 218 }
220 219
221 private: 220 private:
222 URLRequest* url_request_; 221 URLRequest* url_request_;
223 }; 222 };
224 223
225 void Delegate::OnResponseStarted(URLRequest* request) { 224 void Delegate::OnResponseStarted(URLRequest* request) {
226 // All error codes, including OK and ABORTED, as with 225 // All error codes, including OK and ABORTED, as with
227 // Net.ErrorCodesForMainFrame3 226 // Net.ErrorCodesForMainFrame3
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr( 347 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr(
349 new WebSocketHandshakeResponseInfo(url, 348 new WebSocketHandshakeResponseInfo(url,
350 headers->response_code(), 349 headers->response_code(),
351 headers->GetStatusText(), 350 headers->GetStatusText(),
352 headers, 351 headers,
353 response_time))); 352 response_time)));
354 } 353 }
355 } 354 }
356 355
357 } // namespace net 356 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_job_test.cc ('k') | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698