nsNetworkLinkService.h (1468B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set et sw=2 ts=4: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #ifndef NSNETWORKLINKSERVICE_LINUX_H_ 7 #define NSNETWORKLINKSERVICE_LINUX_H_ 8 9 #include "nsINetworkLinkService.h" 10 #include "nsIObserver.h" 11 #include "../netlink/NetlinkService.h" 12 #include "mozilla/RefPtr.h" 13 #include "mozilla/Atomics.h" 14 15 class nsNetworkLinkService : public nsINetworkLinkService, 16 public nsIObserver, 17 public mozilla::net::NetlinkServiceListener { 18 public: 19 NS_DECL_THREADSAFE_ISUPPORTS 20 NS_DECL_NSINETWORKLINKSERVICE 21 NS_DECL_NSIOBSERVER 22 23 nsNetworkLinkService(); 24 nsresult Init(); 25 26 void OnNetworkChanged() override; 27 void OnNetworkIDChanged() override; 28 void OnLinkUp() override; 29 void OnLinkDown() override; 30 void OnLinkStatusKnown() override; 31 void OnDnsSuffixListUpdated() override; 32 33 private: 34 virtual ~nsNetworkLinkService() = default; 35 36 // Called when xpcom-shutdown-threads is received. 37 nsresult Shutdown(); 38 39 // Sends the network event. 40 void NotifyObservers(const char* aTopic, const char* aData); 41 42 mozilla::Atomic<bool, mozilla::Relaxed> mStatusIsKnown; 43 44 RefPtr<mozilla::net::NetlinkService> mNetlinkSvc; 45 }; 46 47 #endif /* NSNETWORKLINKSERVICE_LINUX_H_ */