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

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

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: Renamed GetMap to GetAddressMap. Fixed nits. 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
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 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list_threadsafe.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 class NetworkChangeNotifierFactory; 15 class NetworkChangeNotifierFactory;
16 16
17 namespace internal { 17 namespace internal {
18 class DnsConfigWatcher; 18 class DnsConfigWatcher;
19
20 #if defined(OS_LINUX)
21 class AddressTrackerLinux;
22 #endif
19 } 23 }
20 24
21 // NetworkChangeNotifier monitors the system for network changes, and notifies 25 // NetworkChangeNotifier monitors the system for network changes, and notifies
22 // registered observers of those events. Observers may register on any thread, 26 // registered observers of those events. Observers may register on any thread,
23 // and will be called back on the thread from which they registered. 27 // and will be called back on the thread from which they registered.
24 // NetworkChangeNotifiers are threadsafe, though they must be created and 28 // NetworkChangeNotifiers are threadsafe, though they must be created and
25 // destroyed on the same thread. 29 // destroyed on the same thread.
26 class NET_EXPORT NetworkChangeNotifier { 30 class NET_EXPORT NetworkChangeNotifier {
27 public: 31 public:
28 // Flags which are ORed together to form |detail| in OnDNSChanged. 32 // Flags which are ORed together to form |detail| in OnDNSChanged.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static NetworkChangeNotifier* Create(); 121 static NetworkChangeNotifier* Create();
118 122
119 // Returns the connection type. 123 // Returns the connection type.
120 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the 124 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the
121 // user won't be able to connect to remote sites. However, another return 125 // user won't be able to connect to remote sites. However, another return
122 // value doesn't imply that the user will be able to connect to remote sites; 126 // value doesn't imply that the user will be able to connect to remote sites;
123 // even if some link is up, it is uncertain whether a particular connection 127 // even if some link is up, it is uncertain whether a particular connection
124 // attempt to a particular remote site will be successful. 128 // attempt to a particular remote site will be successful.
125 static ConnectionType GetConnectionType(); 129 static ConnectionType GetConnectionType();
126 130
131 #if defined(OS_LINUX)
132 // Returns the AddressTrackerLinux if present.
133 static const internal::AddressTrackerLinux* GetAddressTracker();
134 #endif
135
127 // Convenience method to determine if the user is offline. 136 // Convenience method to determine if the user is offline.
128 // Returns true if there is currently no internet connection. 137 // Returns true if there is currently no internet connection.
129 // 138 //
130 // A return value of |true| is a pretty strong indicator that the user 139 // A return value of |true| is a pretty strong indicator that the user
131 // won't be able to connect to remote sites. However, a return value of 140 // won't be able to connect to remote sites. However, a return value of
132 // |false| is inconclusive; even if some link is up, it is uncertain 141 // |false| is inconclusive; even if some link is up, it is uncertain
133 // whether a particular connection attempt to a particular remote site 142 // whether a particular connection attempt to a particular remote site
134 // will be successfully. 143 // will be successfully.
135 static bool IsOffline() { 144 static bool IsOffline() {
136 return GetConnectionType() == CONNECTION_NONE; 145 return GetConnectionType() == CONNECTION_NONE;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // http://crbug.com/116139 223 // http://crbug.com/116139
215 base::Lock watching_dns_lock_; 224 base::Lock watching_dns_lock_;
216 bool watching_dns_; 225 bool watching_dns_;
217 226
218 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 227 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
219 }; 228 };
220 229
221 } // namespace net 230 } // namespace net
222 231
223 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 232 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698