OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 ASSERT_EQ(OK, result); | 1403 ASSERT_EQ(OK, result); |
1404 | 1404 |
1405 if (!within_callback_) { | 1405 if (!within_callback_) { |
1406 test_connect_job_factory_->set_job_type(next_job_type_); | 1406 test_connect_job_factory_->set_job_type(next_job_type_); |
1407 | 1407 |
1408 // Don't allow reuse of the socket. Disconnect it and then release it and | 1408 // Don't allow reuse of the socket. Disconnect it and then release it and |
1409 // run through the MessageLoop once to get it completely released. | 1409 // run through the MessageLoop once to get it completely released. |
1410 handle_->socket()->Disconnect(); | 1410 handle_->socket()->Disconnect(); |
1411 handle_->Reset(); | 1411 handle_->Reset(); |
1412 { | 1412 { |
1413 MessageLoop::ScopedNestableTaskAllower nestable( | 1413 // TODO: Resolve conflicting intentions of stopping recursion with the |
1414 MessageLoop::current()); | 1414 // |!within_callback_| test (above) and the call to |RunAllPending()| |
| 1415 // below. http://crbug.com/114130. |
| 1416 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
1415 MessageLoop::current()->RunAllPending(); | 1417 MessageLoop::current()->RunAllPending(); |
1416 } | 1418 } |
1417 within_callback_ = true; | 1419 within_callback_ = true; |
1418 TestCompletionCallback next_job_callback; | 1420 TestCompletionCallback next_job_callback; |
1419 scoped_refptr<TestSocketParams> params(new TestSocketParams()); | 1421 scoped_refptr<TestSocketParams> params(new TestSocketParams()); |
1420 int rv = handle_->Init("a", | 1422 int rv = handle_->Init("a", |
1421 params, | 1423 params, |
1422 kDefaultPriority, | 1424 kDefaultPriority, |
1423 next_job_callback.callback(), | 1425 next_job_callback.callback(), |
1424 pool_, | 1426 pool_, |
1425 BoundNetLog()); | 1427 BoundNetLog()); |
1426 switch (next_job_type_) { | 1428 switch (next_job_type_) { |
1427 case TestConnectJob::kMockJob: | 1429 case TestConnectJob::kMockJob: |
1428 EXPECT_EQ(OK, rv); | 1430 EXPECT_EQ(OK, rv); |
1429 break; | 1431 break; |
1430 case TestConnectJob::kMockPendingJob: | 1432 case TestConnectJob::kMockPendingJob: |
1431 EXPECT_EQ(ERR_IO_PENDING, rv); | 1433 EXPECT_EQ(ERR_IO_PENDING, rv); |
1432 | 1434 |
1433 // For pending jobs, wait for new socket to be created. This makes | 1435 // For pending jobs, wait for new socket to be created. This makes |
1434 // sure there are no more pending operations nor any unclosed sockets | 1436 // sure there are no more pending operations nor any unclosed sockets |
1435 // when the test finishes. | 1437 // when the test finishes. |
1436 // We need to give it a little bit of time to run, so that all the | 1438 // We need to give it a little bit of time to run, so that all the |
1437 // operations that happen on timers (e.g. cleanup of idle | 1439 // operations that happen on timers (e.g. cleanup of idle |
1438 // connections) can execute. | 1440 // connections) can execute. |
1439 { | 1441 { |
1440 MessageLoop::ScopedNestableTaskAllower nestable( | 1442 MessageLoop::ScopedNestableTaskAllower allow( |
1441 MessageLoop::current()); | 1443 MessageLoop::current()); |
1442 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); | 1444 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
1443 EXPECT_EQ(OK, next_job_callback.WaitForResult()); | 1445 EXPECT_EQ(OK, next_job_callback.WaitForResult()); |
1444 } | 1446 } |
1445 break; | 1447 break; |
1446 default: | 1448 default: |
1447 FAIL() << "Unexpected job type: " << next_job_type_; | 1449 FAIL() << "Unexpected job type: " << next_job_type_; |
1448 break; | 1450 break; |
1449 } | 1451 } |
1450 } | 1452 } |
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3359 // The hung connect job should still be there, but everything else should be | 3361 // The hung connect job should still be there, but everything else should be |
3360 // complete. | 3362 // complete. |
3361 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 3363 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
3362 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); | 3364 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); |
3363 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); | 3365 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); |
3364 } | 3366 } |
3365 | 3367 |
3366 } // namespace | 3368 } // namespace |
3367 | 3369 |
3368 } // namespace net | 3370 } // namespace net |
OLD | NEW |