| Index: chrome/utility/local_discovery/service_discovery_client_impl.cc
|
| diff --git a/chrome/utility/local_discovery/service_discovery_client_impl.cc b/chrome/utility/local_discovery/service_discovery_client_impl.cc
|
| index c17c0e15f8efd3b95e9f9b96c3c9f9863e61ac5c..ebb541d932faf6f63cadfd5784c266d0aff35071 100644
|
| --- a/chrome/utility/local_discovery/service_discovery_client_impl.cc
|
| +++ b/chrome/utility/local_discovery/service_discovery_client_impl.cc
|
| @@ -18,6 +18,9 @@ namespace {
|
| // TODO(noamsml): Make this configurable through the LocalDomainResolver
|
| // interface.
|
| const int kLocalDomainSecondAddressTimeoutMs = 100;
|
| +
|
| +const int kInitialRequeryTimeSeconds = 1;
|
| +const int kMaxRequeryTimeSeconds = 2; // Time for last requery
|
| }
|
|
|
| ServiceDiscoveryClientImpl::ServiceDiscoveryClientImpl(
|
| @@ -74,8 +77,7 @@ void ServiceWatcherImpl::DiscoverNewServices(bool force_update) {
|
| DCHECK(started_);
|
| if (force_update)
|
| services_.clear();
|
| - CreateTransaction(true /*network*/, false /*cache*/, force_update,
|
| - &transaction_network_);
|
| + SendQuery(kInitialRequeryTimeSeconds, force_update);
|
| }
|
|
|
| void ServiceWatcherImpl::ReadCachedServices() {
|
| @@ -234,6 +236,25 @@ void ServiceWatcherImpl::OnNsecRecord(const std::string& name,
|
| // on any name.
|
| }
|
|
|
| +void ServiceWatcherImpl::ScheduleQuery(int timeout_seconds) {
|
| + if (timeout_seconds <= kMaxRequeryTimeSeconds) {
|
| + base::MessageLoop::current()->PostDelayedTask(
|
| + FROM_HERE,
|
| + base::Bind(&ServiceWatcherImpl::SendQuery,
|
| + AsWeakPtr(),
|
| + timeout_seconds * 2 /*next_timeout_seconds*/,
|
| + false /*force_update*/),
|
| + base::TimeDelta::FromSeconds(timeout_seconds));
|
| + }
|
| +}
|
| +
|
| +void ServiceWatcherImpl::SendQuery(int next_timeout_seconds,
|
| + bool force_update) {
|
| + CreateTransaction(true /*network*/, false /*cache*/, force_update,
|
| + &transaction_network_);
|
| + ScheduleQuery(next_timeout_seconds);
|
| +}
|
| +
|
| ServiceResolverImpl::ServiceResolverImpl(
|
| const std::string& service_name,
|
| const ResolveCompleteCallback& callback,
|
|
|