summaryrefslogtreecommitdiffstats
path: root/net/dns
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 20:51:34 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 20:51:34 +0000
commit2da659e6279cf515940eb8a091e09e27281a97d6 (patch)
treea34e2eeea8194a16603e24149ae634cb54ddab62 /net/dns
parent954f56f3aceed29573f841648168b91c1fd43074 (diff)
downloadchromium_src-2da659e6279cf515940eb8a091e09e27281a97d6.zip
chromium_src-2da659e6279cf515940eb8a091e09e27281a97d6.tar.gz
chromium_src-2da659e6279cf515940eb8a091e09e27281a97d6.tar.bz2
net: Use base::MessageLoop.
BUG=236029 R=agl@chromium.org Review URL: https://chromiumcodereview.appspot.com/14021017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/dns')
-rw-r--r--net/dns/dns_config_service_posix.cc2
-rw-r--r--net/dns/dns_config_service_unittest.cc11
-rw-r--r--net/dns/dns_config_service_win.cc2
-rw-r--r--net/dns/dns_test_util.cc5
-rw-r--r--net/dns/dns_transaction.cc2
-rw-r--r--net/dns/dns_transaction_unittest.cc14
-rw-r--r--net/dns/host_resolver_impl_unittest.cc37
-rw-r--r--net/dns/mock_host_resolver.cc4
-rw-r--r--net/dns/notify_watcher_mac.cc4
-rw-r--r--net/dns/notify_watcher_mac.h4
-rw-r--r--net/dns/serial_worker_unittest.cc8
11 files changed, 46 insertions, 47 deletions
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index 72cd247..5f0f8244 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -140,7 +140,7 @@ class DnsConfigServicePosix::Watcher {
void OnConfigChanged(bool succeeded) {
// Ignore transient flutter of resolv.conf by delaying the signal a bit.
const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(50);
- MessageLoop::current()->PostDelayedTask(
+ base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&Watcher::OnConfigChangedDelayed,
weak_factory_.GetWeakPtr(),
diff --git a/net/dns/dns_config_service_unittest.cc b/net/dns/dns_config_service_unittest.cc
index af2c221..6121670 100644
--- a/net/dns/dns_config_service_unittest.cc
+++ b/net/dns/dns_config_service_unittest.cc
@@ -21,7 +21,7 @@ class DnsConfigServiceTest : public testing::Test {
void OnConfigChanged(const DnsConfig& config) {
last_config_ = config;
if (quit_on_config_)
- MessageLoop::current()->Quit();
+ base::MessageLoop::current()->Quit();
}
protected:
@@ -53,12 +53,11 @@ class DnsConfigServiceTest : public testing::Test {
};
void WaitForConfig(base::TimeDelta timeout) {
- base::CancelableClosure closure(MessageLoop::QuitClosure());
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- closure.callback(),
- timeout);
+ base::CancelableClosure closure(base::MessageLoop::QuitClosure());
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, closure.callback(), timeout);
quit_on_config_ = true;
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
quit_on_config_ = false;
closure.Cancel();
}
diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc
index 127746e..e1f6b23 100644
--- a/net/dns/dns_config_service_win.cc
+++ b/net/dns/dns_config_service_win.cc
@@ -622,7 +622,7 @@ class DnsConfigServiceWin::ConfigReader : public SerialWorker {
} else {
LOG(WARNING) << "Failed to read DnsConfig.";
// Try again in a while in case DnsConfigWatcher missed the signal.
- MessageLoop::current()->PostDelayedTask(
+ base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&ConfigReader::WorkNow, this),
base::TimeDelta::FromSeconds(kRetryIntervalSeconds));
diff --git a/net/dns/dns_test_util.cc b/net/dns/dns_test_util.cc
index 237646b..d725a32 100644
--- a/net/dns/dns_test_util.cc
+++ b/net/dns/dns_test_util.cc
@@ -65,9 +65,8 @@ class MockTransaction : public DnsTransaction,
if (MockDnsClientRule::FAIL_SYNC == result_)
return ERR_NAME_NOT_RESOLVED;
// Using WeakPtr to cleanly cancel when transaction is destroyed.
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockTransaction::Finish, AsWeakPtr()));
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&MockTransaction::Finish, AsWeakPtr()));
return ERR_IO_PENDING;
}
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc
index fdd2eb2..c297566 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -541,7 +541,7 @@ class DnsTransactionImpl : public DnsTransaction,
AttemptResult result = ProcessAttemptResult(StartQuery());
if (result.rv == OK) {
// DnsTransaction must never succeed synchronously.
- MessageLoop::current()->PostTask(
+ base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&DnsTransactionImpl::DoCallback, AsWeakPtr(), result));
return ERR_IO_PENDING;
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
index 71b5d79..f6fb8e5 100644
--- a/net/dns/dns_transaction_unittest.cc
+++ b/net/dns/dns_transaction_unittest.cc
@@ -276,7 +276,7 @@ class TransactionHelper {
// Tell MessageLoop to quit now, in case any ASSERT_* fails.
if (quit_in_callback_)
- MessageLoop::current()->Quit();
+ base::MessageLoop::current()->Quit();
if (expected_answer_count_ >= 0) {
ASSERT_EQ(OK, rv);
@@ -303,7 +303,7 @@ class TransactionHelper {
bool Run(DnsTransactionFactory* factory) {
StartTransaction(factory);
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
return has_completed();
}
@@ -311,7 +311,7 @@ class TransactionHelper {
bool RunUntilDone(DnsTransactionFactory* factory) {
set_quit_in_callback();
StartTransaction(factory);
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
return has_completed();
}
@@ -498,7 +498,7 @@ TEST_F(DnsTransactionTest, ConcurrentLookup) {
TransactionHelper helper1(kT1HostName, kT1Qtype, kT1RecordCount);
helper1.StartTransaction(transaction_factory_.get());
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(helper0.has_completed());
EXPECT_TRUE(helper1.has_completed());
@@ -517,7 +517,7 @@ TEST_F(DnsTransactionTest, CancelLookup) {
helper0.Cancel();
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(helper0.has_completed());
EXPECT_TRUE(helper1.has_completed());
@@ -533,7 +533,7 @@ TEST_F(DnsTransactionTest, DestroyFactory) {
// Destroying the client does not affect running requests.
transaction_factory_.reset(NULL);
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(helper0.has_completed());
}
@@ -624,7 +624,7 @@ TEST_F(DnsTransactionTest, Timeout) {
TransactionHelper helper0(kT0HostName, kT0Qtype, ERR_DNS_TIMED_OUT);
EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get()));
- MessageLoop::current()->AssertIdle();
+ base::MessageLoop::current()->AssertIdle();
}
TEST_F(DnsTransactionTest, ServerFallbackAndRotate) {
diff --git a/net/dns/host_resolver_impl_unittest.cc b/net/dns/host_resolver_impl_unittest.cc
index 213661d..b677af4 100644
--- a/net/dns/host_resolver_impl_unittest.cc
+++ b/net/dns/host_resolver_impl_unittest.cc
@@ -257,12 +257,11 @@ class Request {
int WaitForResult() {
if (completed())
return result_;
- base::CancelableClosure closure(MessageLoop::QuitClosure());
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- closure.callback(),
- TestTimeouts::action_max_timeout());
+ base::CancelableClosure closure(base::MessageLoop::QuitClosure());
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, closure.callback(), TestTimeouts::action_max_timeout());
quit_on_complete_ = true;
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
bool did_quit = !quit_on_complete_;
quit_on_complete_ = false;
closure.Cancel();
@@ -286,7 +285,7 @@ class Request {
if (handler_)
handler_->Handle(this);
if (quit_on_complete_) {
- MessageLoop::current()->Quit();
+ base::MessageLoop::current()->Quit();
quit_on_complete_ = false;
}
}
@@ -713,7 +712,8 @@ TEST_F(HostResolverImplTest, DeleteWithinCallback) {
// Quit after returning from OnCompleted (to give it a chance at
// incorrectly running the cancelled tasks).
- MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::MessageLoop::QuitClosure());
}
};
set_handler(new MyHandler());
@@ -725,7 +725,7 @@ TEST_F(HostResolverImplTest, DeleteWithinCallback) {
proc_->SignalMultiple(1u); // One for "a".
// |MyHandler| will send quit message once all the requests have finished.
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
}
TEST_F(HostResolverImplTest, DeleteWithinAbortedCallback) {
@@ -738,7 +738,8 @@ TEST_F(HostResolverImplTest, DeleteWithinAbortedCallback) {
// Quit after returning from OnCompleted (to give it a chance at
// incorrectly running the cancelled tasks).
- MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::MessageLoop::QuitClosure());
}
};
set_handler(new MyHandler());
@@ -757,7 +758,7 @@ TEST_F(HostResolverImplTest, DeleteWithinAbortedCallback) {
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
// |MyHandler| will send quit message once all the requests have finished.
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[0]->result());
EXPECT_EQ(ERR_IO_PENDING, requests_[1]->result());
@@ -816,7 +817,7 @@ TEST_F(HostResolverImplTest, BypassCache) {
EXPECT_EQ(ERR_IO_PENDING, CreateRequest(info)->Resolve());
} else if (71 == req->info().port()) {
// Test is done.
- MessageLoop::current()->Quit();
+ base::MessageLoop::current()->Quit();
} else {
FAIL() << "Unexpected request";
}
@@ -828,7 +829,7 @@ TEST_F(HostResolverImplTest, BypassCache) {
proc_->SignalMultiple(3u); // Only need two, but be generous.
// |verifier| will send quit message once all the requests have finished.
- MessageLoop::current()->Run();
+ base::MessageLoop::current()->Run();
EXPECT_EQ(2u, proc_->GetCaptureList().size());
}
@@ -845,7 +846,7 @@ TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) {
// Flush cache by triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
- MessageLoop::current()->RunUntilIdle(); // Notification happens async.
+ base::MessageLoop::current()->RunUntilIdle(); // Notification happens async.
// Resolve "host1" again -- this time it won't be served from cache, so it
// will complete asynchronously.
@@ -862,7 +863,7 @@ TEST_F(HostResolverImplTest, AbortOnIPAddressChanged) {
EXPECT_TRUE(proc_->WaitFor(1u));
// Triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
- MessageLoop::current()->RunUntilIdle(); // Notification happens async.
+ base::MessageLoop::current()->RunUntilIdle(); // Notification happens async.
proc_->SignalAll();
EXPECT_EQ(ERR_NETWORK_CHANGED, req->WaitForResult());
@@ -880,7 +881,7 @@ TEST_F(HostResolverImplTest, ObeyPoolConstraintsAfterIPAddressChange) {
EXPECT_TRUE(proc_->WaitFor(1u));
// Triggering an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
- MessageLoop::current()->RunUntilIdle(); // Notification happens async.
+ base::MessageLoop::current()->RunUntilIdle(); // Notification happens async.
proc_->SignalMultiple(3u); // Let the false-start go so that we can catch it.
EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[0]->WaitForResult());
@@ -924,7 +925,7 @@ TEST_F(HostResolverImplTest, AbortOnlyExistingRequestsOnIPAddressChange) {
// Trigger an IP address change.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
// This should abort all running jobs.
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[0]->result());
EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[1]->result());
EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[2]->result());
@@ -1232,7 +1233,7 @@ TEST_F(HostResolverImplTest, MultipleAttempts) {
resolver_proc->WaitForAllAttemptsToFinish(
base::TimeDelta::FromMilliseconds(60000));
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts);
EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve);
@@ -1287,7 +1288,7 @@ class HostResolverImplDnsTest : public HostResolverImplTest {
void ChangeDnsConfig(const DnsConfig& config) {
NetworkChangeNotifier::SetDnsConfig(config);
// Notification is delivered asynchronously.
- MessageLoop::current()->RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
MockDnsClientRuleList dns_rules_;
diff --git a/net/dns/mock_host_resolver.cc b/net/dns/mock_host_resolver.cc
index 5b75bfb..7fe0adb 100644
--- a/net/dns/mock_host_resolver.cc
+++ b/net/dns/mock_host_resolver.cc
@@ -88,7 +88,7 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
*handle = reinterpret_cast<RequestHandle>(id);
if (!ondemand_mode_) {
- MessageLoop::current()->PostTask(
+ base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), id));
}
@@ -127,7 +127,7 @@ void MockHostResolverBase::ResolveAllPending() {
DCHECK(CalledOnValidThread());
DCHECK(ondemand_mode_);
for (RequestMap::iterator i = requests_.begin(); i != requests_.end(); ++i) {
- MessageLoop::current()->PostTask(
+ base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), i->first));
}
diff --git a/net/dns/notify_watcher_mac.cc b/net/dns/notify_watcher_mac.cc
index 67cee01..286f18b 100644
--- a/net/dns/notify_watcher_mac.cc
+++ b/net/dns/notify_watcher_mac.cc
@@ -26,10 +26,10 @@ bool NotifyWatcherMac::Watch(const char* key, const CallbackType& callback) {
if (status != NOTIFY_STATUS_OK)
return false;
DCHECK_GE(notify_fd_, 0);
- if (!MessageLoopForIO::current()->WatchFileDescriptor(
+ if (!base::MessageLoopForIO::current()->WatchFileDescriptor(
notify_fd_,
true,
- MessageLoopForIO::WATCH_READ,
+ base::MessageLoopForIO::WATCH_READ,
&watcher_,
this)) {
Cancel();
diff --git a/net/dns/notify_watcher_mac.h b/net/dns/notify_watcher_mac.h
index a05eda2..24e9974 100644
--- a/net/dns/notify_watcher_mac.h
+++ b/net/dns/notify_watcher_mac.h
@@ -12,7 +12,7 @@ namespace net {
// Watches for notifications from Libnotify and delivers them to a Callback.
// After failure the watch is cancelled and will have to be restarted.
-class NotifyWatcherMac : public MessageLoopForIO::Watcher {
+class NotifyWatcherMac : public base::MessageLoopForIO::Watcher {
public:
// Called on received notification with true on success and false on error.
typedef base::Callback<void(bool succeeded)> CallbackType;
@@ -37,7 +37,7 @@ class NotifyWatcherMac : public MessageLoopForIO::Watcher {
int notify_fd_;
int notify_token_;
CallbackType callback_;
- MessageLoopForIO::FileDescriptorWatcher watcher_;
+ base::MessageLoopForIO::FileDescriptorWatcher watcher_;
DISALLOW_COPY_AND_ASSIGN(NotifyWatcherMac);
};
diff --git a/net/dns/serial_worker_unittest.cc b/net/dns/serial_worker_unittest.cc
index 7fe0ef7..1265a21 100644
--- a/net/dns/serial_worker_unittest.cc
+++ b/net/dns/serial_worker_unittest.cc
@@ -55,7 +55,7 @@ class SerialWorkerTest : public testing::Test {
}
void OnWorkFinished() {
- EXPECT_TRUE(message_loop_ == MessageLoop::current());
+ EXPECT_TRUE(message_loop_ == base::MessageLoop::current());
EXPECT_EQ(output_value_, input_value_);
BreakNow("OnWorkFinished");
}
@@ -63,7 +63,7 @@ class SerialWorkerTest : public testing::Test {
protected:
void BreakCallback(std::string breakpoint) {
breakpoint_ = breakpoint;
- MessageLoop::current()->QuitNow();
+ base::MessageLoop::current()->QuitNow();
}
void BreakNow(std::string b) {
@@ -97,7 +97,7 @@ class SerialWorkerTest : public testing::Test {
// test::Test methods
virtual void SetUp() OVERRIDE {
- message_loop_ = MessageLoop::current();
+ message_loop_ = base::MessageLoop::current();
worker_ = new TestSerialWorker(this);
}
@@ -126,7 +126,7 @@ class SerialWorkerTest : public testing::Test {
base::Lock work_lock_;
// Loop for this thread.
- MessageLoop* message_loop_;
+ base::MessageLoop* message_loop_;
// WatcherDelegate under test.
scoped_refptr<TestSerialWorker> worker_;