Index: chrome/browser/local_discovery/service_discovery_client_utility.cc |
diff --git a/chrome/browser/local_discovery/service_discovery_client_mdns.cc b/chrome/browser/local_discovery/service_discovery_client_utility.cc |
similarity index 80% |
rename from chrome/browser/local_discovery/service_discovery_client_mdns.cc |
rename to chrome/browser/local_discovery/service_discovery_client_utility.cc |
index 69fd977dd5e1d223b63bfba323619dba27858a89..b6e290c16c3b0c757d5d4d7fa84d9721f44e68cf 100644 |
--- a/chrome/browser/local_discovery/service_discovery_client_mdns.cc |
+++ b/chrome/browser/local_discovery/service_discovery_client_utility.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/local_discovery/service_discovery_client_mdns.h" |
+#include "chrome/browser/local_discovery/service_discovery_client_utility.h" |
#include "base/metrics/histogram.h" |
#include "chrome/browser/local_discovery/service_discovery_host_client.h" |
@@ -18,14 +18,15 @@ const int kRestartDelayOnNetworkChangeSeconds = 3; |
const int kReportSuccessAfterSeconds = 10; |
} |
-scoped_ptr<ServiceWatcher> ServiceDiscoveryClientMdns::CreateServiceWatcher( |
+scoped_ptr<ServiceWatcher> ServiceDiscoveryClientUtility::CreateServiceWatcher( |
const std::string& service_type, |
const ServiceWatcher::UpdatedCallback& callback) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
return host_client_->CreateServiceWatcher(service_type, callback); |
} |
-scoped_ptr<ServiceResolver> ServiceDiscoveryClientMdns::CreateServiceResolver( |
+scoped_ptr<ServiceResolver> |
+ServiceDiscoveryClientUtility::CreateServiceResolver( |
const std::string& service_name, |
const ServiceResolver::ResolveCompleteCallback& callback) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
@@ -33,7 +34,7 @@ scoped_ptr<ServiceResolver> ServiceDiscoveryClientMdns::CreateServiceResolver( |
} |
scoped_ptr<LocalDomainResolver> |
-ServiceDiscoveryClientMdns::CreateLocalDomainResolver( |
+ServiceDiscoveryClientUtility::CreateLocalDomainResolver( |
const std::string& domain, |
net::AddressFamily address_family, |
const LocalDomainResolver::IPAddressCallback& callback) { |
@@ -42,7 +43,7 @@ ServiceDiscoveryClientMdns::CreateLocalDomainResolver( |
callback); |
} |
-ServiceDiscoveryClientMdns::ServiceDiscoveryClientMdns() |
+ServiceDiscoveryClientUtility::ServiceDiscoveryClientUtility() |
: restart_attempts_(kMaxRestartAttempts), |
weak_ptr_factory_(this) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
@@ -50,13 +51,13 @@ ServiceDiscoveryClientMdns::ServiceDiscoveryClientMdns() |
StartNewClient(); |
} |
-ServiceDiscoveryClientMdns::~ServiceDiscoveryClientMdns() { |
+ServiceDiscoveryClientUtility::~ServiceDiscoveryClientUtility() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
host_client_->Shutdown(); |
} |
-void ServiceDiscoveryClientMdns::OnNetworkChanged( |
+void ServiceDiscoveryClientUtility::OnNetworkChanged( |
net::NetworkChangeNotifier::ConnectionType type) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// Only network changes resets kMaxRestartAttempts. |
@@ -64,29 +65,29 @@ void ServiceDiscoveryClientMdns::OnNetworkChanged( |
ScheduleStartNewClient(); |
} |
-void ServiceDiscoveryClientMdns::ScheduleStartNewClient() { |
+void ServiceDiscoveryClientUtility::ScheduleStartNewClient() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
host_client_->Shutdown(); |
weak_ptr_factory_.InvalidateWeakPtrs(); |
base::MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |
- base::Bind(&ServiceDiscoveryClientMdns::StartNewClient, |
+ base::Bind(&ServiceDiscoveryClientUtility::StartNewClient, |
weak_ptr_factory_.GetWeakPtr()), |
base::TimeDelta::FromSeconds(kRestartDelayOnNetworkChangeSeconds)); |
} |
-void ServiceDiscoveryClientMdns::StartNewClient() { |
+void ServiceDiscoveryClientUtility::StartNewClient() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
scoped_refptr<ServiceDiscoveryHostClient> old_client = host_client_; |
if ((restart_attempts_--) > 0) { |
host_client_ = new ServiceDiscoveryHostClient(); |
host_client_->Start( |
- base::Bind(&ServiceDiscoveryClientMdns::ScheduleStartNewClient, |
+ base::Bind(&ServiceDiscoveryClientUtility::ScheduleStartNewClient, |
weak_ptr_factory_.GetWeakPtr())); |
base::MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |
- base::Bind(&ServiceDiscoveryClientMdns::ReportSuccess, |
+ base::Bind(&ServiceDiscoveryClientUtility::ReportSuccess, |
weak_ptr_factory_.GetWeakPtr()), |
base::TimeDelta::FromSeconds(kReportSuccessAfterSeconds)); |
} else { |
@@ -99,7 +100,7 @@ void ServiceDiscoveryClientMdns::StartNewClient() { |
old_client->InvalidateWatchers(); |
} |
-void ServiceDiscoveryClientMdns::ReportSuccess() { |
+void ServiceDiscoveryClientUtility::ReportSuccess() { |
UMA_HISTOGRAM_COUNTS_100("LocalDiscovery.ClientRestartAttempts", |
kMaxRestartAttempts - restart_attempts_); |
} |