| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/client_socket_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_thread.h" | 10 #include "base/platform_thread.h" |
| 11 #include "base/scoped_vector.h" | 11 #include "base/scoped_vector.h" |
| 12 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" |
| 13 #include "net/base/net_log_unittest.h" | 13 #include "net/base/net_log_unittest.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/request_priority.h" | 15 #include "net/base/request_priority.h" |
| 16 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
| 17 #include "net/socket/client_socket.h" | 17 #include "net/socket/client_socket.h" |
| 18 #include "net/socket/client_socket_factory.h" | 18 #include "net/socket/client_socket_factory.h" |
| 19 #include "net/socket/client_socket_handle.h" | 19 #include "net/socket/client_socket_handle.h" |
| 20 #include "net/socket/socket_test_util.h" | 20 #include "net/socket/socket_test_util.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const int kDefaultMaxSockets = 4; | 27 const int kDefaultMaxSockets = 4; |
| 28 const int kDefaultMaxSocketsPerGroup = 2; | 28 const int kDefaultMaxSocketsPerGroup = 2; |
| 29 const RequestPriority kDefaultPriority = MEDIUM; | 29 const net::RequestPriority kDefaultPriority = MEDIUM; |
| 30 | 30 |
| 31 typedef const void* TestSocketParams; | 31 typedef const void* TestSocketParams; |
| 32 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase; | 32 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase; |
| 33 | 33 |
| 34 class MockClientSocket : public ClientSocket { | 34 class MockClientSocket : public ClientSocket { |
| 35 public: | 35 public: |
| 36 MockClientSocket() : connected_(false) {} | 36 MockClientSocket() : connected_(false) {} |
| 37 | 37 |
| 38 // Socket methods: | 38 // Socket methods: |
| 39 virtual int Read( | 39 virtual int Read( |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 public: | 281 public: |
| 282 TestClientSocketPool( | 282 TestClientSocketPool( |
| 283 int max_sockets, | 283 int max_sockets, |
| 284 int max_sockets_per_group, | 284 int max_sockets_per_group, |
| 285 const std::string& name, | 285 const std::string& name, |
| 286 base::TimeDelta unused_idle_socket_timeout, | 286 base::TimeDelta unused_idle_socket_timeout, |
| 287 base::TimeDelta used_idle_socket_timeout, | 287 base::TimeDelta used_idle_socket_timeout, |
| 288 TestClientSocketPoolBase::ConnectJobFactory* connect_job_factory) | 288 TestClientSocketPoolBase::ConnectJobFactory* connect_job_factory) |
| 289 : base_(max_sockets, max_sockets_per_group, name, | 289 : base_(max_sockets, max_sockets_per_group, name, |
| 290 unused_idle_socket_timeout, used_idle_socket_timeout, | 290 unused_idle_socket_timeout, used_idle_socket_timeout, |
| 291 connect_job_factory) {} | 291 connect_job_factory, NULL) {} |
| 292 | 292 |
| 293 virtual int RequestSocket( | 293 virtual int RequestSocket( |
| 294 const std::string& group_name, | 294 const std::string& group_name, |
| 295 const void* params, | 295 const void* params, |
| 296 net::RequestPriority priority, | 296 net::RequestPriority priority, |
| 297 ClientSocketHandle* handle, | 297 ClientSocketHandle* handle, |
| 298 CompletionCallback* callback, | 298 CompletionCallback* callback, |
| 299 const BoundNetLog& net_log) { | 299 const BoundNetLog& net_log) { |
| 300 return base_.RequestSocket( | 300 return base_.RequestSocket( |
| 301 group_name, params, priority, handle, callback, net_log); | 301 group_name, params, priority, handle, callback, net_log); |
| (...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 TestReleasingSocketRequest request(pool_.get()); | 1623 TestReleasingSocketRequest request(pool_.get()); |
| 1624 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority, | 1624 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority, |
| 1625 &request, pool_, BoundNetLog())); | 1625 &request, pool_, BoundNetLog())); |
| 1626 | 1626 |
| 1627 EXPECT_EQ(OK, request.WaitForResult()); | 1627 EXPECT_EQ(OK, request.WaitForResult()); |
| 1628 } | 1628 } |
| 1629 | 1629 |
| 1630 } // namespace | 1630 } // namespace |
| 1631 | 1631 |
| 1632 } // namespace net | 1632 } // namespace net |
| OLD | NEW |