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 NSNOTIFYADDRLISTENER_H_
7 #define NSNOTIFYADDRLISTENER_H_
12 #include "nsINetworkLinkService.h"
13 #include "nsIRunnable.h"
14 #include "nsIObserver.h"
17 #include "nsThreadUtils.h"
18 #include "nsThreadPool.h"
20 #include "mozilla/Atomics.h"
21 #include "mozilla/TimeStamp.h"
22 #include "mozilla/Mutex.h"
23 #include "mozilla/SHA1.h"
24 #include "mozilla/net/DNS.h"
28 class nsNotifyAddrListener
: public nsINetworkLinkService
,
31 virtual ~nsNotifyAddrListener();
34 NS_DECL_THREADSAFE_ISUPPORTS
35 NS_DECL_NSINETWORKLINKSERVICE
39 nsNotifyAddrListener();
42 void CheckLinkStatus(void);
43 static void HashSortedNetworkIds(const std::vector
<GUID
> nwGUIDS
,
44 mozilla::SHA1Sum
& sha1
);
51 nsresult
Shutdown(void);
52 nsresult
NotifyObservers(const char* aTopic
, const char* aData
);
54 DWORD
CheckAdaptersAddresses(void);
56 // This threadpool only ever holds 1 thread. It is a threadpool and not a
57 // regular thread so that we may call shutdownWithTimeout on it.
58 nsCOMPtr
<nsIThreadPool
> mThread
;
61 // Returns the new timeout period for coalescing (or INFINITE)
62 DWORD
nextCoalesceWaitTime();
64 // Called for every detected network change
65 nsresult
NetworkChanged();
67 // Figure out the current network identification
68 void calculateNetworkId(void);
69 bool findMac(char* gateway
);
71 mozilla::Mutex mMutex
;
73 nsTArray
<nsCString
> mDnsSuffixList
;
74 nsTArray
<mozilla::net::NetAddr
> mDNSResolvers
;
78 // set true when mCheckEvent means shutdown
79 mozilla::Atomic
<bool> mShutdown
;
81 // Contains a set of flags that codify the reasons for which
82 // the platform indicates DNS should be used instead of TRR.
83 mozilla::Atomic
<uint32_t, mozilla::Relaxed
> mPlatformDNSIndications
;
85 // This is a checksum of various meta data for all network interfaces
86 // considered UP at last check.
87 ULONG mIPInterfaceChecksum
;
89 // start time of the checking
90 mozilla::TimeStamp mStartTime
;
92 // Flag set while coalescing change events
93 bool mCoalescingActive
;
95 // Time stamp for first event during coalescing
96 mozilla::TimeStamp mChangeTime
;
99 #endif /* NSNOTIFYADDRLISTENER_H_ */