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

Side by Side Diff: net/socket/websocket_endpoint_lock_manager_unittest.cc

Issue 436493002: Handle multiple simultanous wss: connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/interator/iterator/ Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/socket/websocket_endpoint_lock_manager.h" 5 #include "net/socket/websocket_endpoint_lock_manager.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/socket/next_proto.h" 8 #include "net/socket/next_proto.h"
9 #include "net/socket/socket_test_util.h" 9 #include "net/socket/socket_test_util.h"
10 #include "net/socket/stream_socket.h" 10 #include "net/socket/stream_socket.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EXPECT_EQ(ERR_IO_PENDING, 189 EXPECT_EQ(ERR_IO_PENDING,
190 instance()->LockEndpoint(DummyEndpoint(), &waiters[1])); 190 instance()->LockEndpoint(DummyEndpoint(), &waiters[1]));
191 191
192 instance()->RememberSocket(&dummy_socket, DummyEndpoint()); 192 instance()->RememberSocket(&dummy_socket, DummyEndpoint());
193 instance()->UnlockSocket(&dummy_socket); 193 instance()->UnlockSocket(&dummy_socket);
194 EXPECT_TRUE(waiters[1].called()); 194 EXPECT_TRUE(waiters[1].called());
195 195
196 UnlockDummyEndpoint(1); 196 UnlockDummyEndpoint(1);
197 } 197 }
198 198
199 // Calling UnlockSocket() on the same socket a second time should be harmless. 199 // UnlockEndpoint() should cause any sockets remembered for this endpoint
200 TEST_F(WebSocketEndpointLockManagerTest, UnlockSocketTwice) { 200 // to be forgotten.
201 TEST_F(WebSocketEndpointLockManagerTest, SocketAssociationForgottenOnUnlock) {
201 FakeWaiter waiter; 202 FakeWaiter waiter;
202 FakeStreamSocket dummy_socket; 203 FakeStreamSocket dummy_socket;
204
203 EXPECT_EQ(OK, instance()->LockEndpoint(DummyEndpoint(), &waiter)); 205 EXPECT_EQ(OK, instance()->LockEndpoint(DummyEndpoint(), &waiter));
204 instance()->RememberSocket(&dummy_socket, DummyEndpoint()); 206 instance()->RememberSocket(&dummy_socket, DummyEndpoint());
205 instance()->UnlockSocket(&dummy_socket); 207 instance()->UnlockEndpoint(DummyEndpoint());
206 instance()->UnlockSocket(&dummy_socket); 208 EXPECT_TRUE(instance()->IsEmpty());
209 }
210
211 // When ownership of the endpoint is passed to a new waiter, the new waiter can
212 // call RememberSocket() again.
213 TEST_F(WebSocketEndpointLockManagerTest, NextWaiterCanCallRememberSocketAgain) {
214 FakeWaiter waiters[2];
215 FakeStreamSocket dummy_sockets[2];
216 EXPECT_EQ(OK, instance()->LockEndpoint(DummyEndpoint(), &waiters[0]));
217 EXPECT_EQ(ERR_IO_PENDING,
218 instance()->LockEndpoint(DummyEndpoint(), &waiters[1]));
219
220 instance()->RememberSocket(&dummy_sockets[0], DummyEndpoint());
221 instance()->UnlockEndpoint(DummyEndpoint());
222 EXPECT_TRUE(waiters[1].called());
223 instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint());
224
225 UnlockDummyEndpoint(1);
207 } 226 }
208 227
209 } // namespace 228 } // namespace
210 229
211 } // namespace net 230 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/socket/websocket_transport_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698