OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // For OSX 10.5 we use the system API function WirelessScanSplit. This function | 5 // For OSX 10.5 we use the system API function WirelessScanSplit. This function |
6 // is not documented or included in the SDK, so we use a reverse-engineered | 6 // is not documented or included in the SDK, so we use a reverse-engineered |
7 // header, osx_wifi_.h. This file is taken from the iStumbler project | 7 // header, osx_wifi_.h. This file is taken from the iStumbler project |
8 // (http://www.istumbler.net). | 8 // (http://www.istumbler.net). |
9 | 9 |
10 #include "chrome/browser/geolocation/wifi_data_provider_mac.h" | 10 #include "chrome/browser/geolocation/wifi_data_provider_mac.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 const int kNoChangePollingInterval = 300000; // 5 mins | 21 const int kNoChangePollingInterval = 300000; // 5 mins |
22 const int kTwoNoChangePollingInterval = 600000; // 10 mins | 22 const int kTwoNoChangePollingInterval = 600000; // 10 mins |
23 | 23 |
24 // Provides the wifi API binding for use when running on OSX 10.5 machines using | 24 // Provides the wifi API binding for use when running on OSX 10.5 machines using |
25 // the Apple80211 framework. | 25 // the Apple80211 framework. |
26 class Apple80211Api : public WifiDataProviderCommon::WlanApiInterface { | 26 class Apple80211Api : public WifiDataProviderCommon::WlanApiInterface { |
27 public: | 27 public: |
28 Apple80211Api(); | 28 Apple80211Api(); |
29 virtual ~Apple80211Api(); | 29 virtual ~Apple80211Api(); |
30 | 30 |
| 31 // Must be called before any other interface method. Will return false if the |
| 32 // Apple80211 framework cannot be initialized (e.g. running on post-10.5 OSX), |
| 33 // in which case no other method may be called. |
31 bool Init(); | 34 bool Init(); |
32 | 35 |
33 // WlanApiInterface | 36 // WlanApiInterface |
34 virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data); | 37 virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data); |
35 | 38 |
36 private: | 39 private: |
37 // Handle, context and function pointers for Apple80211 library. | 40 // Handle, context and function pointers for Apple80211 library. |
38 void* apple_80211_library_; | 41 void* apple_80211_library_; |
39 WirelessContext* wifi_context_; | 42 WirelessContext* wifi_context_; |
40 WirelessAttachFunction WirelessAttach_function_; | 43 WirelessAttachFunction WirelessAttach_function_; |
41 WirelessScanSplitFunction WirelessScanSplit_function_; | 44 WirelessScanSplitFunction WirelessScanSplit_function_; |
42 WirelessDetachFunction WirelessDetach_function_; | 45 WirelessDetachFunction WirelessDetach_function_; |
43 | 46 |
44 WifiData wifi_data_; | 47 WifiData wifi_data_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(Apple80211Api); |
45 }; | 50 }; |
46 | 51 |
47 Apple80211Api::Apple80211Api() | 52 Apple80211Api::Apple80211Api() |
48 : apple_80211_library_(NULL), wifi_context_(NULL), | 53 : apple_80211_library_(NULL), wifi_context_(NULL), |
49 WirelessAttach_function_(NULL), WirelessScanSplit_function_(NULL), | 54 WirelessAttach_function_(NULL), WirelessScanSplit_function_(NULL), |
50 WirelessDetach_function_(NULL) { | 55 WirelessDetach_function_(NULL) { |
51 } | 56 } |
52 | 57 |
53 Apple80211Api::~Apple80211Api() { | 58 Apple80211Api::~Apple80211Api() { |
54 if (WirelessDetach_function_) | 59 if (WirelessDetach_function_) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 173 |
169 DLOG(INFO) << "MacWifiDataProvider : failed to initialize any wlan api"; | 174 DLOG(INFO) << "MacWifiDataProvider : failed to initialize any wlan api"; |
170 return NULL; | 175 return NULL; |
171 } | 176 } |
172 | 177 |
173 PollingPolicyInterface* MacWifiDataProvider::NewPollingPolicy() { | 178 PollingPolicyInterface* MacWifiDataProvider::NewPollingPolicy() { |
174 return new GenericPollingPolicy<kDefaultPollingInterval, | 179 return new GenericPollingPolicy<kDefaultPollingInterval, |
175 kNoChangePollingInterval, | 180 kNoChangePollingInterval, |
176 kTwoNoChangePollingInterval>; | 181 kTwoNoChangePollingInterval>; |
177 } | 182 } |
OLD | NEW |