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 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
1414 MessageLoop::current()); | |
1415 MessageLoop::current()->RunAllPending(); | 1414 MessageLoop::current()->RunAllPending(); |
1416 } | 1415 } |
1417 within_callback_ = true; | 1416 within_callback_ = true; |
jar (doing other things)
2012/02/11 03:24:38
This is a *little* scary. The names (and pattern
dhollowa
2012/02/13 17:44:26
I've added willchan@ to the CC list.
willchan no longer on Chromium
2012/02/14 01:43:42
I've looked at it and it's minorly scary as jar@ s
dhollowa
2012/02/14 03:19:49
Done.
| |
1418 TestCompletionCallback next_job_callback; | 1417 TestCompletionCallback next_job_callback; |
1419 scoped_refptr<TestSocketParams> params(new TestSocketParams()); | 1418 scoped_refptr<TestSocketParams> params(new TestSocketParams()); |
1420 int rv = handle_->Init("a", | 1419 int rv = handle_->Init("a", |
1421 params, | 1420 params, |
1422 kDefaultPriority, | 1421 kDefaultPriority, |
1423 next_job_callback.callback(), | 1422 next_job_callback.callback(), |
1424 pool_, | 1423 pool_, |
1425 BoundNetLog()); | 1424 BoundNetLog()); |
1426 switch (next_job_type_) { | 1425 switch (next_job_type_) { |
1427 case TestConnectJob::kMockJob: | 1426 case TestConnectJob::kMockJob: |
1428 EXPECT_EQ(OK, rv); | 1427 EXPECT_EQ(OK, rv); |
1429 break; | 1428 break; |
1430 case TestConnectJob::kMockPendingJob: | 1429 case TestConnectJob::kMockPendingJob: |
1431 EXPECT_EQ(ERR_IO_PENDING, rv); | 1430 EXPECT_EQ(ERR_IO_PENDING, rv); |
1432 | 1431 |
1433 // For pending jobs, wait for new socket to be created. This makes | 1432 // For pending jobs, wait for new socket to be created. This makes |
1434 // sure there are no more pending operations nor any unclosed sockets | 1433 // sure there are no more pending operations nor any unclosed sockets |
1435 // when the test finishes. | 1434 // when the test finishes. |
1436 // We need to give it a little bit of time to run, so that all the | 1435 // 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 | 1436 // operations that happen on timers (e.g. cleanup of idle |
1438 // connections) can execute. | 1437 // connections) can execute. |
1439 { | 1438 { |
1440 MessageLoop::ScopedNestableTaskAllower nestable( | 1439 MessageLoop::ScopedNestableTaskAllower allow( |
1441 MessageLoop::current()); | 1440 MessageLoop::current()); |
1442 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); | 1441 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
jar (doing other things)
2012/02/11 03:24:38
This doesn't make sense to me. All we're doing is
jar (doing other things)
2012/02/14 01:51:43
What about removing this allow call??
On 2012/02/
willchan no longer on Chromium
2012/02/14 01:54:10
Jim's suggestion sounds correct to me here, we can
dhollowa
2012/02/14 03:19:49
Done.
dhollowa
2012/02/14 16:35:50
I had to restore the ScopedNestableTaskAllower bec
| |
1443 EXPECT_EQ(OK, next_job_callback.WaitForResult()); | 1442 EXPECT_EQ(OK, next_job_callback.WaitForResult()); |
1444 } | 1443 } |
1445 break; | 1444 break; |
1446 default: | 1445 default: |
1447 FAIL() << "Unexpected job type: " << next_job_type_; | 1446 FAIL() << "Unexpected job type: " << next_job_type_; |
1448 break; | 1447 break; |
1449 } | 1448 } |
1450 } | 1449 } |
1451 } | 1450 } |
1452 | 1451 |
(...skipping 1906 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 | 3358 // The hung connect job should still be there, but everything else should be |
3360 // complete. | 3359 // complete. |
3361 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 3360 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
3362 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); | 3361 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); |
3363 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); | 3362 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); |
3364 } | 3363 } |
3365 | 3364 |
3366 } // namespace | 3365 } // namespace |
3367 | 3366 |
3368 } // namespace net | 3367 } // namespace net |
OLD | NEW |