2012-05-21 04:12:37 -07: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-16 17:30:58 -07:00
|
|
|
|
|
|
|
#include <mach-o/dyld.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "osx_wifi.h"
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsWifiMonitor.h"
|
|
|
|
#include "nsWifiAccessPoint.h"
|
|
|
|
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsIMutableArray.h"
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2009-09-16 13:08:15 -07:00
|
|
|
// defined in osx_corewlan.mm
|
2012-10-09 13:14:58 -07:00
|
|
|
// basically replaces accesspoints in the passed reference
|
2010-05-13 05:19:50 -07:00
|
|
|
// it lives in a separate file so that we can use objective c.
|
2009-09-16 13:08:15 -07:00
|
|
|
extern nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints);
|
|
|
|
|
2009-03-16 17:30:58 -07:00
|
|
|
nsresult
|
2012-10-09 13:14:58 -07:00
|
|
|
nsWifiMonitor::DoScan()
|
2009-09-16 13:08:15 -07:00
|
|
|
{
|
|
|
|
// Regularly get the access point data.
|
2010-03-01 21:56:06 -08:00
|
|
|
|
2009-09-16 13:08:15 -07:00
|
|
|
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
|
|
|
|
nsCOMArray<nsWifiAccessPoint> accessPoints;
|
|
|
|
|
2010-03-01 21:56:06 -08:00
|
|
|
do {
|
2009-09-16 13:08:15 -07:00
|
|
|
nsresult rv = GetAccessPointsFromWLAN(accessPoints);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
|
2009-09-16 13:08:15 -07:00
|
|
|
ReplaceArray(lastAccessPoints, accessPoints);
|
|
|
|
|
2011-07-27 09:26:20 -07:00
|
|
|
rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-09-16 13:08:15 -07:00
|
|
|
|
|
|
|
// wait for some reasonable amount of time. pref?
|
|
|
|
LOG(("waiting on monitor\n"));
|
2010-03-01 21:56:06 -08:00
|
|
|
|
2011-04-29 12:21:57 -07:00
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
2014-06-08 22:52:53 -07:00
|
|
|
mon.Wait(PR_SecondsToInterval(kDefaultWifiScanInterval));
|
2009-09-16 13:08:15 -07:00
|
|
|
}
|
2010-02-07 07:52:43 -08:00
|
|
|
while (mKeepGoing);
|
2010-03-01 21:56:06 -08:00
|
|
|
|
2009-09-16 13:08:15 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|