Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include <mach-o/dyld.h> |
michael@0 | 6 | #include <dlfcn.h> |
michael@0 | 7 | #include <unistd.h> |
michael@0 | 8 | |
michael@0 | 9 | #include "osx_wifi.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsCOMArray.h" |
michael@0 | 13 | #include "nsWifiMonitor.h" |
michael@0 | 14 | #include "nsWifiAccessPoint.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "nsServiceManagerUtils.h" |
michael@0 | 17 | #include "nsComponentManagerUtils.h" |
michael@0 | 18 | #include "nsIMutableArray.h" |
michael@0 | 19 | |
michael@0 | 20 | using namespace mozilla; |
michael@0 | 21 | |
michael@0 | 22 | // defined in osx_corewlan.mm |
michael@0 | 23 | // basically replaces accesspoints in the passed reference |
michael@0 | 24 | // it lives in a separate file so that we can use objective c. |
michael@0 | 25 | extern nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints); |
michael@0 | 26 | |
michael@0 | 27 | nsresult |
michael@0 | 28 | nsWifiMonitor::DoScan() |
michael@0 | 29 | { |
michael@0 | 30 | // Regularly get the access point data. |
michael@0 | 31 | |
michael@0 | 32 | nsCOMArray<nsWifiAccessPoint> lastAccessPoints; |
michael@0 | 33 | nsCOMArray<nsWifiAccessPoint> accessPoints; |
michael@0 | 34 | |
michael@0 | 35 | do { |
michael@0 | 36 | nsresult rv = GetAccessPointsFromWLAN(accessPoints); |
michael@0 | 37 | if (NS_FAILED(rv)) |
michael@0 | 38 | return rv; |
michael@0 | 39 | |
michael@0 | 40 | bool accessPointsChanged = !AccessPointsEqual(accessPoints, lastAccessPoints); |
michael@0 | 41 | ReplaceArray(lastAccessPoints, accessPoints); |
michael@0 | 42 | |
michael@0 | 43 | rv = CallWifiListeners(lastAccessPoints, accessPointsChanged); |
michael@0 | 44 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 45 | |
michael@0 | 46 | // wait for some reasonable amount of time. pref? |
michael@0 | 47 | LOG(("waiting on monitor\n")); |
michael@0 | 48 | |
michael@0 | 49 | ReentrantMonitorAutoEnter mon(mReentrantMonitor); |
michael@0 | 50 | mon.Wait(PR_SecondsToInterval(60)); |
michael@0 | 51 | } |
michael@0 | 52 | while (mKeepGoing); |
michael@0 | 53 | |
michael@0 | 54 | return NS_OK; |
michael@0 | 55 | } |