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

Unified Diff: net/base/network_change_notifier_linux.cc

Issue 9147026: API for connection type (Ethernet/WIFI/WWAN ...) in NetworkChangeNotifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: net/base/network_change_notifier_linux.cc
diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc
index 99167dc93610247b38ac3c6f33f3b0d3e523c896..59db24571a1dbf921543622d5859170da48faf15 100644
--- a/net/base/network_change_notifier_linux.cc
+++ b/net/base/network_change_notifier_linux.cc
@@ -82,9 +82,9 @@ class NetworkManagerApi {
// Must be called by the helper thread's CleanUp() method.
void CleanUp();
- // Implementation of NetworkChangeNotifierLinux::IsCurrentlyOffline().
+ // Implementation of NetworkChangeNotifierLinux::GetCurrentConnectionState().
// Safe to call from any thread, but will block until Init() has completed.
- bool IsCurrentlyOffline();
+ NetworkChangeNotifier::ConnectionState GetCurrentConnectionState();
private:
// Callbacks for D-Bus API.
@@ -230,10 +230,12 @@ bool NetworkManagerApi::StateIsOffline(uint32 state) {
}
}
-bool NetworkManagerApi::IsCurrentlyOffline() {
+NetworkChangeNotifier::ConnectionState
+NetworkManagerApi::GetCurrentConnectionState() {
offline_state_initialized_.Wait();
base::AutoLock lock(is_offline_lock_);
- return is_offline_;
+ return is_offline_ ? NetworkChangeNotifier::NONE :
+ NetworkChangeNotifier::ETHERNET;
joth 2012/01/10 10:48:35 again, seems like UNKNOWN would be a better fit?
}
class DNSWatchDelegate : public FilePathWatcher::Delegate {
@@ -270,10 +272,10 @@ class NetworkChangeNotifierLinux::Thread
virtual void OnFileCanReadWithoutBlocking(int fd);
virtual void OnFileCanWriteWithoutBlocking(int /* fd */);
- // Plumbing for NetworkChangeNotifier::IsCurrentlyOffline.
+ // Plumbing for NetworkChangeNotifier::GetCurrentConnectionState.
// Safe to call from any thread.
- bool IsCurrentlyOffline() {
- return network_manager_api_.IsCurrentlyOffline();
+ NetworkChangeNotifier::ConnectionState GetCurrentConnectionState() {
+ return network_manager_api_.GetCurrentConnectionState();
}
protected:
@@ -290,8 +292,8 @@ class NetworkChangeNotifierLinux::Thread
NetworkChangeNotifier::NotifyObserversOfDNSChange();
}
- static void NotifyObserversOfOnlineStateChange() {
- NetworkChangeNotifier::NotifyObserversOfOnlineStateChange();
+ static void NotifyObserversOfConnectionStateChange() {
+ NetworkChangeNotifier::NotifyObserversOfConnectionStateChange();
}
// Starts listening for netlink messages. Also handles the messages if there
@@ -315,7 +317,7 @@ class NetworkChangeNotifierLinux::Thread
scoped_ptr<base::files::FilePathWatcher> hosts_file_watcher_;
scoped_refptr<DNSWatchDelegate> file_watcher_delegate_;
- // Used to detect online/offline state changes.
+ // Used to detect connection state changes.
NetworkManagerApi network_manager_api_;
DISALLOW_COPY_AND_ASSIGN(Thread);
@@ -327,7 +329,7 @@ NetworkChangeNotifierLinux::Thread::Thread(dbus::Bus* bus)
ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)),
network_manager_api_(
base::Bind(&NetworkChangeNotifierLinux::Thread
- ::NotifyObserversOfOnlineStateChange),
+ ::NotifyObserversOfConnectionStateChange),
bus) {
}
@@ -459,8 +461,9 @@ NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() {
notifier_thread_->Stop();
}
-bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const {
- return notifier_thread_->IsCurrentlyOffline();
+NetworkChangeNotifier::ConnectionState
+NetworkChangeNotifierMac::GetCurrentConnectionState() const {
+ return notifier_thread_->GetCurrentConnectionState();
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698