2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-03-17 03:30:58 +03:00
|
|
|
|
2012-10-10 05:40:11 +04:00
|
|
|
#ifndef __nsWifiMonitor__
|
|
|
|
#define __nsWifiMonitor__
|
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
#include "nsIWifiMonitor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-03-16 03:02:01 +04:00
|
|
|
#include "nsProxyRelease.h"
|
2009-03-17 03:30:58 +03:00
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIWifiMonitor.h"
|
2011-04-29 23:21:57 +04:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2009-03-17 03:30:58 +03:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsTArray.h"
|
2012-10-10 05:40:11 +04:00
|
|
|
#include "nsITimer.h"
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-10-10 05:40:11 +04:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2009-03-17 03:30:58 +03:00
|
|
|
|
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
extern PRLogModuleInfo *gWifiMonitorLog;
|
|
|
|
#endif
|
|
|
|
#define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
|
|
|
|
|
2011-07-27 20:26:20 +04:00
|
|
|
class nsWifiAccessPoint;
|
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
class nsWifiListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-03-16 03:02:01 +04:00
|
|
|
nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
|
2009-03-17 03:30:58 +03:00
|
|
|
{
|
|
|
|
mListener = aListener;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasSentData = false;
|
2009-03-17 03:30:58 +03:00
|
|
|
}
|
|
|
|
~nsWifiListener() {}
|
2010-03-02 08:56:06 +03:00
|
|
|
|
2013-03-16 03:02:01 +04:00
|
|
|
nsMainThreadPtrHandle<nsIWifiListener> mListener;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHasSentData;
|
2009-03-17 03:30:58 +03:00
|
|
|
};
|
|
|
|
|
2012-10-10 05:40:11 +04:00
|
|
|
#ifndef MOZ_WIDGET_GONK
|
2012-06-06 07:18:25 +04:00
|
|
|
class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
|
2009-03-17 03:30:58 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWIFIMONITOR
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsWifiMonitor();
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsWifiMonitor();
|
|
|
|
|
|
|
|
nsresult DoScan();
|
|
|
|
|
2011-07-27 20:26:20 +04:00
|
|
|
nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAccessPointsChanged);
|
2011-07-27 20:26:20 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mKeepGoing;
|
2009-03-17 03:30:58 +03:00
|
|
|
nsCOMPtr<nsIThread> mThread;
|
|
|
|
|
|
|
|
nsTArray<nsWifiListener> mListeners;
|
|
|
|
|
2011-04-29 23:21:57 +04:00
|
|
|
mozilla::ReentrantMonitor mReentrantMonitor;
|
2009-03-17 03:30:58 +03:00
|
|
|
|
|
|
|
};
|
2012-10-10 05:40:11 +04:00
|
|
|
#else
|
|
|
|
#include "nsIWifi.h"
|
|
|
|
class nsWifiMonitor MOZ_FINAL : nsIWifiMonitor, nsIWifiScanResultsReady, nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWIFIMONITOR
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_NSIWIFISCANRESULTSREADY
|
|
|
|
|
|
|
|
nsWifiMonitor();
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsWifiMonitor();
|
|
|
|
|
|
|
|
void ClearTimer() {
|
|
|
|
if (mTimer) {
|
|
|
|
mTimer->Cancel();
|
|
|
|
mTimer = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsCOMArray<nsWifiAccessPoint> mLastAccessPoints;
|
|
|
|
nsTArray<nsWifiListener> mListeners;
|
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
};
|
|
|
|
#endif
|
2009-03-17 03:30:58 +03:00
|
|
|
|
|
|
|
#endif
|