Bumping manifests a=b2g-bump
[gecko.git] / netwerk / wifi / nsWifiScannerMac.cpp
blobb8ca682c213fe669af81c37583aa54cf44ebba91
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <mach-o/dyld.h>
6 #include <dlfcn.h>
7 #include <unistd.h>
9 #include "osx_wifi.h"
11 #include "nsAutoPtr.h"
12 #include "nsCOMArray.h"
13 #include "nsWifiMonitor.h"
14 #include "nsWifiAccessPoint.h"
16 #include "nsServiceManagerUtils.h"
17 #include "nsComponentManagerUtils.h"
18 #include "nsIMutableArray.h"
20 using namespace mozilla;
22 // defined in osx_corewlan.mm
23 // basically replaces accesspoints in the passed reference
24 // it lives in a separate file so that we can use objective c.
25 extern nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints);
27 nsresult
28 nsWifiMonitor::DoScan()
30 // Regularly get the access point data.
32 nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
33 nsCOMArray<nsWifiAccessPoint> accessPoints;
35 do {
36 nsresult rv = GetAccessPointsFromWLAN(accessPoints);
37 if (NS_FAILED(rv))
38 return rv;
40 bool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints);
41 ReplaceArray(lastAccessPoints, accessPoints);
43 rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
44 NS_ENSURE_SUCCESS(rv, rv);
46 // wait for some reasonable amount of time. pref?
47 LOG(("waiting on monitor\n"));
49 ReentrantMonitorAutoEnter mon(mReentrantMonitor);
50 mon.Wait(PR_SecondsToInterval(kDefaultWifiScanInterval));
52 while (mKeepGoing);
54 return NS_OK;