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_mac.h" | 5 #include "net/base/network_change_notifier_mac.h" |
6 | 6 |
7 #include <netinet/in.h> | 7 #include <netinet/in.h> |
8 #include <resolv.h> | 8 #include <resolv.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 NetworkChangeNotifier::ConnectionType | 75 NetworkChangeNotifier::ConnectionType |
76 NetworkChangeNotifierMac::GetCurrentConnectionType() const { | 76 NetworkChangeNotifierMac::GetCurrentConnectionType() const { |
77 base::AutoLock lock(connection_type_lock_); | 77 base::AutoLock lock(connection_type_lock_); |
78 // Make sure the initial connection type is set before returning. | 78 // Make sure the initial connection type is set before returning. |
79 while (!connection_type_initialized_) { | 79 while (!connection_type_initialized_) { |
80 initial_connection_type_cv_.Wait(); | 80 initial_connection_type_cv_.Wait(); |
81 } | 81 } |
82 return connection_type_; | 82 return connection_type_; |
83 } | 83 } |
84 | 84 |
85 void NetworkChangeNotifierMac::Forwarder::Init() { | |
86 net_config_watcher_->SetInitialConnectionType(); | |
87 } | |
88 void NetworkChangeNotifierMac::Forwarder::StartReachabilityNotifications() { | |
89 net_config_watcher_->StartReachabilityNotifications(); | |
90 } | |
91 void NetworkChangeNotifierMac::Forwarder::SetDynamicStoreNotificationKeys( | |
92 SCDynamicStoreRef store) { | |
93 net_config_watcher_->SetDynamicStoreNotificationKeys(store); | |
94 } | |
95 void NetworkChangeNotifierMac::Forwarder::OnNetworkConfigChange( | |
mmenke
2012/08/09 15:13:35
nit: put a black line between functions.
hans
2012/08/09 15:35:42
Done.
| |
96 CFArrayRef changed_keys) { | |
97 net_config_watcher_->OnNetworkConfigChange(changed_keys); | |
98 } | |
99 | |
85 void NetworkChangeNotifierMac::SetInitialConnectionType() { | 100 void NetworkChangeNotifierMac::SetInitialConnectionType() { |
86 // Called on notifier thread. | 101 // Called on notifier thread. |
87 | 102 |
88 // Try to reach 0.0.0.0. This is the approach taken by Firefox: | 103 // Try to reach 0.0.0.0. This is the approach taken by Firefox: |
89 // | 104 // |
90 // http://mxr.mozilla.org/mozilla2.0/source/netwerk/system/mac/nsNetworkLinkSe rvice.mm | 105 // http://mxr.mozilla.org/mozilla2.0/source/netwerk/system/mac/nsNetworkLinkSe rvice.mm |
91 // | 106 // |
92 // From my (adamk) testing on Snow Leopard, 0.0.0.0 | 107 // From my (adamk) testing on Snow Leopard, 0.0.0.0 |
93 // seems to be reachable if any network connection is available. | 108 // seems to be reachable if any network connection is available. |
94 struct sockaddr_in addr = {0}; | 109 struct sockaddr_in addr = {0}; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 { | 214 { |
200 base::AutoLock lock(notifier_mac->connection_type_lock_); | 215 base::AutoLock lock(notifier_mac->connection_type_lock_); |
201 old_type = notifier_mac->connection_type_; | 216 old_type = notifier_mac->connection_type_; |
202 notifier_mac->connection_type_ = new_type; | 217 notifier_mac->connection_type_ = new_type; |
203 } | 218 } |
204 if (old_type != new_type) | 219 if (old_type != new_type) |
205 NotifyObserversOfConnectionTypeChange(); | 220 NotifyObserversOfConnectionTypeChange(); |
206 } | 221 } |
207 | 222 |
208 } // namespace net | 223 } // namespace net |
OLD | NEW |