| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/network_change_notifier_mac.h" | 5 #include "net/base/network_change_notifier_mac.h" |
| 6 | 6 |
| 7 #include <netinet/in.h> | 7 #include <netinet/in.h> |
| 8 #include <resolv.h> | 8 #include <resolv.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return NetworkChangeNotifier::CONNECTION_NONE; | 36 return NetworkChangeNotifier::CONNECTION_NONE; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Thread on which we can run DnsConfigService, which requires a TYPE_IO | 40 // Thread on which we can run DnsConfigService, which requires a TYPE_IO |
| 41 // message loop. | 41 // message loop. |
| 42 class NetworkChangeNotifierMac::DnsConfigServiceThread : public base::Thread { | 42 class NetworkChangeNotifierMac::DnsConfigServiceThread : public base::Thread { |
| 43 public: | 43 public: |
| 44 DnsConfigServiceThread() : base::Thread("DnsConfigService") {} | 44 DnsConfigServiceThread() : base::Thread("DnsConfigService") {} |
| 45 | 45 |
| 46 virtual ~DnsConfigServiceThread() { | 46 ~DnsConfigServiceThread() override { Stop(); } |
| 47 Stop(); | |
| 48 } | |
| 49 | 47 |
| 50 virtual void Init() override { | 48 void Init() override { |
| 51 service_ = DnsConfigService::CreateSystemService(); | 49 service_ = DnsConfigService::CreateSystemService(); |
| 52 service_->WatchConfig(base::Bind(&NetworkChangeNotifier::SetDnsConfig)); | 50 service_->WatchConfig(base::Bind(&NetworkChangeNotifier::SetDnsConfig)); |
| 53 } | 51 } |
| 54 | 52 |
| 55 virtual void CleanUp() override { | 53 void CleanUp() override { service_.reset(); } |
| 56 service_.reset(); | |
| 57 } | |
| 58 | 54 |
| 59 private: | 55 private: |
| 60 scoped_ptr<DnsConfigService> service_; | 56 scoped_ptr<DnsConfigService> service_; |
| 61 | 57 |
| 62 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread); | 58 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread); |
| 63 }; | 59 }; |
| 64 | 60 |
| 65 NetworkChangeNotifierMac::NetworkChangeNotifierMac() | 61 NetworkChangeNotifierMac::NetworkChangeNotifierMac() |
| 66 : NetworkChangeNotifier(NetworkChangeCalculatorParamsMac()), | 62 : NetworkChangeNotifier(NetworkChangeCalculatorParamsMac()), |
| 67 connection_type_(CONNECTION_UNKNOWN), | 63 connection_type_(CONNECTION_UNKNOWN), |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 NotifyObserversOfConnectionTypeChange(); | 259 NotifyObserversOfConnectionTypeChange(); |
| 264 | 260 |
| 265 #if defined(OS_IOS) | 261 #if defined(OS_IOS) |
| 266 // On iOS, the SCDynamicStore API does not exist, and we use the reachability | 262 // On iOS, the SCDynamicStore API does not exist, and we use the reachability |
| 267 // API to detect IP address changes instead. | 263 // API to detect IP address changes instead. |
| 268 NotifyObserversOfIPAddressChange(); | 264 NotifyObserversOfIPAddressChange(); |
| 269 #endif // defined(OS_IOS) | 265 #endif // defined(OS_IOS) |
| 270 } | 266 } |
| 271 | 267 |
| 272 } // namespace net | 268 } // namespace net |
| OLD | NEW |