| 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 // This is a small utility that watches for and logs network changes. | 5 // This is a small utility that watches for and logs network changes. |
| 6 // It prints out the current network connection type and proxy configuration | 6 // It prints out the current network connection type and proxy configuration |
| 7 // upon startup and then prints out changes as they happen. | 7 // upon startup and then prints out changes as they happen. |
| 8 // It's useful for testing NetworkChangeNotifier and ProxyConfigService. | 8 // It's useful for testing NetworkChangeNotifier and ProxyConfigService. |
| 9 // The only command line option supported is --ignore-netif which is followed | 9 // The only command line option supported is --ignore-netif which is followed |
| 10 // by a comma seperated list of network interfaces to ignore when computing | 10 // by a comma seperated list of network interfaces to ignore when computing |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( | 174 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( |
| 175 new net::NetworkChangeNotifierLinux(ignored_interfaces)); | 175 new net::NetworkChangeNotifierLinux(ignored_interfaces)); |
| 176 #else | 176 #else |
| 177 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( | 177 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( |
| 178 net::NetworkChangeNotifier::Create()); | 178 net::NetworkChangeNotifier::Create()); |
| 179 #endif | 179 #endif |
| 180 | 180 |
| 181 // Use the network loop as the file loop also. | 181 // Use the network loop as the file loop also. |
| 182 std::unique_ptr<net::ProxyConfigService> proxy_config_service( | 182 std::unique_ptr<net::ProxyConfigService> proxy_config_service( |
| 183 net::ProxyService::CreateSystemProxyConfigService( | 183 net::ProxyService::CreateSystemProxyConfigService( |
| 184 network_loop.task_runner(), network_loop.task_runner())); | 184 network_loop.task_runner())); |
| 185 | 185 |
| 186 // Uses |network_change_notifier|. | 186 // Uses |network_change_notifier|. |
| 187 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); | 187 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); |
| 188 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher); | 188 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher); |
| 189 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher); | 189 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher); |
| 190 net::NetworkChangeNotifier::AddNetworkChangeObserver(&net_watcher); | 190 net::NetworkChangeNotifier::AddNetworkChangeObserver(&net_watcher); |
| 191 | 191 |
| 192 proxy_config_service->AddObserver(&net_watcher); | 192 proxy_config_service->AddObserver(&net_watcher); |
| 193 | 193 |
| 194 LOG(INFO) << "Initial connection type: " | 194 LOG(INFO) << "Initial connection type: " |
| (...skipping 17 matching lines...) Expand all Loading... |
| 212 proxy_config_service->RemoveObserver(&net_watcher); | 212 proxy_config_service->RemoveObserver(&net_watcher); |
| 213 | 213 |
| 214 // Uses |network_change_notifier|. | 214 // Uses |network_change_notifier|. |
| 215 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 215 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
| 216 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 216 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
| 217 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 217 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
| 218 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); | 218 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); |
| 219 | 219 |
| 220 return 0; | 220 return 0; |
| 221 } | 221 } |
| OLD | NEW |