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

Side by Side Diff: net/websockets/websocket_stream_test.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_stream.cc ('k') | net/websockets/websocket_throttle_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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // deterministic key to use in the WebSocket handshake. 92 // deterministic key to use in the WebSocket handshake.
93 class DeterministicKeyWebSocketHandshakeStreamCreateHelper 93 class DeterministicKeyWebSocketHandshakeStreamCreateHelper
94 : public WebSocketHandshakeStreamCreateHelper { 94 : public WebSocketHandshakeStreamCreateHelper {
95 public: 95 public:
96 DeterministicKeyWebSocketHandshakeStreamCreateHelper( 96 DeterministicKeyWebSocketHandshakeStreamCreateHelper(
97 WebSocketStream::ConnectDelegate* connect_delegate, 97 WebSocketStream::ConnectDelegate* connect_delegate,
98 const std::vector<std::string>& requested_subprotocols) 98 const std::vector<std::string>& requested_subprotocols)
99 : WebSocketHandshakeStreamCreateHelper(connect_delegate, 99 : WebSocketHandshakeStreamCreateHelper(connect_delegate,
100 requested_subprotocols) {} 100 requested_subprotocols) {}
101 101
102 virtual void OnStreamCreated(WebSocketBasicHandshakeStream* stream) override { 102 void OnStreamCreated(WebSocketBasicHandshakeStream* stream) override {
103 stream->SetWebSocketKeyForTesting("dGhlIHNhbXBsZSBub25jZQ=="); 103 stream->SetWebSocketKeyForTesting("dGhlIHNhbXBsZSBub25jZQ==");
104 } 104 }
105 }; 105 };
106 106
107 class WebSocketStreamCreateTest : public ::testing::Test { 107 class WebSocketStreamCreateTest : public ::testing::Test {
108 public: 108 public:
109 WebSocketStreamCreateTest() : has_failed_(false), ssl_fatal_(false) {} 109 WebSocketStreamCreateTest() : has_failed_(false), ssl_fatal_(false) {}
110 110
111 void CreateAndConnectCustomResponse( 111 void CreateAndConnectCustomResponse(
112 const std::string& socket_url, 112 const std::string& socket_url,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 const std::string& failure_message() const { return failure_message_; } 196 const std::string& failure_message() const { return failure_message_; }
197 bool has_failed() const { return has_failed_; } 197 bool has_failed() const { return has_failed_; }
198 198
199 class TestConnectDelegate : public WebSocketStream::ConnectDelegate { 199 class TestConnectDelegate : public WebSocketStream::ConnectDelegate {
200 public: 200 public:
201 explicit TestConnectDelegate(WebSocketStreamCreateTest* owner) 201 explicit TestConnectDelegate(WebSocketStreamCreateTest* owner)
202 : owner_(owner) {} 202 : owner_(owner) {}
203 203
204 virtual void OnSuccess(scoped_ptr<WebSocketStream> stream) override { 204 void OnSuccess(scoped_ptr<WebSocketStream> stream) override {
205 stream.swap(owner_->stream_); 205 stream.swap(owner_->stream_);
206 } 206 }
207 207
208 virtual void OnFailure(const std::string& message) override { 208 void OnFailure(const std::string& message) override {
209 owner_->has_failed_ = true; 209 owner_->has_failed_ = true;
210 owner_->failure_message_ = message; 210 owner_->failure_message_ = message;
211 } 211 }
212 212
213 virtual void OnStartOpeningHandshake( 213 void OnStartOpeningHandshake(
214 scoped_ptr<WebSocketHandshakeRequestInfo> request) override { 214 scoped_ptr<WebSocketHandshakeRequestInfo> request) override {
215 // Can be called multiple times (in the case of HTTP auth). Last call 215 // Can be called multiple times (in the case of HTTP auth). Last call
216 // wins. 216 // wins.
217 owner_->request_info_ = request.Pass(); 217 owner_->request_info_ = request.Pass();
218 } 218 }
219 virtual void OnFinishOpeningHandshake( 219 void OnFinishOpeningHandshake(
220 scoped_ptr<WebSocketHandshakeResponseInfo> response) override { 220 scoped_ptr<WebSocketHandshakeResponseInfo> response) override {
221 if (owner_->response_info_) 221 if (owner_->response_info_)
222 ADD_FAILURE(); 222 ADD_FAILURE();
223 owner_->response_info_ = response.Pass(); 223 owner_->response_info_ = response.Pass();
224 } 224 }
225 virtual void OnSSLCertificateError( 225 void OnSSLCertificateError(
226 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> 226 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks>
227 ssl_error_callbacks, 227 ssl_error_callbacks,
228 const SSLInfo& ssl_info, 228 const SSLInfo& ssl_info,
229 bool fatal) override { 229 bool fatal) override {
230 owner_->ssl_error_callbacks_ = ssl_error_callbacks.Pass(); 230 owner_->ssl_error_callbacks_ = ssl_error_callbacks.Pass();
231 owner_->ssl_info_ = ssl_info; 231 owner_->ssl_info_ = ssl_info;
232 owner_->ssl_fatal_ = fatal; 232 owner_->ssl_fatal_ = fatal;
233 } 233 }
234 234
235 private: 235 private:
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 if (original) { 1453 if (original) {
1454 samples->Subtract(*original); // Cancel the original values. 1454 samples->Subtract(*original); // Cancel the original values.
1455 } 1455 }
1456 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); 1456 EXPECT_EQ(1, samples->GetCount(INCOMPLETE));
1457 EXPECT_EQ(0, samples->GetCount(CONNECTED)); 1457 EXPECT_EQ(0, samples->GetCount(CONNECTED));
1458 EXPECT_EQ(0, samples->GetCount(FAILED)); 1458 EXPECT_EQ(0, samples->GetCount(FAILED));
1459 } 1459 }
1460 1460
1461 } // namespace 1461 } // namespace
1462 } // namespace net 1462 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_stream.cc ('k') | net/websockets/websocket_throttle_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698