| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/host_resolver_impl_chromeos.h" | 5 #include "chromeos/network/host_resolver_impl_chromeos.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chromeos/network/device_state.h" | 10 #include "chromeos/network/device_state.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 network_state_handler_->AddObserver(this, FROM_HERE); | 45 network_state_handler_->AddObserver(this, FROM_HERE); |
| 46 DefaultNetworkChanged(network_state_handler_->DefaultNetwork()); | 46 DefaultNetworkChanged(network_state_handler_->DefaultNetwork()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 virtual ~NetworkObserver() { | 50 virtual ~NetworkObserver() { |
| 51 network_state_handler_->RemoveObserver(this, FROM_HERE); | 51 network_state_handler_->RemoveObserver(this, FROM_HERE); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // NetworkStateHandlerObserver | 54 // NetworkStateHandlerObserver |
| 55 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE { | 55 virtual void DefaultNetworkChanged(const NetworkState* network) override { |
| 56 if (!network) { | 56 if (!network) { |
| 57 DVLOG(2) << "DefaultNetworkChanged: No Network."; | 57 DVLOG(2) << "DefaultNetworkChanged: No Network."; |
| 58 CallResolverSetIpAddress("", ""); | 58 CallResolverSetIpAddress("", ""); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 std::string ipv4_address, ipv6_address; | 61 std::string ipv4_address, ipv6_address; |
| 62 const DeviceState* device_state = | 62 const DeviceState* device_state = |
| 63 network_state_handler_->GetDeviceState(network->device_path()); | 63 network_state_handler_->GetDeviceState(network->device_path()); |
| 64 if (!device_state) { | 64 if (!device_state) { |
| 65 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) | 65 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 } else { | 85 } else { |
| 86 LOG(ERROR) << "DefaultNetworkChanged: IPConfigs missing properties: " | 86 LOG(ERROR) << "DefaultNetworkChanged: IPConfigs missing properties: " |
| 87 << network->path(); | 87 << network->path(); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 DVLOG(2) << "DefaultNetworkChanged: " << network->name() | 90 DVLOG(2) << "DefaultNetworkChanged: " << network->name() |
| 91 << " IPv4: " << ipv4_address << " IPv6: " << ipv6_address; | 91 << " IPv4: " << ipv4_address << " IPv6: " << ipv6_address; |
| 92 CallResolverSetIpAddress(ipv4_address, ipv6_address); | 92 CallResolverSetIpAddress(ipv4_address, ipv6_address); |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void IsShuttingDown() OVERRIDE { | 95 virtual void IsShuttingDown() override { |
| 96 delete this; | 96 delete this; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void CallResolverSetIpAddress(const std::string& ipv4_address, | 99 void CallResolverSetIpAddress(const std::string& ipv4_address, |
| 100 const std::string& ipv6_address) { | 100 const std::string& ipv6_address) { |
| 101 resolver_message_loop_->PostTask( | 101 resolver_message_loop_->PostTask( |
| 102 FROM_HERE, | 102 FROM_HERE, |
| 103 base::Bind(&NetworkObserver::SetIpAddressOnResolverThread, | 103 base::Bind(&NetworkObserver::SetIpAddressOnResolverThread, |
| 104 weak_ptr_factory_resolver_thread_.GetWeakPtr(), | 104 weak_ptr_factory_resolver_thread_.GetWeakPtr(), |
| 105 ipv4_address, ipv6_address)); | 105 ipv4_address, ipv6_address)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 NetworkStateHandler* network_state_handler) { | 207 NetworkStateHandler* network_state_handler) { |
| 208 Options options; | 208 Options options; |
| 209 return scoped_ptr<net::HostResolver>(new HostResolverImplChromeOS( | 209 return scoped_ptr<net::HostResolver>(new HostResolverImplChromeOS( |
| 210 network_handler_message_loop, | 210 network_handler_message_loop, |
| 211 network_state_handler, | 211 network_state_handler, |
| 212 options, | 212 options, |
| 213 NULL)); | 213 NULL)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace chromeos | 216 } // namespace chromeos |
| OLD | NEW |