Backed out changesets d8fd745a0095 and 30b7ebdf5c99 (bug 924480) for robocop-3 failures.
[gecko.git] / netwerk / wifi / nsWifiMonitor.h
blob3121eb284921a1222129dc16deebc09a323afeb6
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 "nsProxyRelease.h"
12 #include "nsIThread.h"
13 #include "nsIRunnable.h"
14 #include "nsCOMArray.h"
15 #include "nsIWifiListener.h"
16 #include "mozilla/ReentrantMonitor.h"
17 #include "prlog.h"
18 #include "nsIObserver.h"
19 #include "nsTArray.h"
20 #include "nsITimer.h"
21 #include "mozilla/Attributes.h"
22 #include "nsIInterfaceRequestor.h"
24 #if defined(PR_LOGGING)
25 extern PRLogModuleInfo *gWifiMonitorLog;
26 #endif
27 #define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
29 class nsWifiAccessPoint;
31 class nsWifiListener
33 public:
35 nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
37 mListener = aListener;
38 mHasSentData = false;
40 ~nsWifiListener() {}
42 nsMainThreadPtrHandle<nsIWifiListener> mListener;
43 bool mHasSentData;
46 #ifndef MOZ_WIDGET_GONK
47 class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
49 public:
50 NS_DECL_THREADSAFE_ISUPPORTS
51 NS_DECL_NSIWIFIMONITOR
52 NS_DECL_NSIRUNNABLE
53 NS_DECL_NSIOBSERVER
55 nsWifiMonitor();
57 private:
58 ~nsWifiMonitor();
60 nsresult DoScan();
62 nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
63 bool aAccessPointsChanged);
65 bool mKeepGoing;
66 nsCOMPtr<nsIThread> mThread;
68 nsTArray<nsWifiListener> mListeners;
70 mozilla::ReentrantMonitor mReentrantMonitor;
73 #else
74 #include "nsIWifi.h"
75 class nsWifiMonitor MOZ_FINAL : nsIWifiMonitor, nsIWifiScanResultsReady, nsIObserver
77 public:
78 NS_DECL_ISUPPORTS
79 NS_DECL_NSIWIFIMONITOR
80 NS_DECL_NSIOBSERVER
81 NS_DECL_NSIWIFISCANRESULTSREADY
83 nsWifiMonitor();
85 private:
86 ~nsWifiMonitor();
88 void ClearTimer() {
89 if (mTimer) {
90 mTimer->Cancel();
91 mTimer = nullptr;
94 nsCOMArray<nsWifiAccessPoint> mLastAccessPoints;
95 nsTArray<nsWifiListener> mListeners;
96 nsCOMPtr<nsITimer> mTimer;
98 #endif
100 #endif