| OLD | NEW |
| 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_transport_client_socket_pool.h" | 5 #include "net/socket/websocket_transport_client_socket_pool.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 | 1103 |
| 1104 connect_trigger.Run(); // Calls InvokeUserCallbackLater() | 1104 connect_trigger.Run(); // Calls InvokeUserCallbackLater() |
| 1105 | 1105 |
| 1106 request(0)->handle()->Reset(); // calls CancelRequest() | 1106 request(0)->handle()->Reset(); // calls CancelRequest() |
| 1107 | 1107 |
| 1108 // We should now be able to create a new connection without blocking on the | 1108 // We should now be able to create a new connection without blocking on the |
| 1109 // endpoint lock. | 1109 // endpoint lock. |
| 1110 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); | 1110 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 // A handshake completing and then the WebSocket closing should only release one |
| 1114 // Endpoint, not two. |
| 1115 TEST_F(WebSocketTransportClientSocketPoolTest, EndpointLockIsOnlyReleasedOnce) { |
| 1116 host_resolver_->set_synchronous_mode(true); |
| 1117 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); |
| 1118 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); |
| 1119 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); |
| 1120 // First socket completes handshake. |
| 1121 WebSocketTransportClientSocketPool::UnlockEndpoint(request(0)->handle()); |
| 1122 // First socket is closed. |
| 1123 request(0)->handle()->Reset(); |
| 1124 // Second socket should have been released. |
| 1125 EXPECT_EQ(OK, request(1)->WaitForResult()); |
| 1126 // Third socket should still be waiting for endpoint. |
| 1127 ASSERT_FALSE(request(2)->handle()->is_initialized()); |
| 1128 EXPECT_EQ(LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET, |
| 1129 request(2)->handle()->GetLoadState()); |
| 1130 } |
| 1131 |
| 1113 } // namespace | 1132 } // namespace |
| 1114 | 1133 |
| 1115 } // namespace net | 1134 } // namespace net |
| OLD | NEW |