summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/local_discovery/service_discovery_host_client.cc60
-rw-r--r--chrome/browser/local_discovery/service_discovery_host_client.h9
2 files changed, 51 insertions, 18 deletions
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.cc b/chrome/browser/local_discovery/service_discovery_host_client.cc
index c37d4c0..e66e4b1 100644
--- a/chrome/browser/local_discovery/service_discovery_host_client.cc
+++ b/chrome/browser/local_discovery/service_discovery_host_client.cc
@@ -15,6 +15,21 @@
namespace local_discovery {
+namespace {
+
+void LogInterfaces() {
+ net::NetworkInterfaceList list;
+ net::GetNetworkList(&list);
+ std::string log;
+ for (net::NetworkInterfaceList::iterator it = list.begin(); it != list.end();
+ ++it) {
+ log += " " + net::IPAddressToString(it->address);
+ }
+ VLOG(1) << "Local addresses:" << log;
+}
+
+} // namespace
+
using content::BrowserThread;
using content::UtilityProcessHost;
@@ -216,14 +231,14 @@ void ServiceDiscoveryHostClient::UnregisterLocalDomainResolverCallback(
void ServiceDiscoveryHostClient::Start() {
DCHECK(CalledOnValidThread());
- net::NetworkChangeNotifier::AddIPAddressObserver(this);
+ net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
io_runner_->PostTask(
FROM_HERE,
base::Bind(&ServiceDiscoveryHostClient::StartOnIOThread, this));
}
void ServiceDiscoveryHostClient::Shutdown() {
- net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
+ net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
DCHECK(CalledOnValidThread());
io_runner_->PostTask(
FROM_HERE,
@@ -264,6 +279,27 @@ void ServiceDiscoveryHostClient::ShutdownOnIOThread() {
}
}
+void ServiceDiscoveryHostClient::Restart() {
+ DCHECK(CalledOnValidThread());
+
+ VLOG(1) << "ServiceDiscoveryHostClient::Restart";
+ LogInterfaces();
+
+ io_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ServiceDiscoveryHostClient::RestartOnIOThread, this));
+
+ WatcherCallbacks service_watcher_callbacks;
+ service_watcher_callbacks_.swap(service_watcher_callbacks);
+
+ for (WatcherCallbacks::iterator i = service_watcher_callbacks.begin();
+ i != service_watcher_callbacks.end(); i++) {
+ if (!i->second.is_null()) {
+ i->second.Run(ServiceWatcher::UPDATE_INVALIDATED, "");
+ }
+ }
+}
+
void ServiceDiscoveryHostClient::RestartOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -284,20 +320,14 @@ void ServiceDiscoveryHostClient::SendOnIOThread(IPC::Message* msg) {
utility_host_->Send(msg);
}
-void ServiceDiscoveryHostClient::OnIPAddressChanged() {
- io_runner_->PostTask(
+void ServiceDiscoveryHostClient::OnNetworkChanged(
+ net::NetworkChangeNotifier::ConnectionType type) {
+ VLOG(1) << "ServiceDiscoveryHostClient::OnNetworkChanged";
+ LogInterfaces();
+ callback_runner_->PostDelayedTask(
FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::RestartOnIOThread, this));
-
- WatcherCallbacks service_watcher_callbacks;
- service_watcher_callbacks_.swap(service_watcher_callbacks);
-
- for (WatcherCallbacks::iterator i = service_watcher_callbacks.begin();
- i != service_watcher_callbacks.end(); i++) {
- if (!i->second.is_null()) {
- i->second.Run(ServiceWatcher::UPDATE_INVALIDATED, "");
- }
- }
+ base::Bind(&ServiceDiscoveryHostClient::Restart, this),
+ base::TimeDelta::FromSeconds(10));
}
bool ServiceDiscoveryHostClient::OnMessageReceived(
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.h b/chrome/browser/local_discovery/service_discovery_host_client.h
index dbb7071..efbb025 100644
--- a/chrome/browser/local_discovery/service_discovery_host_client.h
+++ b/chrome/browser/local_discovery/service_discovery_host_client.h
@@ -30,7 +30,7 @@ class ServiceDiscoveryHostClient
: public base::NonThreadSafe,
public ServiceDiscoveryClient,
public content::UtilityProcessHostClient,
- public net::NetworkChangeNotifier::IPAddressObserver {
+ public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
ServiceDiscoveryHostClient();
@@ -55,8 +55,9 @@ class ServiceDiscoveryHostClient
// UtilityProcessHostClient implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- // net::NetworkChangeNotifier::IPAddressObserver implementation.
- virtual void OnIPAddressChanged() OVERRIDE;
+ // net::NetworkChangeNotifier::NetworkChangeObserver implementation.
+ virtual void OnNetworkChanged(
+ net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
protected:
virtual ~ServiceDiscoveryHostClient();
@@ -76,6 +77,8 @@ class ServiceDiscoveryHostClient
void ShutdownOnIOThread();
void RestartOnIOThread();
+ void Restart();
+
void Send(IPC::Message* msg);
void SendOnIOThread(IPC::Message* msg);