2012-05-21 11:12:37 +00: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 00:30:58 +00:00
|
|
|
|
2012-10-10 01:40:11 +00:00
|
|
|
#ifndef __nsWifiMonitor__
|
|
|
|
#define __nsWifiMonitor__
|
|
|
|
|
2009-03-17 00:30:58 +00:00
|
|
|
#include "nsIWifiMonitor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-03-15 23:02:01 +00:00
|
|
|
#include "nsProxyRelease.h"
|
2009-03-17 00:30:58 +00:00
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIWifiMonitor.h"
|
2011-04-29 19:21:57 +00:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2009-03-17 00:30:58 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsTArray.h"
|
2012-10-10 01:40:11 +00:00
|
|
|
#include "nsITimer.h"
|
2012-06-06 03:18:25 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-10-10 01:40:11 +00:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2009-03-17 00:30:58 +00:00
|
|
|
|
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
extern PRLogModuleInfo *gWifiMonitorLog;
|
|
|
|
#endif
|
|
|
|
#define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
|
|
|
|
|
2011-07-27 16:26:20 +00:00
|
|
|
class nsWifiAccessPoint;
|
|
|
|
|
2009-03-17 00:30:58 +00:00
|
|
|
class nsWifiListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-03-15 23:02:01 +00:00
|
|
|
nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
|
2009-03-17 00:30:58 +00:00
|
|
|
{
|
|
|
|
mListener = aListener;
|
2011-10-17 14:59:28 +00:00
|
|
|
mHasSentData = false;
|
2009-03-17 00:30:58 +00:00
|
|
|
}
|
|
|
|
~nsWifiListener() {}
|
2010-03-02 05:56:06 +00:00
|
|
|
|
2013-03-15 23:02:01 +00:00
|
|
|
nsMainThreadPtrHandle<nsIWifiListener> mListener;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mHasSentData;
|
2009-03-17 00:30:58 +00:00
|
|
|
};
|
|
|
|
|
2012-10-10 01:40:11 +00:00
|
|
|
#ifndef MOZ_WIDGET_GONK
|
2012-06-06 03:18:25 +00:00
|
|
|
class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
|
2009-03-17 00:30:58 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWIFIMONITOR
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsWifiMonitor();
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsWifiMonitor();
|
|
|
|
|
|
|
|
nsresult DoScan();
|
|
|
|
|
2011-07-27 16:26:20 +00:00
|
|
|
nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAccessPointsChanged);
|
2011-07-27 16:26:20 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mKeepGoing;
|
2009-03-17 00:30:58 +00:00
|
|
|
nsCOMPtr<nsIThread> mThread;
|
|
|
|
|
|
|
|
nsTArray<nsWifiListener> mListeners;
|
|
|
|
|
2011-04-29 19:21:57 +00:00
|
|
|
mozilla::ReentrantMonitor mReentrantMonitor;
|
2009-03-17 00:30:58 +00:00
|
|
|
|
|
|
|
};
|
2012-10-10 01:40:11 +00: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 00:30:58 +00:00
|
|
|
|
|
|
|
#endif
|