Bug 1568126 - Part 1: Use the contextual WalkerFront in _hideHighlighterIfDeadNode...
[gecko.git] / netwerk / wifi / nsWifiScannerMac.cpp
blob051eab93c1df1bda37e63eafdeb3b63a3e7616d9
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(
26 nsCOMArray<nsWifiAccessPoint>& accessPoints);
28 nsresult nsWifiMonitor::DoScan() {
29 // Regularly get the access point data.
31 nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
32 nsCOMArray<nsWifiAccessPoint> accessPoints;
34 do {
35 nsresult rv = GetAccessPointsFromWLAN(accessPoints);
36 if (NS_FAILED(rv)) return rv;
38 bool accessPointsChanged =
39 !AccessPointsEqual(accessPoints, lastAccessPoints);
40 ReplaceArray(lastAccessPoints, accessPoints);
42 rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
43 NS_ENSURE_SUCCESS(rv, rv);
45 // wait for some reasonable amount of time. pref?
46 LOG(("waiting on monitor\n"));
48 ReentrantMonitorAutoEnter mon(mReentrantMonitor);
49 mon.Wait(PR_SecondsToInterval(kDefaultWifiScanInterval));
50 } while (mKeepGoing);
52 return NS_OK;