| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
| 20 #include "net/proxy/proxy_config.h" | 21 #include "net/proxy/proxy_config.h" |
| 21 #include "net/proxy/proxy_config_service.h" | 22 #include "net/proxy/proxy_config_service.h" |
| 22 #include "net/proxy/proxy_service.h" | 23 #include "net/proxy/proxy_service.h" |
| 23 | 24 |
| 24 #if defined(USE_GLIB) && !defined(OS_CHROMEOS) | 25 #if defined(USE_GLIB) && !defined(OS_CHROMEOS) |
| 25 #include <glib-object.h> | 26 #include <glib-object.h> |
| 26 #endif | 27 #endif |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void OnNetworkChanged( | 108 void OnNetworkChanged( |
| 108 net::NetworkChangeNotifier::ConnectionType type) override { | 109 net::NetworkChangeNotifier::ConnectionType type) override { |
| 109 LOG(INFO) << "OnNetworkChanged(" | 110 LOG(INFO) << "OnNetworkChanged(" |
| 110 << ConnectionTypeToString(type) << ")"; | 111 << ConnectionTypeToString(type) << ")"; |
| 111 } | 112 } |
| 112 | 113 |
| 113 // net::ProxyConfigService::Observer implementation. | 114 // net::ProxyConfigService::Observer implementation. |
| 114 void OnProxyConfigChanged( | 115 void OnProxyConfigChanged( |
| 115 const net::ProxyConfig& config, | 116 const net::ProxyConfig& config, |
| 116 net::ProxyConfigService::ConfigAvailability availability) override { | 117 net::ProxyConfigService::ConfigAvailability availability) override { |
| 118 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455942 is |
| 119 // fixed. |
| 120 tracked_objects::ScopedTracker tracking_profile( |
| 121 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 122 "455942 NetWatcher::OnProxyConfigChanged")); |
| 117 LOG(INFO) << "OnProxyConfigChanged(" | 123 LOG(INFO) << "OnProxyConfigChanged(" |
| 118 << ProxyConfigToString(config) << ", " | 124 << ProxyConfigToString(config) << ", " |
| 119 << ConfigAvailabilityToString(availability) << ")"; | 125 << ConfigAvailabilityToString(availability) << ")"; |
| 120 } | 126 } |
| 121 | 127 |
| 122 private: | 128 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(NetWatcher); | 129 DISALLOW_COPY_AND_ASSIGN(NetWatcher); |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } // namespace | 132 } // namespace |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 proxy_config_service->RemoveObserver(&net_watcher); | 194 proxy_config_service->RemoveObserver(&net_watcher); |
| 189 | 195 |
| 190 // Uses |network_change_notifier|. | 196 // Uses |network_change_notifier|. |
| 191 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 197 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
| 192 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 198 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
| 193 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 199 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
| 194 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); | 200 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); |
| 195 | 201 |
| 196 return 0; | 202 return 0; |
| 197 } | 203 } |
| OLD | NEW |