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/tcp_client_socket_pool.h" | 5 #include "net/socket/tcp_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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "net/base/mock_host_resolver.h" | 10 #include "net/base/mock_host_resolver.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 TCPClientSocketPoolTest() | 265 TCPClientSocketPoolTest() |
266 : ignored_socket_params_( | 266 : ignored_socket_params_( |
267 HostPortPair("ignored", 80), MEDIUM, GURL(), false), | 267 HostPortPair("ignored", 80), MEDIUM, GURL(), false), |
268 histograms_(new ClientSocketPoolHistograms("TCPUnitTest")), | 268 histograms_(new ClientSocketPoolHistograms("TCPUnitTest")), |
269 host_resolver_(new MockHostResolver), | 269 host_resolver_(new MockHostResolver), |
270 pool_(new TCPClientSocketPool(kMaxSockets, | 270 pool_(new TCPClientSocketPool(kMaxSockets, |
271 kMaxSocketsPerGroup, | 271 kMaxSocketsPerGroup, |
272 histograms_, | 272 histograms_, |
273 host_resolver_, | 273 host_resolver_, |
274 &client_socket_factory_, | 274 &client_socket_factory_, |
275 ¬ifier_)) { | 275 ¬ifier_, |
| 276 NULL)) { |
276 } | 277 } |
277 | 278 |
278 int StartRequest(const std::string& group_name, RequestPriority priority) { | 279 int StartRequest(const std::string& group_name, RequestPriority priority) { |
279 return StartRequestUsingPool( | 280 return StartRequestUsingPool( |
280 pool_, group_name, priority, ignored_socket_params_); | 281 pool_, group_name, priority, ignored_socket_params_); |
281 } | 282 } |
282 | 283 |
283 TCPSocketParams ignored_socket_params_; | 284 TCPSocketParams ignored_socket_params_; |
284 scoped_refptr<ClientSocketPoolHistograms> histograms_; | 285 scoped_refptr<ClientSocketPoolHistograms> histograms_; |
285 scoped_refptr<MockHostResolver> host_resolver_; | 286 scoped_refptr<MockHostResolver> host_resolver_; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 | 740 |
740 // One socket is stalled, the other is active. | 741 // One socket is stalled, the other is active. |
741 EXPECT_EQ(0, pool_->IdleSocketCount()); | 742 EXPECT_EQ(0, pool_->IdleSocketCount()); |
742 handle.Reset(); | 743 handle.Reset(); |
743 | 744 |
744 pool_ = new TCPClientSocketPool(kMaxSockets, | 745 pool_ = new TCPClientSocketPool(kMaxSockets, |
745 kMaxSocketsPerGroup, | 746 kMaxSocketsPerGroup, |
746 histograms_, | 747 histograms_, |
747 host_resolver_, | 748 host_resolver_, |
748 &client_socket_factory_, | 749 &client_socket_factory_, |
| 750 NULL, |
749 NULL); | 751 NULL); |
750 } | 752 } |
751 } | 753 } |
752 | 754 |
753 // Test the case where a socket took long enough to start the creation | 755 // Test the case where a socket took long enough to start the creation |
754 // of the backup socket, but then we cancelled the request after that. | 756 // of the backup socket, but then we cancelled the request after that. |
755 TEST_F(TCPClientSocketPoolTest, BackupSocketCancel) { | 757 TEST_F(TCPClientSocketPoolTest, BackupSocketCancel) { |
756 client_socket_factory_.set_client_socket_type( | 758 client_socket_factory_.set_client_socket_type( |
757 MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET); | 759 MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET); |
758 | 760 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 EXPECT_FALSE(handle.socket()); | 880 EXPECT_FALSE(handle.socket()); |
879 handle.Reset(); | 881 handle.Reset(); |
880 | 882 |
881 // Reset for the next case. | 883 // Reset for the next case. |
882 host_resolver_->set_synchronous_mode(false); | 884 host_resolver_->set_synchronous_mode(false); |
883 } | 885 } |
884 | 886 |
885 } // namespace | 887 } // namespace |
886 | 888 |
887 } // namespace net | 889 } // namespace net |
OLD | NEW |