Bug 1708422: part 8) Move `mozInlineSpellChecker::CheckWordsAndAddRangesForMisspellin...
[gecko.git] / netwerk / system / win32 / nsNotifyAddrListener.h
blob3406dd3b94ac3331ebbe3a92afee82e710f1af73
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_
9 #include <windows.h>
10 #include <winsock2.h>
11 #include <iptypes.h>
12 #include "nsINetworkLinkService.h"
13 #include "nsIRunnable.h"
14 #include "nsIObserver.h"
15 #include "nsString.h"
16 #include "nsTArray.h"
17 #include "nsThreadUtils.h"
18 #include "nsThreadPool.h"
19 #include "nsCOMPtr.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"
26 class nsIThreadPool;
28 class nsNotifyAddrListener : public nsINetworkLinkService,
29 public nsIRunnable,
30 public nsIObserver {
31 virtual ~nsNotifyAddrListener();
33 public:
34 NS_DECL_THREADSAFE_ISUPPORTS
35 NS_DECL_NSINETWORKLINKSERVICE
36 NS_DECL_NSIRUNNABLE
37 NS_DECL_NSIOBSERVER
39 nsNotifyAddrListener();
41 nsresult Init(void);
42 void CheckLinkStatus(void);
43 static void HashSortedNetworkIds(const std::vector<GUID> nwGUIDS,
44 mozilla::SHA1Sum& sha1);
46 protected:
47 bool mLinkUp;
48 bool mStatusKnown;
49 bool mCheckAttempted;
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;
60 private:
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;
72 nsCString mNetworkId;
73 nsTArray<nsCString> mDnsSuffixList;
74 nsTArray<mozilla::net::NetAddr> mDNSResolvers;
76 HANDLE mCheckEvent;
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_ */