netwerk/wifi/nsWifiMonitor.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef __nsWifiMonitor__
michael@0 6 #define __nsWifiMonitor__
michael@0 7
michael@0 8 #include "nsIWifiMonitor.h"
michael@0 9 #include "nsCOMPtr.h"
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "nsProxyRelease.h"
michael@0 12 #include "nsIThread.h"
michael@0 13 #include "nsIRunnable.h"
michael@0 14 #include "nsCOMArray.h"
michael@0 15 #include "nsIWifiListener.h"
michael@0 16 #include "mozilla/ReentrantMonitor.h"
michael@0 17 #include "prlog.h"
michael@0 18 #include "nsIObserver.h"
michael@0 19 #include "nsTArray.h"
michael@0 20 #include "nsITimer.h"
michael@0 21 #include "mozilla/Attributes.h"
michael@0 22 #include "nsIInterfaceRequestor.h"
michael@0 23
michael@0 24 #if defined(PR_LOGGING)
michael@0 25 extern PRLogModuleInfo *gWifiMonitorLog;
michael@0 26 #endif
michael@0 27 #define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
michael@0 28
michael@0 29 class nsWifiAccessPoint;
michael@0 30
michael@0 31 class nsWifiListener
michael@0 32 {
michael@0 33 public:
michael@0 34
michael@0 35 nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
michael@0 36 {
michael@0 37 mListener = aListener;
michael@0 38 mHasSentData = false;
michael@0 39 }
michael@0 40 ~nsWifiListener() {}
michael@0 41
michael@0 42 nsMainThreadPtrHandle<nsIWifiListener> mListener;
michael@0 43 bool mHasSentData;
michael@0 44 };
michael@0 45
michael@0 46 #ifndef MOZ_WIDGET_GONK
michael@0 47 class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
michael@0 48 {
michael@0 49 public:
michael@0 50 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 51 NS_DECL_NSIWIFIMONITOR
michael@0 52 NS_DECL_NSIRUNNABLE
michael@0 53 NS_DECL_NSIOBSERVER
michael@0 54
michael@0 55 nsWifiMonitor();
michael@0 56
michael@0 57 private:
michael@0 58 ~nsWifiMonitor();
michael@0 59
michael@0 60 nsresult DoScan();
michael@0 61
michael@0 62 nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
michael@0 63 bool aAccessPointsChanged);
michael@0 64
michael@0 65 bool mKeepGoing;
michael@0 66 nsCOMPtr<nsIThread> mThread;
michael@0 67
michael@0 68 nsTArray<nsWifiListener> mListeners;
michael@0 69
michael@0 70 mozilla::ReentrantMonitor mReentrantMonitor;
michael@0 71
michael@0 72 };
michael@0 73 #else
michael@0 74 #include "nsIWifi.h"
michael@0 75 class nsWifiMonitor MOZ_FINAL : nsIWifiMonitor, nsIWifiScanResultsReady, nsIObserver
michael@0 76 {
michael@0 77 public:
michael@0 78 NS_DECL_ISUPPORTS
michael@0 79 NS_DECL_NSIWIFIMONITOR
michael@0 80 NS_DECL_NSIOBSERVER
michael@0 81 NS_DECL_NSIWIFISCANRESULTSREADY
michael@0 82
michael@0 83 nsWifiMonitor();
michael@0 84
michael@0 85 private:
michael@0 86 ~nsWifiMonitor();
michael@0 87
michael@0 88 void ClearTimer() {
michael@0 89 if (mTimer) {
michael@0 90 mTimer->Cancel();
michael@0 91 mTimer = nullptr;
michael@0 92 }
michael@0 93 }
michael@0 94 nsCOMArray<nsWifiAccessPoint> mLastAccessPoints;
michael@0 95 nsTArray<nsWifiListener> mListeners;
michael@0 96 nsCOMPtr<nsITimer> mTimer;
michael@0 97 };
michael@0 98 #endif
michael@0 99
michael@0 100 #endif

mercurial