summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 01:13:20 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 01:13:20 +0000
commit26f34dd42f1af46a4c68e9082290c359706685db (patch)
tree63891e5d7594b26a0b5b599618b560e154633e18 /net/socket
parenteb6d7019c477673c57f1fbde224d5b8ae8919019 (diff)
downloadchromium_src-26f34dd42f1af46a4c68e9082290c359706685db.zip
chromium_src-26f34dd42f1af46a4c68e9082290c359706685db.tar.gz
chromium_src-26f34dd42f1af46a4c68e9082290c359706685db.tar.bz2
Roll back Markus's CL ( http://codereview.chromium.org/196053)
BUG=none TEST=UI test and valgrind test pass TBR=markus Review URL: http://codereview.chromium.org/222031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc39
-rw-r--r--net/socket/socket_test_util.cc9
2 files changed, 11 insertions, 37 deletions
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index c0a04aa..249d7e3 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -143,34 +143,31 @@ class TestConnectJob : public ConnectJob {
return DoConnect(false /* error */, false /* sync */);
case kMockPendingJob:
set_load_state(LOAD_STATE_CONNECTING);
- MessageLoop::current()->PostDelayedTask(
+ MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &TestConnectJob::DoConnect,
- true /* successful */,
- true /* async */),
- 2);
+ &TestConnectJob::DoConnect,
+ true /* successful */,
+ true /* async */));
return ERR_IO_PENDING;
case kMockPendingFailingJob:
set_load_state(LOAD_STATE_CONNECTING);
- MessageLoop::current()->PostDelayedTask(
+ MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &TestConnectJob::DoConnect,
- false /* error */,
- true /* async */),
- 2);
+ &TestConnectJob::DoConnect,
+ false /* error */,
+ true /* async */));
return ERR_IO_PENDING;
case kMockWaitingJob:
client_socket_factory_->WaitForSignal(this);
waiting_success_ = true;
return ERR_IO_PENDING;
case kMockAdvancingLoadStateJob:
- MessageLoop::current()->PostDelayedTask(
+ MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &TestConnectJob::AdvanceLoadState, load_state_),
- 2);
+ &TestConnectJob::AdvanceLoadState, load_state_));
return ERR_IO_PENDING;
default:
NOTREACHED();
@@ -720,8 +717,6 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitCountsConnectingSockets) {
// Create one asynchronous request.
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
EXPECT_EQ(ERR_IO_PENDING, StartRequest("d", kDefaultPriority));
- PlatformThread::Sleep(10);
- MessageLoop::current()->RunAllPending();
// The next synchronous request should wait for its turn.
connect_job_factory_->set_job_type(TestConnectJob::kMockJob);
@@ -958,26 +953,14 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
test_connect_job_factory_->set_job_type(next_job_type_);
handle_->Reset();
within_callback_ = true;
- TestCompletionCallback next_job_callback;
int rv = InitHandle(
- handle_, "a", kDefaultPriority, &next_job_callback, pool_.get(),
- NULL);
+ handle_, "a", kDefaultPriority, this, pool_.get(), NULL);
switch (next_job_type_) {
case TestConnectJob::kMockJob:
EXPECT_EQ(OK, rv);
break;
case TestConnectJob::kMockPendingJob:
EXPECT_EQ(ERR_IO_PENDING, rv);
-
- // For pending jobs, wait for new socket to be created. This makes
- // sure there are no more pending operations nor any unclosed sockets
- // when the test finishes.
- // We need to give it a little bit of time to run, so that all the
- // operations that happen on timers (e.g. cleanup of idle
- // connections) can execute.
- MessageLoop::current()->SetNestableTasksAllowed(true);
- PlatformThread::Sleep(10);
- EXPECT_EQ(OK, next_job_callback.WaitForResult());
break;
default:
FAIL() << "Unexpected job type: " << next_job_type_;
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 7f4af08..cd4423b 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -343,15 +343,6 @@ void ClientSocketPoolTest::SetUp() {
void ClientSocketPoolTest::TearDown() {
// The tests often call Reset() on handles at the end which may post
// DoReleaseSocket() tasks.
- // Pending tasks created by client_socket_pool_base_unittest.cc are
- // posted two milliseconds into the future and thus won't become
- // scheduled until that time.
- // We wait a few milliseconds to make sure that all such future tasks
- // are ready to run, before calling RunAllPending(). This will work
- // correctly even if Sleep() finishes late (and it should never finish
- // early), as all we have to ensure is that actual wall-time has progressed
- // past the scheduled starting time of the pending task.
- PlatformThread::Sleep(10);
MessageLoop::current()->RunAllPending();
}