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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 private: | 124 private: |
125 DISALLOW_COPY_AND_ASSIGN(NetWatcher); | 125 DISALLOW_COPY_AND_ASSIGN(NetWatcher); |
126 }; | 126 }; |
127 | 127 |
128 } // namespace | 128 } // namespace |
129 | 129 |
130 int main(int argc, char* argv[]) { | 130 int main(int argc, char* argv[]) { |
131 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
132 base::mac::ScopedNSAutoreleasePool pool; | 132 base::mac::ScopedNSAutoreleasePool pool; |
133 #endif | 133 #endif |
134 #if (defined(OS_LINUX) || defined(OS_OPENBSD)) && !defined(OS_CHROMEOS) | 134 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
akalin
2013/10/07 23:24:55
looks like you change the guards for the glib-obje
| |
135 // g_type_init will be deprecated in 2.36. 2.35 is the development | |
136 // version for 2.36, hence do not call g_type_init starting 2.35. | |
137 // http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g -type-init | |
138 #if !GLIB_CHECK_VERSION(2, 35, 0) | |
135 // Needed so ProxyConfigServiceLinux can use gconf. | 139 // Needed so ProxyConfigServiceLinux can use gconf. |
136 // Normally handled by BrowserMainLoop::InitializeToolkit(). | 140 // Normally handled by BrowserMainLoop::InitializeToolkit(). |
137 // From glib version 2.36 onwards, g_type_init is implicitly called and it is | 141 g_type_init(); |
138 // deprecated. | |
139 // TODO(yael) Simplify this once Ubuntu 10.04 is no longer supported. | |
140 #if defined(G_GNUC_BEGIN_IGNORE_DEPRECATIONS) && \ | |
141 defined(G_GNUC_END_IGNORE_DEPRECATIONS) | |
142 #define USE_GLIB_DEPRECATIONS_MACROS | |
143 #endif | 142 #endif |
144 | 143 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
145 #if defined(USE_GLIB_DEPRECATIONS_MACROS) | |
146 G_GNUC_BEGIN_IGNORE_DEPRECATIONS | |
147 #endif | |
148 g_type_init(); | |
149 #if defined(USE_GLIB_DEPRECATIONS_MACROS) | |
150 G_GNUC_END_IGNORE_DEPRECATIONS | |
151 #endif | |
152 #undef USE_GLIB_DEPRECATIONS_MACROS | |
153 #endif // (defined(OS_LINUX) || defined(OS_OPENBSD)) && !defined(OS_CHROMEOS) | |
154 base::AtExitManager exit_manager; | 144 base::AtExitManager exit_manager; |
155 CommandLine::Init(argc, argv); | 145 CommandLine::Init(argc, argv); |
156 logging::LoggingSettings settings; | 146 logging::LoggingSettings settings; |
157 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 147 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
158 logging::InitLogging(settings); | 148 logging::InitLogging(settings); |
159 | 149 |
160 // Just make the main message loop the network loop. | 150 // Just make the main message loop the network loop. |
161 base::MessageLoopForIO network_loop; | 151 base::MessageLoopForIO network_loop; |
162 | 152 |
163 NetWatcher net_watcher; | 153 NetWatcher net_watcher; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 proxy_config_service->RemoveObserver(&net_watcher); | 189 proxy_config_service->RemoveObserver(&net_watcher); |
200 | 190 |
201 // Uses |network_change_notifier|. | 191 // Uses |network_change_notifier|. |
202 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); | 192 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); |
203 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); | 193 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); |
204 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); | 194 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); |
205 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); | 195 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); |
206 | 196 |
207 return 0; | 197 return 0; |
208 } | 198 } |
OLD | NEW |