Rollup of bug 786631: Get processes with non-default permissions on the prelaunch...
[gecko.git] / netwerk / wifi / nsWifiMonitor.h
blobd5190262d6fe628fea6c37930b4cccb1e2ce267f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef __nsWifiMonitor__
6 #define __nsWifiMonitor__
8 #include "nsIWifiMonitor.h"
9 #include "nsCOMPtr.h"
10 #include "nsAutoPtr.h"
11 #include "nsIThread.h"
12 #include "nsIRunnable.h"
13 #include "nsCOMArray.h"
14 #include "nsIWifiMonitor.h"
15 #include "mozilla/ReentrantMonitor.h"
16 #include "prlog.h"
17 #include "nsIObserver.h"
18 #include "nsTArray.h"
19 #include "nsITimer.h"
20 #include "mozilla/Attributes.h"
21 #include "nsIInterfaceRequestor.h"
23 #if defined(PR_LOGGING)
24 extern PRLogModuleInfo *gWifiMonitorLog;
25 #endif
26 #define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
28 class nsWifiAccessPoint;
30 class nsWifiListener
32 public:
34 nsWifiListener(nsIWifiListener* aListener)
36 mListener = aListener;
37 mHasSentData = false;
39 ~nsWifiListener() {}
41 nsCOMPtr<nsIWifiListener> mListener;
42 bool mHasSentData;
45 #ifndef MOZ_WIDGET_GONK
46 class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
48 public:
49 NS_DECL_ISUPPORTS
50 NS_DECL_NSIWIFIMONITOR
51 NS_DECL_NSIRUNNABLE
52 NS_DECL_NSIOBSERVER
54 nsWifiMonitor();
56 private:
57 ~nsWifiMonitor();
59 nsresult DoScan();
61 #if defined(XP_MACOSX)
62 nsresult DoScanWithCoreWLAN();
63 nsresult DoScanOld();
64 #endif
66 nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
67 bool aAccessPointsChanged);
69 bool mKeepGoing;
70 nsCOMPtr<nsIThread> mThread;
72 nsTArray<nsWifiListener> mListeners;
74 mozilla::ReentrantMonitor mReentrantMonitor;
77 #else
78 #include "nsIWifi.h"
79 class nsWifiMonitor MOZ_FINAL : nsIWifiMonitor, nsIWifiScanResultsReady, nsIObserver
81 public:
82 NS_DECL_ISUPPORTS
83 NS_DECL_NSIWIFIMONITOR
84 NS_DECL_NSIOBSERVER
85 NS_DECL_NSIWIFISCANRESULTSREADY
87 nsWifiMonitor();
89 private:
90 ~nsWifiMonitor();
92 void ClearTimer() {
93 if (mTimer) {
94 mTimer->Cancel();
95 mTimer = nullptr;
98 nsCOMArray<nsWifiAccessPoint> mLastAccessPoints;
99 nsTArray<nsWifiListener> mListeners;
100 nsCOMPtr<nsITimer> mTimer;
102 #endif
104 #endif