OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
10 #include "base/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
11 #include "net/base/load_log.h" | 11 #include "net/base/load_log.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 class TestConnectJobDelegate : public ConnectJob::Delegate { | 334 class TestConnectJobDelegate : public ConnectJob::Delegate { |
335 public: | 335 public: |
336 TestConnectJobDelegate() | 336 TestConnectJobDelegate() |
337 : have_result_(false), waiting_for_result_(false), result_(OK) {} | 337 : have_result_(false), waiting_for_result_(false), result_(OK) {} |
338 virtual ~TestConnectJobDelegate() {} | 338 virtual ~TestConnectJobDelegate() {} |
339 | 339 |
340 virtual void OnConnectJobComplete(int result, ConnectJob* job) { | 340 virtual void OnConnectJobComplete(int result, ConnectJob* job) { |
341 result_ = result; | 341 result_ = result; |
342 scoped_ptr<ClientSocket> socket(job->ReleaseSocket()); | 342 scoped_ptr<ClientSocket> socket(job->ReleaseSocket()); |
343 if (result == OK) { | 343 // socket.get() should be NULL iff result != OK |
344 EXPECT_TRUE(socket.get() != NULL); | 344 EXPECT_EQ(socket.get() == NULL, result != OK); |
345 } else { | |
346 EXPECT_EQ(NULL, socket.get()); | |
347 } | |
348 delete job; | 345 delete job; |
349 have_result_ = true; | 346 have_result_ = true; |
350 if (waiting_for_result_) | 347 if (waiting_for_result_) |
351 MessageLoop::current()->Quit(); | 348 MessageLoop::current()->Quit(); |
352 } | 349 } |
353 | 350 |
354 int WaitForResult() { | 351 int WaitForResult() { |
355 DCHECK(!waiting_for_result_); | 352 DCHECK(!waiting_for_result_); |
356 while (!have_result_) { | 353 while (!have_result_) { |
357 waiting_for_result_ = true; | 354 waiting_for_result_ = true; |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 | 1821 |
1825 pool_->CleanupTimedOutIdleSockets(); | 1822 pool_->CleanupTimedOutIdleSockets(); |
1826 rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL); | 1823 rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL); |
1827 EXPECT_EQ(OK, rv); | 1824 EXPECT_EQ(OK, rv); |
1828 EXPECT_TRUE(req.handle()->is_reused()); | 1825 EXPECT_TRUE(req.handle()->is_reused()); |
1829 } | 1826 } |
1830 | 1827 |
1831 } // namespace | 1828 } // namespace |
1832 | 1829 |
1833 } // namespace net | 1830 } // namespace net |
OLD | NEW |