OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implements a WLAN API binding for CoreWLAN, as available on OSX 10.6 | 5 // Implements a WLAN API binding for CoreWLAN, as available on OSX 10.6 |
6 | 6 |
7 #include "content/browser/geolocation/wifi_data_provider_mac.h" | 7 #include "content/browser/geolocation/wifi_data_provider_mac.h" |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| 11 #include <stdint.h> |
11 | 12 |
12 #include "base/mac/scoped_nsautorelease_pool.h" | 13 #include "base/mac/scoped_nsautorelease_pool.h" |
13 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/macros.h" |
14 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
15 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
16 | 18 |
17 // Define a subset of the CoreWLAN interfaces we require. We can't depend on | 19 // Define a subset of the CoreWLAN interfaces we require. We can't depend on |
18 // CoreWLAN.h existing as we need to build on 10.5 SDKs. We can't just send | 20 // CoreWLAN.h existing as we need to build on 10.5 SDKs. We can't just send |
19 // messages to an untyped id due to the build treating warnings as errors, | 21 // messages to an untyped id due to the build treating warnings as errors, |
20 // hence the reason we need class definitions. | 22 // hence the reason we need class definitions. |
21 // TODO(joth): When we build all 10.6 code exclusively 10.6 SDK (or later) | 23 // TODO(joth): When we build all 10.6 code exclusively 10.6 SDK (or later) |
22 // tidy this up to use the framework directly. See http://crbug.com/37703 | 24 // tidy this up to use the framework directly. See http://crbug.com/37703 |
23 | 25 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 base::TimeDelta::FromMinutes(1), | 147 base::TimeDelta::FromMinutes(1), |
146 100); | 148 100); |
147 | 149 |
148 DVLOG(1) << interface_name << ": found " << count << " wifi APs"; | 150 DVLOG(1) << interface_name << ": found " << count << " wifi APs"; |
149 | 151 |
150 for (CWNetwork* network in scan) { | 152 for (CWNetwork* network in scan) { |
151 DCHECK(network); | 153 DCHECK(network); |
152 AccessPointData access_point_data; | 154 AccessPointData access_point_data; |
153 NSData* mac = [network bssidData]; | 155 NSData* mac = [network bssidData]; |
154 DCHECK([mac length] == 6); | 156 DCHECK([mac length] == 6); |
155 access_point_data.mac_address = MacAddressAsString16( | 157 access_point_data.mac_address = |
156 static_cast<const uint8*>([mac bytes])); | 158 MacAddressAsString16(static_cast<const uint8_t*>([mac bytes])); |
157 access_point_data.radio_signal_strength = [[network rssi] intValue]; | 159 access_point_data.radio_signal_strength = [[network rssi] intValue]; |
158 access_point_data.channel = [[network channel] intValue]; | 160 access_point_data.channel = [[network channel] intValue]; |
159 access_point_data.signal_to_noise = | 161 access_point_data.signal_to_noise = |
160 access_point_data.radio_signal_strength - [[network noise] intValue]; | 162 access_point_data.radio_signal_strength - [[network noise] intValue]; |
161 access_point_data.ssid = base::SysNSStringToUTF16([network ssid]); | 163 access_point_data.ssid = base::SysNSStringToUTF16([network ssid]); |
162 data->insert(access_point_data); | 164 data->insert(access_point_data); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 UMA_HISTOGRAM_CUSTOM_COUNTS( | 168 UMA_HISTOGRAM_CUSTOM_COUNTS( |
(...skipping 11 matching lines...) Expand all Loading... |
178 | 180 |
179 WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() { | 181 WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() { |
180 scoped_ptr<CoreWlanApi> self(new CoreWlanApi); | 182 scoped_ptr<CoreWlanApi> self(new CoreWlanApi); |
181 if (self->Init()) | 183 if (self->Init()) |
182 return self.release(); | 184 return self.release(); |
183 | 185 |
184 return NULL; | 186 return NULL; |
185 } | 187 } |
186 | 188 |
187 } // namespace content | 189 } // namespace content |
OLD | NEW |