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

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

Issue 835623003: Add a delay when unlocking WebSocket endpoints. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document WebSocketEndpointLockManager Created 5 years, 11 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/socket/websocket_transport_client_socket_pool_unittest.cc ('k') | no next file » | 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 requested_subprotocols) {} 100 requested_subprotocols) {}
101 101
102 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 ~WebSocketStreamCreateTest() override {
111 // Permit any endpoint locks to be released.
112 stream_request_.reset();
113 stream_.reset();
114 RunUntilIdle();
115 }
110 116
111 void CreateAndConnectCustomResponse( 117 void CreateAndConnectCustomResponse(
112 const std::string& socket_url, 118 const std::string& socket_url,
113 const std::string& socket_path, 119 const std::string& socket_path,
114 const std::vector<std::string>& sub_protocols, 120 const std::vector<std::string>& sub_protocols,
115 const std::string& origin, 121 const std::string& origin,
116 const std::string& extra_request_headers, 122 const std::string& extra_request_headers,
117 const std::string& response_body, 123 const std::string& response_body,
118 scoped_ptr<base::Timer> timer = scoped_ptr<base::Timer>()) { 124 scoped_ptr<base::Timer> timer = scoped_ptr<base::Timer>()) {
119 url_request_context_host_.SetExpectations( 125 url_request_context_host_.SetExpectations(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 scoped_ptr<WebSocketStream> stream_; 248 scoped_ptr<WebSocketStream> stream_;
243 // Only set if the connection failed. 249 // Only set if the connection failed.
244 std::string failure_message_; 250 std::string failure_message_;
245 bool has_failed_; 251 bool has_failed_;
246 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_; 252 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_;
247 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_; 253 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_;
248 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_; 254 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_;
249 SSLInfo ssl_info_; 255 SSLInfo ssl_info_;
250 bool ssl_fatal_; 256 bool ssl_fatal_;
251 ScopedVector<SSLSocketDataProvider> ssl_data_; 257 ScopedVector<SSLSocketDataProvider> ssl_data_;
258 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_;
252 }; 259 };
253 260
254 // There are enough tests of the Sec-WebSocket-Extensions header that they 261 // There are enough tests of the Sec-WebSocket-Extensions header that they
255 // deserve their own test fixture. 262 // deserve their own test fixture.
256 class WebSocketStreamCreateExtensionTest : public WebSocketStreamCreateTest { 263 class WebSocketStreamCreateExtensionTest : public WebSocketStreamCreateTest {
257 public: 264 public:
258 // Performs a standard connect, with the value of the Sec-WebSocket-Extensions 265 // Performs a standard connect, with the value of the Sec-WebSocket-Extensions
259 // header in the response set to |extensions_header_value|. Runs the event 266 // header in the response set to |extensions_header_value|. Runs the event
260 // loop to allow the connect to complete. 267 // loop to allow the connect to complete.
261 void CreateAndConnectWithExtensions( 268 void CreateAndConnectWithExtensions(
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 if (original) { 1460 if (original) {
1454 samples->Subtract(*original); // Cancel the original values. 1461 samples->Subtract(*original); // Cancel the original values.
1455 } 1462 }
1456 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); 1463 EXPECT_EQ(1, samples->GetCount(INCOMPLETE));
1457 EXPECT_EQ(0, samples->GetCount(CONNECTED)); 1464 EXPECT_EQ(0, samples->GetCount(CONNECTED));
1458 EXPECT_EQ(0, samples->GetCount(FAILED)); 1465 EXPECT_EQ(0, samples->GetCount(FAILED));
1459 } 1466 }
1460 1467
1461 } // namespace 1468 } // namespace
1462 } // namespace net 1469 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698