| 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 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // The main observer class that logs network events. | 81 // The main observer class that logs network events. |
| 82 class NetWatcher : | 82 class NetWatcher : |
| 83 public net::NetworkChangeNotifier::IPAddressObserver, | 83 public net::NetworkChangeNotifier::IPAddressObserver, |
| 84 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 84 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 85 public net::NetworkChangeNotifier::DNSObserver, | 85 public net::NetworkChangeNotifier::DNSObserver, |
| 86 public net::NetworkChangeNotifier::NetworkChangeObserver, | 86 public net::NetworkChangeNotifier::NetworkChangeObserver, |
| 87 public net::ProxyConfigService::Observer { | 87 public net::ProxyConfigService::Observer { |
| 88 public: | 88 public: |
| 89 NetWatcher() {} | 89 NetWatcher() {} |
| 90 | 90 |
| 91 virtual ~NetWatcher() {} | 91 ~NetWatcher() override {} |
| 92 | 92 |
| 93 // net::NetworkChangeNotifier::IPAddressObserver implementation. | 93 // net::NetworkChangeNotifier::IPAddressObserver implementation. |
| 94 virtual void OnIPAddressChanged() override { | 94 void OnIPAddressChanged() override { LOG(INFO) << "OnIPAddressChanged()"; } |
| 95 LOG(INFO) << "OnIPAddressChanged()"; | |
| 96 } | |
| 97 | 95 |
| 98 // net::NetworkChangeNotifier::ConnectionTypeObserver implementation. | 96 // net::NetworkChangeNotifier::ConnectionTypeObserver implementation. |
| 99 virtual void OnConnectionTypeChanged( | 97 void OnConnectionTypeChanged( |
| 100 net::NetworkChangeNotifier::ConnectionType type) override { | 98 net::NetworkChangeNotifier::ConnectionType type) override { |
| 101 LOG(INFO) << "OnConnectionTypeChanged(" | 99 LOG(INFO) << "OnConnectionTypeChanged(" |
| 102 << ConnectionTypeToString(type) << ")"; | 100 << ConnectionTypeToString(type) << ")"; |
| 103 } | 101 } |
| 104 | 102 |
| 105 // net::NetworkChangeNotifier::DNSObserver implementation. | 103 // net::NetworkChangeNotifier::DNSObserver implementation. |
| 106 virtual void OnDNSChanged() override { | 104 void OnDNSChanged() override { LOG(INFO) << "OnDNSChanged()"; } |
| 107 LOG(INFO) << "OnDNSChanged()"; | |
| 108 } | |
| 109 | 105 |
| 110 // net::NetworkChangeNotifier::NetworkChangeObserver implementation. | 106 // net::NetworkChangeNotifier::NetworkChangeObserver implementation. |
| 111 virtual void OnNetworkChanged( | 107 void OnNetworkChanged( |
| 112 net::NetworkChangeNotifier::ConnectionType type) override { | 108 net::NetworkChangeNotifier::ConnectionType type) override { |
| 113 LOG(INFO) << "OnNetworkChanged(" | 109 LOG(INFO) << "OnNetworkChanged(" |
| 114 << ConnectionTypeToString(type) << ")"; | 110 << ConnectionTypeToString(type) << ")"; |
| 115 } | 111 } |
| 116 | 112 |
| 117 // net::ProxyConfigService::Observer implementation. | 113 // net::ProxyConfigService::Observer implementation. |
| 118 virtual void OnProxyConfigChanged( | 114 void OnProxyConfigChanged( |
| 119 const net::ProxyConfig& config, | 115 const net::ProxyConfig& config, |
| 120 net::ProxyConfigService::ConfigAvailability availability) override { | 116 net::ProxyConfigService::ConfigAvailability availability) override { |
| 121 LOG(INFO) << "OnProxyConfigChanged(" | 117 LOG(INFO) << "OnProxyConfigChanged(" |
| 122 << ProxyConfigToString(config) << ", " | 118 << ProxyConfigToString(config) << ", " |
| 123 << ConfigAvailabilityToString(availability) << ")"; | 119 << ConfigAvailabilityToString(availability) << ")"; |
| 124 } | 120 } |
| 125 | 121 |
| 126 private: | 122 private: |
| 127 DISALLOW_COPY_AND_ASSIGN(NetWatcher); | 123 DISALLOW_COPY_AND_ASSIGN(NetWatcher); |
| 128 }; | 124 }; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 proxy_config_service->RemoveObserver(&net_watcher); | 188 proxy_config_service->RemoveObserver(&net_watcher); |
| 193 | 189 |
| 194 // Uses |network_change_notifier|. | 190 // Uses |network_change_notifier|. |
| 195 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 191 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
| 196 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 192 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
| 197 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 193 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
| 198 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); | 194 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); |
| 199 | 195 |
| 200 return 0; | 196 return 0; |
| 201 } | 197 } |
| OLD | NEW |