Chromium Code Reviews| 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.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
| 20 #include "net/proxy/proxy_config.h" | 20 #include "net/proxy/proxy_config.h" |
| 21 #include "net/proxy/proxy_config_service.h" | 21 #include "net/proxy/proxy_config_service.h" |
| 22 #include "net/proxy/proxy_service.h" | 22 #include "net/proxy/proxy_service.h" |
| 23 | 23 |
| 24 #if defined(OS_LINUX) | |
|
szym
2012/11/16 16:35:41
|| defined(OS_OPENBSD)
to match BrowserMainLoop::I
pauljensen
2012/11/16 16:49:33
digit1 thought it wasn't worth it as it's guarding
| |
| 25 #include <glib-object.h> | |
| 26 #endif | |
| 27 | |
| 24 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
| 25 #include "base/mac/scoped_nsautorelease_pool.h" | 29 #include "base/mac/scoped_nsautorelease_pool.h" |
| 26 #endif | 30 #endif |
| 27 | 31 |
| 28 namespace { | 32 namespace { |
| 29 | 33 |
| 30 // Conversions from various network-related types to string. | 34 // Conversions from various network-related types to string. |
| 31 | 35 |
| 32 const char* ConnectionTypeToString( | 36 const char* ConnectionTypeToString( |
| 33 net::NetworkChangeNotifier::ConnectionType type) { | 37 net::NetworkChangeNotifier::ConnectionType type) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 private: | 116 private: |
| 113 DISALLOW_COPY_AND_ASSIGN(NetWatcher); | 117 DISALLOW_COPY_AND_ASSIGN(NetWatcher); |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 } // namespace | 120 } // namespace |
| 117 | 121 |
| 118 int main(int argc, char* argv[]) { | 122 int main(int argc, char* argv[]) { |
| 119 #if defined(OS_MACOSX) | 123 #if defined(OS_MACOSX) |
| 120 base::mac::ScopedNSAutoreleasePool pool; | 124 base::mac::ScopedNSAutoreleasePool pool; |
| 121 #endif | 125 #endif |
| 126 #if defined(OS_LINUX) | |
|
szym
2012/11/16 16:35:41
ditto
| |
| 127 // Needed so ProxyConfigServiceLinux can use gconf. | |
| 128 // Normally handled by BrowserMainLoop::InitializeToolkit(). | |
| 129 g_type_init(); | |
|
szym
2012/11/16 16:35:41
I am surprised ProxyConfigServiceLinuxTest does no
| |
| 130 #endif | |
| 122 base::AtExitManager exit_manager; | 131 base::AtExitManager exit_manager; |
| 123 CommandLine::Init(argc, argv); | 132 CommandLine::Init(argc, argv); |
| 124 logging::InitLogging( | 133 logging::InitLogging( |
| 125 NULL, | 134 NULL, |
| 126 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 135 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| 127 logging::LOCK_LOG_FILE, | 136 logging::LOCK_LOG_FILE, |
| 128 logging::DELETE_OLD_LOG_FILE, | 137 logging::DELETE_OLD_LOG_FILE, |
| 129 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 138 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
| 130 | 139 |
| 131 // Just make the main message loop the network loop. | 140 // Just make the main message loop the network loop. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 | 178 |
| 170 proxy_config_service->RemoveObserver(&net_watcher); | 179 proxy_config_service->RemoveObserver(&net_watcher); |
| 171 | 180 |
| 172 // Uses |network_change_notifier|. | 181 // Uses |network_change_notifier|. |
| 173 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 182 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
| 174 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 183 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
| 175 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 184 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
| 176 | 185 |
| 177 return 0; | 186 return 0; |
| 178 } | 187 } |
| OLD | NEW |