Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Side by Side Diff: net/base/network_change_notifier.cc

Issue 10689015: [net] Adds AddressTrackerLinux which keeps track of interface addresses using rtnetlink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added NET_EXPORT_PRIVATE for tests. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/network_change_notifier.h ('k') | net/base/network_change_notifier_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "net/base/network_change_notifier.h"
6 #include "net/base/network_change_notifier_factory.h" 6 #include "net/base/network_change_notifier_factory.h"
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include "net/base/network_change_notifier_win.h" 9 #include "net/base/network_change_notifier_win.h"
10 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) 10 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 // static 79 // static
80 NetworkChangeNotifier::ConnectionType 80 NetworkChangeNotifier::ConnectionType
81 NetworkChangeNotifier::GetConnectionType() { 81 NetworkChangeNotifier::GetConnectionType() {
82 return g_network_change_notifier ? 82 return g_network_change_notifier ?
83 g_network_change_notifier->GetCurrentConnectionType() : 83 g_network_change_notifier->GetCurrentConnectionType() :
84 CONNECTION_UNKNOWN; 84 CONNECTION_UNKNOWN;
85 } 85 }
86 86
87 #if defined(OS_LINUX)
88 // static
89 const internal::AddressTrackerLinux*
90 NetworkChangeNotifier::GetAddressTracker() {
91 return g_network_change_notifier ?
92 g_network_change_notifier->GetAddressTrackerInternal() : NULL;
93 }
94 #endif
95
87 // static 96 // static
88 bool NetworkChangeNotifier::IsWatchingDNS() { 97 bool NetworkChangeNotifier::IsWatchingDNS() {
89 if (!g_network_change_notifier) 98 if (!g_network_change_notifier)
90 return false; 99 return false;
91 base::AutoLock lock(g_network_change_notifier->watching_dns_lock_); 100 base::AutoLock lock(g_network_change_notifier->watching_dns_lock_);
92 return g_network_change_notifier->watching_dns_; 101 return g_network_change_notifier->watching_dns_;
93 } 102 }
94 103
95 // static 104 // static
96 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { 105 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 new ObserverListThreadSafe<ConnectionTypeObserver>( 157 new ObserverListThreadSafe<ConnectionTypeObserver>(
149 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)), 158 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)),
150 resolver_state_observer_list_( 159 resolver_state_observer_list_(
151 new ObserverListThreadSafe<DNSObserver>( 160 new ObserverListThreadSafe<DNSObserver>(
152 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)), 161 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
153 watching_dns_(false) { 162 watching_dns_(false) {
154 DCHECK(!g_network_change_notifier); 163 DCHECK(!g_network_change_notifier);
155 g_network_change_notifier = this; 164 g_network_change_notifier = this;
156 } 165 }
157 166
167 #if defined(OS_LINUX)
168 const internal::AddressTrackerLinux*
169 NetworkChangeNotifier::GetAddressTrackerInternal() const {
170 return NULL;
171 }
172 #endif
173
158 // static 174 // static
159 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { 175 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() {
160 if (g_network_change_notifier) { 176 if (g_network_change_notifier) {
161 g_network_change_notifier->ip_address_observer_list_->Notify( 177 g_network_change_notifier->ip_address_observer_list_->Notify(
162 &IPAddressObserver::OnIPAddressChanged); 178 &IPAddressObserver::OnIPAddressChanged);
163 } 179 }
164 } 180 }
165 181
166 // static 182 // static
167 void NetworkChangeNotifier::NotifyObserversOfDNSChange(unsigned detail) { 183 void NetworkChangeNotifier::NotifyObserversOfDNSChange(unsigned detail) {
(...skipping 29 matching lines...) Expand all
197 DCHECK(g_network_change_notifier); 213 DCHECK(g_network_change_notifier);
198 g_network_change_notifier = NULL; 214 g_network_change_notifier = NULL;
199 } 215 }
200 216
201 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 217 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
202 DCHECK(!g_network_change_notifier); 218 DCHECK(!g_network_change_notifier);
203 g_network_change_notifier = network_change_notifier_; 219 g_network_change_notifier = network_change_notifier_;
204 } 220 }
205 221
206 } // namespace net 222 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.h ('k') | net/base/network_change_notifier_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698