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 <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <unordered_set> | 9 #include <unordered_set> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/run_loop.h" | |
18 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
22 #include "net/proxy/proxy_config.h" | 23 #include "net/proxy/proxy_config.h" |
23 #include "net/proxy/proxy_config_service.h" | 24 #include "net/proxy/proxy_config_service.h" |
24 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
25 | 26 |
26 #if defined(USE_GLIB) && !defined(OS_CHROMEOS) | 27 #if defined(USE_GLIB) && !defined(OS_CHROMEOS) |
27 #include <glib-object.h> | 28 #include <glib-object.h> |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 const net::ProxyConfigService::ConfigAvailability availability = | 208 const net::ProxyConfigService::ConfigAvailability availability = |
208 proxy_config_service->GetLatestProxyConfig(&config); | 209 proxy_config_service->GetLatestProxyConfig(&config); |
209 LOG(INFO) << "Initial proxy config: " | 210 LOG(INFO) << "Initial proxy config: " |
210 << ProxyConfigToString(config) << ", " | 211 << ProxyConfigToString(config) << ", " |
211 << ConfigAvailabilityToString(availability); | 212 << ConfigAvailabilityToString(availability); |
212 } | 213 } |
213 | 214 |
214 LOG(INFO) << "Watching for network events..."; | 215 LOG(INFO) << "Watching for network events..."; |
215 | 216 |
216 // Start watching for events. | 217 // Start watching for events. |
217 network_loop.Run(); | 218 base::RunLoop().Run(); |
agl
2016/08/06 00:44:00
This one seems a little suspect, although I'm not
fdoray
2016/08/06 01:26:14
see previous comment.
Note that the implementatio
| |
218 | 219 |
219 proxy_config_service->RemoveObserver(&net_watcher); | 220 proxy_config_service->RemoveObserver(&net_watcher); |
220 | 221 |
221 // Uses |network_change_notifier|. | 222 // Uses |network_change_notifier|. |
222 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 223 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
223 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 224 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
224 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 225 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
225 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); | 226 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); |
226 | 227 |
227 return 0; | 228 return 0; |
228 } | 229 } |
OLD | NEW |