Chromium Code Reviews| Index: chrome/browser/chromeos/net/network_change_notifier_chromeos.cc |
| diff --git a/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc b/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc |
| index 2007857481c882223e8470fd075f7715810fe46d..ddd55a1ecbde022add4d9928890d9f99c1b1879a 100644 |
| --- a/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc |
| +++ b/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc |
| @@ -8,6 +8,7 @@ |
| #include "chrome/browser/chromeos/cros/cros_library.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "net/dns/dns_config_service_posix.h" |
| using content::BrowserThread; |
| @@ -26,6 +27,27 @@ bool IsOnline(chromeos::ConnectionState state) { |
| namespace chromeos { |
| +class NetworkChangeNotifierChromeos::DnsConfigServiceChromeos |
| + : public net::DnsConfigServicePosix { |
| + public: |
| + DnsConfigServiceChromeos() {} |
| + |
| + virtual ~DnsConfigServiceChromeos() {} |
| + |
| + // net::DnsConfigServicePosix: |
| + virtual bool StartWatching() OVERRIDE { |
| + // Notifications from NetworkLibrary are sent to |
| + // NetworkChangeNotifierChromeos. |
| + return true; |
| + } |
| + |
| + void OnNetworkChange() { |
| + InvalidateConfig(); |
| + InvalidateHosts(); |
| + ReadNow(); |
| + } |
| +}; |
| + |
| NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() |
| : has_active_network_(false), |
| connection_state_(chromeos::STATE_UNKNOWN), |
| @@ -49,12 +71,18 @@ void NetworkChangeNotifierChromeos::Init() { |
| DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| + dns_config_service_.reset(new DnsConfigServiceChromeos()); |
| + dns_config_service_->WatchConfig( |
| + base::Bind(NetworkChangeNotifier::SetDnsConfig)); |
| + |
| UpdateNetworkState(network_library); |
| } |
| void NetworkChangeNotifierChromeos::Shutdown() { |
| weak_factory_.InvalidateWeakPtrs(); |
| + dns_config_service_.reset(); |
| + |
| if (!chromeos::CrosLibrary::Get()) |
| return; |
| @@ -112,6 +140,8 @@ void NetworkChangeNotifierChromeos::UpdateNetworkState( |
| << ", state= " << network->state(); |
| } |
| + dns_config_service_->OnNetworkChange(); |
|
zel
2012/09/04 17:16:11
This will fire way too often for what you are tryi
szym
2012/09/04 17:29:31
How often does this fire?
If I correctly understa
zel
2012/09/05 19:26:59
For an active network this will fire when any of i
szym
2012/09/05 19:48:29
That is indeed a bit too often, but note that this
|
| + |
| // Check if active network was added, removed or changed. |
| if ((!network && has_active_network_) || |
| (network && (!has_active_network_ || |