LCOV - code coverage report
Current view: top level - netwerk/system/linux - nsNotifyAddrListener_Linux.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* vim:set et sw=4 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 NSNOTIFYADDRLISTENER_LINUX_H_
       7             : #define NSNOTIFYADDRLISTENER_LINUX_H_
       8             : 
       9             : #include <sys/socket.h>
      10             : #include <stdlib.h>
      11             : #include <stdio.h>
      12             : #include <string.h>
      13             : #include <linux/netlink.h>
      14             : #include <linux/rtnetlink.h>
      15             : #include <arpa/inet.h>
      16             : #include <unistd.h>
      17             : 
      18             : #include "nsINetworkLinkService.h"
      19             : #include "nsIRunnable.h"
      20             : #include "nsIObserver.h"
      21             : #include "nsThreadUtils.h"
      22             : #include "nsCOMPtr.h"
      23             : #include "mozilla/Atomics.h"
      24             : #include "mozilla/TimeStamp.h"
      25             : #include "nsITimer.h"
      26             : #include "nsClassHashtable.h"
      27             : 
      28             : class nsNotifyAddrListener : public nsINetworkLinkService,
      29             :                              public nsIRunnable,
      30             :                              public nsIObserver
      31             : {
      32             :     virtual ~nsNotifyAddrListener();
      33             : 
      34             : public:
      35             :     NS_DECL_THREADSAFE_ISUPPORTS
      36             :     NS_DECL_NSINETWORKLINKSERVICE
      37             :     NS_DECL_NSIRUNNABLE
      38             :     NS_DECL_NSIOBSERVER
      39             : 
      40             :     nsNotifyAddrListener();
      41             :     nsresult Init(void);
      42             : 
      43             : private:
      44           0 :     class ChangeEvent : public mozilla::Runnable {
      45             :     public:
      46             :         NS_DECL_NSIRUNNABLE
      47           0 :         ChangeEvent(nsINetworkLinkService* aService, const char* aEventID)
      48           0 :           : mozilla::Runnable("nsNotifyAddrListener::ChangeEvent")
      49             :           , mService(aService)
      50           0 :           , mEventID(aEventID)
      51             :         {
      52           0 :         }
      53             :     private:
      54             :         nsCOMPtr<nsINetworkLinkService> mService;
      55             :         const char *mEventID;
      56             :     };
      57             : 
      58             :     // Called when xpcom-shutdown-threads is received.
      59             :     nsresult Shutdown(void);
      60             : 
      61             :     // Called when a network change was detected
      62             :     nsresult NetworkChanged();
      63             : 
      64             :     // Sends the network event.
      65             :     nsresult SendEvent(const char *aEventID);
      66             : 
      67             :     // Figure out the current "network identification"
      68             :     void calculateNetworkId(void);
      69             :     nsCString mNetworkId;
      70             : 
      71             :     // Checks if there's a network "link"
      72             :     void checkLink(void);
      73             : 
      74             :     // Deals with incoming NETLINK messages.
      75             :     void OnNetlinkMessage(int NetlinkSocket);
      76             : 
      77             :     nsCOMPtr<nsIThread> mThread;
      78             : 
      79             :     // The network is up.
      80             :     bool mLinkUp;
      81             : 
      82             :     // The network's up/down status is known.
      83             :     bool mStatusKnown;
      84             : 
      85             :     // A pipe to signal shutdown with.
      86             :     int mShutdownPipe[2];
      87             : 
      88             :     // Network changed events are enabled
      89             :     bool mAllowChangedEvent;
      90             : 
      91             :     // Flag set while coalescing change events
      92             :     bool mCoalescingActive;
      93             : 
      94             :     // Time stamp for first event during coalescing
      95             :     mozilla::TimeStamp mChangeTime;
      96             : 
      97             :     // Seen Ip addresses. For Ipv6 addresses some time router renews their
      98             :     // lifetime and we should not detect this as a network link change, so we
      99             :     // keep info about all seen addresses.
     100             :      nsClassHashtable<nsCStringHashKey, struct ifaddrmsg> mAddressInfo;
     101             :  };
     102             : 
     103             : #endif /* NSNOTIFYADDRLISTENER_LINUX_H_ */

Generated by: LCOV version 1.13