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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 MessageLoopForIO network_loop; | 132 MessageLoopForIO network_loop; |
133 | 133 |
134 NetWatcher net_watcher; | 134 NetWatcher net_watcher; |
135 | 135 |
136 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( | 136 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( |
137 net::NetworkChangeNotifier::Create()); | 137 net::NetworkChangeNotifier::Create()); |
138 | 138 |
139 // Use the network loop as the file loop also. | 139 // Use the network loop as the file loop also. |
140 scoped_ptr<net::ProxyConfigService> proxy_config_service( | 140 scoped_ptr<net::ProxyConfigService> proxy_config_service( |
141 net::ProxyService::CreateSystemProxyConfigService( | 141 net::ProxyService::CreateSystemProxyConfigService( |
142 network_loop.message_loop_proxy(), | 142 network_loop.message_loop_proxy().get(), |
143 &network_loop)); | 143 &network_loop)); |
144 | 144 |
145 // Uses |network_change_notifier|. | 145 // Uses |network_change_notifier|. |
146 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); | 146 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); |
147 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher); | 147 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher); |
148 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher); | 148 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher); |
149 | 149 |
150 proxy_config_service->AddObserver(&net_watcher); | 150 proxy_config_service->AddObserver(&net_watcher); |
151 | 151 |
152 LOG(INFO) << "Initial connection type: " | 152 LOG(INFO) << "Initial connection type: " |
(...skipping 16 matching lines...) Expand all Loading... |
169 | 169 |
170 proxy_config_service->RemoveObserver(&net_watcher); | 170 proxy_config_service->RemoveObserver(&net_watcher); |
171 | 171 |
172 // Uses |network_change_notifier|. | 172 // Uses |network_change_notifier|. |
173 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 173 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
174 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 174 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
175 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 175 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
176 | 176 |
177 return 0; | 177 return 0; |
178 } | 178 } |
OLD | NEW |