| 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 // Windows Vista uses the Native Wifi (WLAN) API for accessing WiFi cards. See | 5 // Windows Vista uses the Native Wifi (WLAN) API for accessing WiFi cards. See |
| 6 // http://msdn.microsoft.com/en-us/library/ms705945(VS.85).aspx. Windows XP | 6 // http://msdn.microsoft.com/en-us/library/ms705945(VS.85).aspx. Windows XP |
| 7 // Service Pack 3 (and Windows XP Service Pack 2, if upgraded with a hot fix) | 7 // Service Pack 3 (and Windows XP Service Pack 2, if upgraded with a hot fix) |
| 8 // also support a limited version of the WLAN API. See | 8 // also support a limited version of the WLAN API. See |
| 9 // http://msdn.microsoft.com/en-us/library/bb204766.aspx. The WLAN API uses | 9 // http://msdn.microsoft.com/en-us/library/bb204766.aspx. The WLAN API uses |
| 10 // wlanapi.h, which is not part of the SDK used by Gears, so is replicated | 10 // wlanapi.h, which is not part of the SDK used by Gears, so is replicated |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Taken from ndis.h for WinCE. | 36 // Taken from ndis.h for WinCE. |
| 37 #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L) | 37 #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L) |
| 38 #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L) | 38 #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L) |
| 39 | 39 |
| 40 namespace content { | 40 namespace content { |
| 41 namespace { | 41 namespace { |
| 42 // The limits on the size of the buffer used for the OID query. | 42 // The limits on the size of the buffer used for the OID query. |
| 43 const int kInitialBufferSize = 2 << 12; // Good for about 50 APs. | 43 const int kInitialBufferSize = 2 << 12; // Good for about 50 APs. |
| 44 const int kMaximumBufferSize = 2 << 20; // 2MB | 44 const int kMaximumBufferSize = 2 << 20; // 2MB |
| 45 | 45 |
| 46 // Length for generic string buffers passed to Win32 APIs. | 46 // Length for generic string buffers passed to Windows APIs. |
| 47 const int kStringLength = 512; | 47 const int kStringLength = 512; |
| 48 | 48 |
| 49 // The time periods, in milliseconds, between successive polls of the wifi data. | 49 // The time periods, in milliseconds, between successive polls of the wifi data. |
| 50 const int kDefaultPollingInterval = 10000; // 10s | 50 const int kDefaultPollingInterval = 10000; // 10s |
| 51 const int kNoChangePollingInterval = 120000; // 2 mins | 51 const int kNoChangePollingInterval = 120000; // 2 mins |
| 52 const int kTwoNoChangePollingInterval = 600000; // 10 mins | 52 const int kTwoNoChangePollingInterval = 600000; // 10 mins |
| 53 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s | 53 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s |
| 54 | 54 |
| 55 // WlanOpenHandle | 55 // WlanOpenHandle |
| 56 typedef DWORD (WINAPI* WlanOpenHandleFunction)(DWORD dwClientVersion, | 56 typedef DWORD (WINAPI* WlanOpenHandleFunction)(DWORD dwClientVersion, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Remembers scan result buffer size across calls. | 140 // Remembers scan result buffer size across calls. |
| 141 int oid_buffer_size_; | 141 int oid_buffer_size_; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // Extracts data for an access point and converts to Gears format. | 144 // Extracts data for an access point and converts to Gears format. |
| 145 bool GetNetworkData(const WLAN_BSS_ENTRY& bss_entry, | 145 bool GetNetworkData(const WLAN_BSS_ENTRY& bss_entry, |
| 146 AccessPointData* access_point_data); | 146 AccessPointData* access_point_data); |
| 147 bool UndefineDosDevice(const base::string16& device_name); | 147 bool UndefineDosDevice(const base::string16& device_name); |
| 148 bool DefineDosDeviceIfNotExists(const base::string16& device_name); | 148 bool DefineDosDeviceIfNotExists(const base::string16& device_name); |
| 149 HANDLE GetFileHandle(const base::string16& device_name); | 149 HANDLE GetFileHandle(const base::string16& device_name); |
| 150 // Makes the OID query and returns a Win32 error code. | 150 // Makes the OID query and returns a Windows API error code. |
| 151 int PerformQuery(HANDLE adapter_handle, | 151 int PerformQuery(HANDLE adapter_handle, |
| 152 BYTE* buffer, | 152 BYTE* buffer, |
| 153 DWORD buffer_size, | 153 DWORD buffer_size, |
| 154 DWORD* bytes_out); | 154 DWORD* bytes_out); |
| 155 bool ResizeBuffer(int requested_size, | 155 bool ResizeBuffer(int requested_size, |
| 156 scoped_ptr<BYTE, base::FreeDeleter>* buffer); | 156 scoped_ptr<BYTE, base::FreeDeleter>* buffer); |
| 157 // Gets the system directory and appends a trailing slash if not already | 157 // Gets the system directory and appends a trailing slash if not already |
| 158 // present. | 158 // present. |
| 159 bool GetSystemDirectory(base::string16* path); | 159 bool GetSystemDirectory(base::string16* path); |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { | 162 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { |
| 163 return new Win32WifiDataProvider(); | 163 return new WifiDataProviderWin(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 Win32WifiDataProvider::Win32WifiDataProvider() { | 166 WifiDataProviderWin::WifiDataProviderWin() { |
| 167 } | 167 } |
| 168 | 168 |
| 169 Win32WifiDataProvider::~Win32WifiDataProvider() { | 169 WifiDataProviderWin::~WifiDataProviderWin() { |
| 170 } | 170 } |
| 171 | 171 |
| 172 WifiDataProviderCommon::WlanApiInterface* Win32WifiDataProvider::NewWlanApi() { | 172 WifiDataProviderCommon::WlanApiInterface* WifiDataProviderWin::NewWlanApi() { |
| 173 // Use the WLAN interface if we're on Vista and if it's available. Otherwise, | 173 // Use the WLAN interface if we're on Vista and if it's available. Otherwise, |
| 174 // use NDIS. | 174 // use NDIS. |
| 175 WlanApiInterface* api = WindowsWlanApi::Create(); | 175 WlanApiInterface* api = WindowsWlanApi::Create(); |
| 176 if (api) { | 176 if (api) { |
| 177 return api; | 177 return api; |
| 178 } | 178 } |
| 179 return WindowsNdisApi::Create(); | 179 return WindowsNdisApi::Create(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 WifiPollingPolicy* Win32WifiDataProvider::NewPollingPolicy() { | 182 WifiPollingPolicy* WifiDataProviderWin::NewPollingPolicy() { |
| 183 return new GenericWifiPollingPolicy<kDefaultPollingInterval, | 183 return new GenericWifiPollingPolicy<kDefaultPollingInterval, |
| 184 kNoChangePollingInterval, | 184 kNoChangePollingInterval, |
| 185 kTwoNoChangePollingInterval, | 185 kTwoNoChangePollingInterval, |
| 186 kNoWifiPollingIntervalMilliseconds>; | 186 kNoWifiPollingIntervalMilliseconds>; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Local classes and functions | 189 // Local classes and functions |
| 190 namespace { | 190 namespace { |
| 191 | 191 |
| 192 // WindowsWlanApi | 192 // WindowsWlanApi |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 632 |
| 633 if (*path->rbegin() != L'\\') { | 633 if (*path->rbegin() != L'\\') { |
| 634 path->append(L"\\"); | 634 path->append(L"\\"); |
| 635 } | 635 } |
| 636 DCHECK_EQ(L'\\', *path->rbegin()); | 636 DCHECK_EQ(L'\\', *path->rbegin()); |
| 637 return true; | 637 return true; |
| 638 } | 638 } |
| 639 } // namespace | 639 } // namespace |
| 640 | 640 |
| 641 } // namespace content | 641 } // namespace content |
| OLD | NEW |