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 #include "net/base/network_change_notifier_win.h" | 5 #include "net/base/network_change_notifier_win.h" |
6 | 6 |
7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/profiler/scoped_tracker.h" | |
14 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
16 #include "net/base/winsock_init.h" | 15 #include "net/base/winsock_init.h" |
17 #include "net/dns/dns_config_service.h" | 16 #include "net/dns/dns_config_service.h" |
18 | 17 |
19 #pragma comment(lib, "iphlpapi.lib") | 18 #pragma comment(lib, "iphlpapi.lib") |
20 | 19 |
21 namespace net { | 20 namespace net { |
22 | 21 |
23 namespace { | 22 namespace { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 LOG_IF(ERROR, result != 0) | 200 LOG_IF(ERROR, result != 0) |
202 << "WSALookupServiceEnd() failed with: " << result; | 201 << "WSALookupServiceEnd() failed with: " << result; |
203 | 202 |
204 // TODO(droger): Return something more detailed than CONNECTION_UNKNOWN. | 203 // TODO(droger): Return something more detailed than CONNECTION_UNKNOWN. |
205 return found_connection ? NetworkChangeNotifier::CONNECTION_UNKNOWN : | 204 return found_connection ? NetworkChangeNotifier::CONNECTION_UNKNOWN : |
206 NetworkChangeNotifier::CONNECTION_NONE; | 205 NetworkChangeNotifier::CONNECTION_NONE; |
207 } | 206 } |
208 | 207 |
209 NetworkChangeNotifier::ConnectionType | 208 NetworkChangeNotifier::ConnectionType |
210 NetworkChangeNotifierWin::GetCurrentConnectionType() const { | 209 NetworkChangeNotifierWin::GetCurrentConnectionType() const { |
211 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
212 tracked_objects::ScopedTracker tracking_profile( | |
213 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
214 "422516 NetworkChangeNotifierWin::GetCurrentConnectionType")); | |
215 | |
216 base::AutoLock auto_lock(last_computed_connection_type_lock_); | 210 base::AutoLock auto_lock(last_computed_connection_type_lock_); |
217 return last_computed_connection_type_; | 211 return last_computed_connection_type_; |
218 } | 212 } |
219 | 213 |
220 void NetworkChangeNotifierWin::SetCurrentConnectionType( | 214 void NetworkChangeNotifierWin::SetCurrentConnectionType( |
221 ConnectionType connection_type) { | 215 ConnectionType connection_type) { |
222 base::AutoLock auto_lock(last_computed_connection_type_lock_); | 216 base::AutoLock auto_lock(last_computed_connection_type_lock_); |
223 last_computed_connection_type_ = connection_type; | 217 last_computed_connection_type_ = connection_type; |
224 } | 218 } |
225 | 219 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return; | 318 return; |
325 } | 319 } |
326 if (last_announced_offline_) | 320 if (last_announced_offline_) |
327 UMA_HISTOGRAM_CUSTOM_COUNTS("NCN.OfflinePolls", offline_polls_, 1, 50, 50); | 321 UMA_HISTOGRAM_CUSTOM_COUNTS("NCN.OfflinePolls", offline_polls_, 1, 50, 50); |
328 last_announced_offline_ = current_offline; | 322 last_announced_offline_ = current_offline; |
329 | 323 |
330 NotifyObserversOfConnectionTypeChange(); | 324 NotifyObserversOfConnectionTypeChange(); |
331 } | 325 } |
332 | 326 |
333 } // namespace net | 327 } // namespace net |
OLD | NEW |