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

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

Issue 1808001: Implement a 15 connection per proxy server limit. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Remove extra newline. Created 10 years, 7 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 (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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 private: 249 private:
250 int allocation_count_; 250 int allocation_count_;
251 ClientSocketType client_socket_type_; 251 ClientSocketType client_socket_type_;
252 ClientSocketType* client_socket_types_; 252 ClientSocketType* client_socket_types_;
253 int client_socket_index_; 253 int client_socket_index_;
254 }; 254 };
255 255
256 class TCPClientSocketPoolTest : public ClientSocketPoolTest { 256 class TCPClientSocketPoolTest : public ClientSocketPoolTest {
257 protected: 257 protected:
258 TCPClientSocketPoolTest() 258 TCPClientSocketPoolTest()
259 : ignored_socket_params_("ignored", 80, MEDIUM, GURL(), false), 259 : ignored_socket_params_(
260 HostPortPair("ignored", 80), MEDIUM, GURL(), false),
260 host_resolver_(new MockHostResolver), 261 host_resolver_(new MockHostResolver),
261 pool_(new TCPClientSocketPool(kMaxSockets, 262 pool_(new TCPClientSocketPool(kMaxSockets,
262 kMaxSocketsPerGroup, 263 kMaxSocketsPerGroup,
263 "TCPUnitTest", 264 "TCPUnitTest",
264 host_resolver_, 265 host_resolver_,
265 &client_socket_factory_, 266 &client_socket_factory_,
266 &notifier_)) { 267 &notifier_)) {
267 } 268 }
268 269
269 int StartRequest(const std::string& group_name, RequestPriority priority) { 270 int StartRequest(const std::string& group_name, RequestPriority priority) {
270 return StartRequestUsingPool( 271 return StartRequestUsingPool(
271 pool_, group_name, priority, ignored_socket_params_); 272 pool_, group_name, priority, ignored_socket_params_);
272 } 273 }
273 274
274 TCPSocketParams ignored_socket_params_; 275 TCPSocketParams ignored_socket_params_;
275 scoped_refptr<MockHostResolver> host_resolver_; 276 scoped_refptr<MockHostResolver> host_resolver_;
276 MockClientSocketFactory client_socket_factory_; 277 MockClientSocketFactory client_socket_factory_;
277 MockNetworkChangeNotifier notifier_; 278 MockNetworkChangeNotifier notifier_;
278 scoped_refptr<TCPClientSocketPool> pool_; 279 scoped_refptr<TCPClientSocketPool> pool_;
279 }; 280 };
280 281
281 TEST_F(TCPClientSocketPoolTest, Basic) { 282 TEST_F(TCPClientSocketPoolTest, Basic) {
282 TestCompletionCallback callback; 283 TestCompletionCallback callback;
283 ClientSocketHandle handle; 284 ClientSocketHandle handle;
284 TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false); 285 TCPSocketParams dest(HostPortPair("www.google.com", 80), LOW, GURL(), false);
285 int rv = handle.Init("a", dest, LOW, &callback, pool_, BoundNetLog()); 286 int rv = handle.Init("a", dest, LOW, &callback, pool_, BoundNetLog());
286 EXPECT_EQ(ERR_IO_PENDING, rv); 287 EXPECT_EQ(ERR_IO_PENDING, rv);
287 EXPECT_FALSE(handle.is_initialized()); 288 EXPECT_FALSE(handle.is_initialized());
288 EXPECT_FALSE(handle.socket()); 289 EXPECT_FALSE(handle.socket());
289 290
290 EXPECT_EQ(OK, callback.WaitForResult()); 291 EXPECT_EQ(OK, callback.WaitForResult());
291 EXPECT_TRUE(handle.is_initialized()); 292 EXPECT_TRUE(handle.is_initialized());
292 EXPECT_TRUE(handle.socket()); 293 EXPECT_TRUE(handle.socket());
293 294
294 handle.Reset(); 295 handle.Reset();
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 EXPECT_FALSE(handle.socket()); 862 EXPECT_FALSE(handle.socket());
862 handle.Reset(); 863 handle.Reset();
863 864
864 // Reset for the next case. 865 // Reset for the next case.
865 host_resolver_->set_synchronous_mode(false); 866 host_resolver_->set_synchronous_mode(false);
866 } 867 }
867 868
868 } // namespace 869 } // namespace
869 870
870 } // namespace net 871 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698