| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/socks_client_socket_pool.h" | 5 #include "net/socket/socks_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/run_loop.h" |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "net/base/load_timing_info.h" | 11 #include "net/base/load_timing_info.h" |
| 11 #include "net/base/load_timing_info_test_util.h" | 12 #include "net/base/load_timing_info_test_util.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
| 14 #include "net/dns/mock_host_resolver.h" | 15 #include "net/dns/mock_host_resolver.h" |
| 15 #include "net/socket/client_socket_factory.h" | 16 #include "net/socket/client_socket_factory.h" |
| 16 #include "net/socket/client_socket_handle.h" | 17 #include "net/socket/client_socket_handle.h" |
| 17 #include "net/socket/socket_test_util.h" | 18 #include "net/socket/socket_test_util.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 291 |
| 291 rv = StartRequestV5("a", LOW); | 292 rv = StartRequestV5("a", LOW); |
| 292 EXPECT_EQ(ERR_IO_PENDING, rv); | 293 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 293 | 294 |
| 294 pool_.CancelRequest("a", (*requests())[0]->handle()); | 295 pool_.CancelRequest("a", (*requests())[0]->handle()); |
| 295 pool_.CancelRequest("a", (*requests())[1]->handle()); | 296 pool_.CancelRequest("a", (*requests())[1]->handle()); |
| 296 // Requests in the connect phase don't actually get cancelled. | 297 // Requests in the connect phase don't actually get cancelled. |
| 297 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); | 298 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); |
| 298 | 299 |
| 299 // Now wait for the TCP sockets to connect. | 300 // Now wait for the TCP sockets to connect. |
| 300 base::MessageLoop::current()->RunUntilIdle(); | 301 base::RunLoop().RunUntilIdle(); |
| 301 | 302 |
| 302 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); | 303 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); |
| 303 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); | 304 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); |
| 304 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); | 305 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); |
| 305 EXPECT_EQ(2, pool_.IdleSocketCount()); | 306 EXPECT_EQ(2, pool_.IdleSocketCount()); |
| 306 | 307 |
| 307 (*requests())[0]->handle()->Reset(); | 308 (*requests())[0]->handle()->Reset(); |
| 308 (*requests())[1]->handle()->Reset(); | 309 (*requests())[1]->handle()->Reset(); |
| 309 } | 310 } |
| 310 | 311 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 326 rv = StartRequestV5("a", LOW); | 327 rv = StartRequestV5("a", LOW); |
| 327 EXPECT_EQ(ERR_IO_PENDING, rv); | 328 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 328 | 329 |
| 329 pool_.CancelRequest("a", (*requests())[0]->handle()); | 330 pool_.CancelRequest("a", (*requests())[0]->handle()); |
| 330 pool_.CancelRequest("a", (*requests())[1]->handle()); | 331 pool_.CancelRequest("a", (*requests())[1]->handle()); |
| 331 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); | 332 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); |
| 332 // Requests in the connect phase don't actually get cancelled. | 333 // Requests in the connect phase don't actually get cancelled. |
| 333 EXPECT_EQ(0, transport_socket_pool_.release_count()); | 334 EXPECT_EQ(0, transport_socket_pool_.release_count()); |
| 334 | 335 |
| 335 // Now wait for the async data to reach the SOCKS connect jobs. | 336 // Now wait for the async data to reach the SOCKS connect jobs. |
| 336 base::MessageLoop::current()->RunUntilIdle(); | 337 base::RunLoop().RunUntilIdle(); |
| 337 | 338 |
| 338 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); | 339 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); |
| 339 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); | 340 EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); |
| 340 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); | 341 EXPECT_EQ(0, transport_socket_pool_.cancel_count()); |
| 341 EXPECT_EQ(0, transport_socket_pool_.release_count()); | 342 EXPECT_EQ(0, transport_socket_pool_.release_count()); |
| 342 EXPECT_EQ(2, pool_.IdleSocketCount()); | 343 EXPECT_EQ(2, pool_.IdleSocketCount()); |
| 343 | 344 |
| 344 (*requests())[0]->handle()->Reset(); | 345 (*requests())[0]->handle()->Reset(); |
| 345 (*requests())[1]->handle()->Reset(); | 346 (*requests())[1]->handle()->Reset(); |
| 346 } | 347 } |
| 347 | 348 |
| 348 // It would be nice to also test the timeouts in SOCKSClientSocketPool. | 349 // It would be nice to also test the timeouts in SOCKSClientSocketPool. |
| 349 | 350 |
| 350 } // namespace | 351 } // namespace |
| 351 | 352 |
| 352 } // namespace net | 353 } // namespace net |
| OLD | NEW |