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

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

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get compiling on mac Created 11 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/tcp_client_socket_pool.h" 5 #include "net/base/tcp_client_socket_pool.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "net/base/client_socket.h" 8 #include "net/base/client_socket.h"
9 #include "net/base/client_socket_factory.h" 9 #include "net/base/client_socket_factory.h"
10 #include "net/base/client_socket_handle.h" 10 #include "net/base/client_socket_handle.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 private: 191 private:
192 std::vector<TestSocketRequest*>* request_order_; 192 std::vector<TestSocketRequest*>* request_order_;
193 TestCompletionCallback callback_; 193 TestCompletionCallback callback_;
194 }; 194 };
195 195
196 int TestSocketRequest::completion_count = 0; 196 int TestSocketRequest::completion_count = 0;
197 197
198 class TCPClientSocketPoolTest : public testing::Test { 198 class TCPClientSocketPoolTest : public testing::Test {
199 protected: 199 protected:
200 TCPClientSocketPoolTest() 200 TCPClientSocketPoolTest()
201 : pool_(new TCPClientSocketPool(kMaxSocketsPerGroup, 201 // We disable caching here since these unit tests don't expect
202 // host resolving to be able to complete synchronously.
203 // TODO(eroman): enable caching.
204 : host_resolver_(0, 0),
205 pool_(new TCPClientSocketPool(kMaxSocketsPerGroup,
206 &host_resolver_,
202 &client_socket_factory_)) {} 207 &client_socket_factory_)) {}
203 208
204 virtual void SetUp() { 209 virtual void SetUp() {
205 TestSocketRequest::completion_count = 0; 210 TestSocketRequest::completion_count = 0;
206 } 211 }
207 212
213 HostResolver host_resolver_;
208 MockClientSocketFactory client_socket_factory_; 214 MockClientSocketFactory client_socket_factory_;
209 scoped_refptr<ClientSocketPool> pool_; 215 scoped_refptr<ClientSocketPool> pool_;
210 std::vector<TestSocketRequest*> request_order_; 216 std::vector<TestSocketRequest*> request_order_;
211 }; 217 };
212 218
213 TEST_F(TCPClientSocketPoolTest, Basic) { 219 TEST_F(TCPClientSocketPoolTest, Basic) {
214 TestCompletionCallback callback; 220 TestCompletionCallback callback;
215 ClientSocketHandle handle(pool_.get()); 221 ClientSocketHandle handle(pool_.get());
216 int rv = handle.Init("a", "www.google.com", 80, 0, &callback); 222 int rv = handle.Init("a", "www.google.com", 80, 0, &callback);
217 EXPECT_EQ(ERR_IO_PENDING, rv); 223 EXPECT_EQ(ERR_IO_PENDING, rv);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 478
473 EXPECT_EQ(request_order_[arraysize(reqs) - 2], 479 EXPECT_EQ(request_order_[arraysize(reqs) - 2],
474 reqs[arraysize(reqs) - 1].get()) << 480 reqs[arraysize(reqs) - 1].get()) <<
475 "The last request with priority 1 should not have been inserted " 481 "The last request with priority 1 should not have been inserted "
476 "earlier into the queue."; 482 "earlier into the queue.";
477 } 483 }
478 484
479 } // namespace 485 } // namespace
480 486
481 } // namespace net 487 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698