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
|
|
|
|
|
|
|
#include "nsIWifiMonitor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#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-06-06 03:18:25 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-03-17 00:30:58 +00:00
|
|
|
|
|
|
|
#ifndef __nsWifiMonitor__
|
|
|
|
#define __nsWifiMonitor__
|
|
|
|
|
|
|
|
#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:
|
|
|
|
|
|
|
|
nsWifiListener(nsIWifiListener* aListener)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2009-03-17 00:30:58 +00:00
|
|
|
nsCOMPtr<nsIWifiListener> mListener;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mHasSentData;
|
2009-03-17 00:30:58 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|