Skip to content

Commit

Permalink
net: Update calls from RunAllPending() to RunUntilIdle().
Browse files Browse the repository at this point in the history
RunAllPending() is deprecated and we should switch to RunUntilIdle().

BUG=131220
TBR=willchan@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11361263

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167705 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Nov 14, 2012
1 parent 90bb38d commit b4c62eb
Show file tree
Hide file tree
Showing 54 changed files with 312 additions and 312 deletions.
6 changes: 3 additions & 3 deletions net/android/network_change_notifier_android_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ TEST_F(NetworkChangeNotifierAndroidTest, ObserverNotified) {
observer()->current_connection());

ForceConnectivityState(false);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(1, observer()->times_connection_type_has_been_changed());
EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE,
observer()->current_connection());

ForceConnectivityState(false);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(1, observer()->times_connection_type_has_been_changed());
EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE,
observer()->current_connection());

ForceConnectivityState(true);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(2, observer()->times_connection_type_has_been_changed());
EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN,
Expand Down
2 changes: 1 addition & 1 deletion net/base/directory_lister_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ TEST(DirectoryListerTest, CancelTest) {

lister.Cancel();

MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(num_files, delegate.num_files());
}
Expand Down
4 changes: 2 additions & 2 deletions net/base/file_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ TEST_F(FileStreamTest, AsyncRead_EarlyDelete) {
if (rv < 0) {
EXPECT_EQ(ERR_IO_PENDING, rv);
// The callback should not be called if the request is cancelled.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(callback.have_result());
} else {
EXPECT_EQ(std::string(kTestData, rv), std::string(buf->data(), rv));
Expand Down Expand Up @@ -458,7 +458,7 @@ TEST_F(FileStreamTest, AsyncWrite_EarlyDelete) {
if (rv < 0) {
EXPECT_EQ(ERR_IO_PENDING, rv);
// The callback should not be called if the request is cancelled.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(callback.have_result());
} else {
ok = file_util::GetFileSize(temp_file_path(), &file_size);
Expand Down
12 changes: 6 additions & 6 deletions net/base/host_resolver_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) {

// Flush cache by triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
MessageLoop::current()->RunAllPending(); // Notification happens async.
MessageLoop::current()->RunUntilIdle(); // Notification happens async.

// Resolve "host1" again -- this time it won't be served from cache, so it
// will complete asynchronously.
Expand All @@ -840,7 +840,7 @@ TEST_F(HostResolverImplTest, AbortOnIPAddressChanged) {
EXPECT_TRUE(proc_->WaitFor(1u));
// Triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
MessageLoop::current()->RunAllPending(); // Notification happens async.
MessageLoop::current()->RunUntilIdle(); // Notification happens async.
proc_->SignalAll();

EXPECT_EQ(ERR_ABORTED, req->WaitForResult());
Expand All @@ -858,7 +858,7 @@ TEST_F(HostResolverImplTest, ObeyPoolConstraintsAfterIPAddressChange) {
EXPECT_TRUE(proc_->WaitFor(1u));
// Triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
MessageLoop::current()->RunAllPending(); // Notification happens async.
MessageLoop::current()->RunUntilIdle(); // Notification happens async.
proc_->SignalMultiple(3u); // Let the false-start go so that we can catch it.

EXPECT_EQ(ERR_ABORTED, requests_[0]->WaitForResult());
Expand Down Expand Up @@ -902,7 +902,7 @@ TEST_F(HostResolverImplTest, AbortOnlyExistingRequestsOnIPAddressChange) {
// Trigger an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
// This should abort all running jobs.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(ERR_ABORTED, requests_[0]->result());
EXPECT_EQ(ERR_ABORTED, requests_[1]->result());
EXPECT_EQ(ERR_ABORTED, requests_[2]->result());
Expand Down Expand Up @@ -1211,7 +1211,7 @@ TEST_F(HostResolverImplTest, MultipleAttempts) {

resolver_proc->WaitForAllAttemptsToFinish(
base::TimeDelta::FromMilliseconds(60000));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts);
EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve);
Expand Down Expand Up @@ -1266,7 +1266,7 @@ class HostResolverImplDnsTest : public HostResolverImplTest {
void ChangeDnsConfig(const DnsConfig& config) {
NetworkChangeNotifier::SetDnsConfig(config);
// Notification is delivered asynchronously.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

MockDnsClientRuleList dns_rules_;
Expand Down
2 changes: 1 addition & 1 deletion net/base/network_change_notifier_linux_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class NetworkChangeNotifierLinuxTest : public testing::Test {
event.Wait();
// Run any tasks queued on the main thread, e.g. by
// ObserverListThreadSafe.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

void SendResponse(uint32 state) {
Expand Down
10 changes: 5 additions & 5 deletions net/base/network_change_notifier_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {

// If a task to notify observers of the IP address change event was
// incorrectly posted, make sure it gets run to trigger a failure.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal
Expand All @@ -112,7 +112,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {

// If a task to notify observers of the IP address change event was
// incorrectly posted, make sure it gets run.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Simulates a network change event, resulting in a call to OnObjectSignaled.
Expand All @@ -132,7 +132,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
EXPECT_EQ(0, network_change_notifier_.sequential_failures());

// Run the task to notify observers of the IP address change event.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Simulates a network change event, resulting in a call to OnObjectSignaled.
Expand All @@ -154,7 +154,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
EXPECT_LT(0, network_change_notifier_.sequential_failures());

// Run the task to notify observers of the IP address change event.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Runs the message loop until WatchForAddressChange is called again, as a
Expand Down Expand Up @@ -204,7 +204,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {

// If a task to notify observers of the IP address change event was
// incorrectly posted, make sure it gets run.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

private:
Expand Down
2 changes: 1 addition & 1 deletion net/base/nss_cert_database_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CertDatabaseNSSTest : public testing::Test {
// Run the message loop to process any observer callbacks (e.g. for the
// ClientSocketFactory singleton) so that the scoped ref ptrs created in
// NSSCertDatabase::NotifyObservers* get released.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

EXPECT_EQ(0U, ListCertsInSlot(slot_->os_module_handle()).size());
}
Expand Down
4 changes: 2 additions & 2 deletions net/base/server_bound_cert_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ TEST_F(ServerBoundCertServiceTest, CancelRequest) {
sequenced_worker_pool_->FlushForTesting();
// Wait for reply from ServerBoundCertServiceWorker to be posted back to the
// ServerBoundCertService.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

// Even though the original request was cancelled, the service will still
// store the result, it just doesn't call the callback.
Expand Down Expand Up @@ -381,7 +381,7 @@ TEST_F(ServerBoundCertServiceTest, DestructionWithPendingRequest) {
// ServerBoundCertServiceWorker should not post anything back to the
// non-existant ServerBoundCertService, but run the loop just to be sure it
// doesn't.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

// If we got here without crashing or a valgrind error, it worked.
}
Expand Down
14 changes: 7 additions & 7 deletions net/base/upload_data_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ TEST_F(UploadDataStreamTest, InitAsync) {
MockCompletionCallback mock_callback;
EXPECT_CALL(mock_callback, Run(OK)).Times(1);
EXPECT_EQ(stream.Init(mock_callback.CreateCallback()), ERR_IO_PENDING);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Init() of a reader fails asynchronously.
Expand All @@ -329,7 +329,7 @@ TEST_F(UploadDataStreamTest, InitAsyncFailureAsync) {
MockCompletionCallback mock_callback;
EXPECT_CALL(mock_callback, Run(ERR_FAILED)).Times(1);
EXPECT_EQ(stream.Init(mock_callback.CreateCallback()), ERR_IO_PENDING);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Init() of a reader fails synchronously.
Expand All @@ -352,7 +352,7 @@ TEST_F(UploadDataStreamTest, InitAsyncFailureSync) {
MockCompletionCallback mock_callback;
EXPECT_CALL(mock_callback, Run(ERR_FAILED)).Times(1);
EXPECT_EQ(stream.Init(mock_callback.CreateCallback()), ERR_IO_PENDING);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Read with a buffer whose size is same as the data.
Expand Down Expand Up @@ -408,27 +408,27 @@ TEST_F(UploadDataStreamTest, ReadAsync) {
MockCompletionCallback mock_callback;
EXPECT_CALL(mock_callback, Run(OK)).Times(1);
EXPECT_EQ(ERR_IO_PENDING, stream.Init(mock_callback.CreateCallback()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

scoped_refptr<IOBuffer> buf = new IOBuffer(kTestBufferSize);

// Consume the first element.
EXPECT_CALL(mock_callback, Run(kTestDataSize)).Times(0);
EXPECT_EQ(static_cast<int>(kTestDataSize),
stream.Read(buf, kTestDataSize, mock_callback.CreateCallback()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

// Consume the second element.
EXPECT_CALL(mock_callback, Run(kTestDataSize)).Times(1);
EXPECT_EQ(ERR_IO_PENDING,
stream.Read(buf, kTestDataSize, mock_callback.CreateCallback()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

// Consume the third and the fourth elements.
EXPECT_CALL(mock_callback, Run(kTestDataSize*2)).Times(1);
EXPECT_EQ(ERR_IO_PENDING,
stream.Read(buf, kTestDataSize*2, mock_callback.CreateCallback()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

void UploadDataStreamTest::FileChangedHelper(const FilePath& file_path,
Expand Down
6 changes: 3 additions & 3 deletions net/cookies/cookie_monster_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BaseCallback {
// Therefore, callbacks will actually always complete synchronously. If the
// tests get more advanced we need to add other means of signaling
// completion.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(has_run_);
has_run_ = false;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ TEST_F(CookieMonsterTest, TestAddCookiesOnSingleHost) {

PerfTimeLogger timer3("Cookie_monster_deleteall_single_host");
cm->DeleteAllAsync(CookieMonster::DeleteCallback());
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
timer3.Done();
}

Expand Down Expand Up @@ -197,7 +197,7 @@ TEST_F(CookieMonsterTest, TestAddCookieOnManyHosts) {

PerfTimeLogger timer3("Cookie_monster_deleteall_many_hosts");
cm->DeleteAllAsync(CookieMonster::DeleteCallback());
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
timer3.Done();
}

Expand Down
12 changes: 6 additions & 6 deletions net/cookies/cookie_monster_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1878,29 +1878,29 @@ TEST_F(CookieMonsterTest, FlushStore) {

// Before initialization, FlushStore() should just run the callback.
cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(0, store->flush_count());
ASSERT_EQ(1, counter->callback_count());

// NULL callback is safe.
cm->FlushStore(base::Closure());
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(0, store->flush_count());
ASSERT_EQ(1, counter->callback_count());

// After initialization, FlushStore() should delegate to the store.
GetAllCookies(cm); // Force init.
cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(1, store->flush_count());
ASSERT_EQ(2, counter->callback_count());

// NULL callback is still safe.
cm->FlushStore(base::Closure());
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(2, store->flush_count());
ASSERT_EQ(2, counter->callback_count());
Expand All @@ -1909,12 +1909,12 @@ TEST_F(CookieMonsterTest, FlushStore) {
cm = new CookieMonster(NULL, NULL);
GetAllCookies(cm); // Force init.
cm->FlushStore(base::Closure());
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(2, counter->callback_count());

cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get()));
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

ASSERT_EQ(3, counter->callback_count());
}
Expand Down
14 changes: 7 additions & 7 deletions net/disk_cache/backend_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ TEST_F(DiskCacheTest, CreateBackend) {
delete cache;
}

MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

// Testst that re-creating the cache performs the expected cleanup.
Expand Down Expand Up @@ -331,7 +331,7 @@ void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) {
}
}

MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

#if defined(OS_WIN)
// Wait for the actual operation to complete, or we'll keep a file handle that
Expand Down Expand Up @@ -383,7 +383,7 @@ void DiskCacheBackendTest::BackendShutdownWithPendingIO(bool fast) {
delete cache;
}

MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

TEST_F(DiskCacheBackendTest, ShutdownWithPendingIO) {
Expand Down Expand Up @@ -424,7 +424,7 @@ void DiskCacheBackendTest::BackendShutdownWithPendingCreate(bool fast) {
EXPECT_FALSE(cb.have_result());
}

MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
}

TEST_F(DiskCacheBackendTest, ShutdownWithPendingCreate) {
Expand Down Expand Up @@ -876,7 +876,7 @@ void DiskCacheBackendTest::BackendTrimInvalidEntry() {
// If we evicted the entry in less than 20mS, we have one entry in the cache;
// if it took more than that, we posted a task and we'll delete the second
// entry too.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

// This may be not thread-safe in general, but for now it's OK so add some
// ThreadSanitizer annotations to ignore data races on cache_.
Expand Down Expand Up @@ -943,7 +943,7 @@ void DiskCacheBackendTest::BackendTrimInvalidEntry2() {
FlushQueueForTest();

// We may abort the eviction before cleaning up everything.
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();
FlushQueueForTest();
// If it's not clear enough: we may still have eviction tasks running at this
// time, so the number of entries is changing while we read it.
Expand Down Expand Up @@ -2277,7 +2277,7 @@ void DiskCacheBackendTest::BackendDoomAll() {
ASSERT_EQ(0, cache_->GetEntryCount());

// We should stop posting tasks at some point (if we post any).
MessageLoop::current()->RunAllPending();
MessageLoop::current()->RunUntilIdle();

disk_cache::Entry *entry3, *entry4;
ASSERT_EQ(net::OK, CreateEntry("third", &entry3));
Expand Down
Loading

0 comments on commit b4c62eb

Please sign in to comment.