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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 private: | 44 private: |
45 scoped_ptr<DnsConfigService> service_; | 45 scoped_ptr<DnsConfigService> service_; |
46 | 46 |
47 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread); | 47 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread); |
48 }; | 48 }; |
49 | 49 |
50 NetworkChangeNotifierWin::NetworkChangeNotifierWin() | 50 NetworkChangeNotifierWin::NetworkChangeNotifierWin() |
51 : NetworkChangeNotifier(NetworkChangeCalculatorParamsWin()), | 51 : NetworkChangeNotifier(NetworkChangeCalculatorParamsWin()), |
52 is_watching_(false), | 52 is_watching_(false), |
53 sequential_failures_(0), | 53 sequential_failures_(0), |
54 weak_factory_(this), | |
55 dns_config_service_thread_(new DnsConfigServiceThread()), | 54 dns_config_service_thread_(new DnsConfigServiceThread()), |
56 last_computed_connection_type_(RecomputeCurrentConnectionType()), | 55 last_computed_connection_type_(RecomputeCurrentConnectionType()), |
57 last_announced_offline_( | 56 last_announced_offline_(last_computed_connection_type_ == |
58 last_computed_connection_type_ == CONNECTION_NONE) { | 57 CONNECTION_NONE), |
| 58 weak_factory_(this) { |
59 memset(&addr_overlapped_, 0, sizeof addr_overlapped_); | 59 memset(&addr_overlapped_, 0, sizeof addr_overlapped_); |
60 addr_overlapped_.hEvent = WSACreateEvent(); | 60 addr_overlapped_.hEvent = WSACreateEvent(); |
61 } | 61 } |
62 | 62 |
63 NetworkChangeNotifierWin::~NetworkChangeNotifierWin() { | 63 NetworkChangeNotifierWin::~NetworkChangeNotifierWin() { |
64 if (is_watching_) { | 64 if (is_watching_) { |
65 CancelIPChangeNotify(&addr_overlapped_); | 65 CancelIPChangeNotify(&addr_overlapped_); |
66 addr_watcher_.StopWatching(); | 66 addr_watcher_.StopWatching(); |
67 } | 67 } |
68 WSACloseEvent(addr_overlapped_.hEvent); | 68 WSACloseEvent(addr_overlapped_.hEvent); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 return; | 314 return; |
315 } | 315 } |
316 if (last_announced_offline_) | 316 if (last_announced_offline_) |
317 UMA_HISTOGRAM_CUSTOM_COUNTS("NCN.OfflinePolls", offline_polls_, 1, 50, 50); | 317 UMA_HISTOGRAM_CUSTOM_COUNTS("NCN.OfflinePolls", offline_polls_, 1, 50, 50); |
318 last_announced_offline_ = current_offline; | 318 last_announced_offline_ = current_offline; |
319 | 319 |
320 NotifyObserversOfConnectionTypeChange(); | 320 NotifyObserversOfConnectionTypeChange(); |
321 } | 321 } |
322 | 322 |
323 } // namespace net | 323 } // namespace net |
OLD | NEW |