| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Win32 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, scoped_ptr_malloc<BYTE>* buffer); | 155 bool ResizeBuffer(int requested_size, |
| 156 scoped_ptr<BYTE, base::FreeDeleter>* buffer); |
| 156 // 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 |
| 157 // present. | 158 // present. |
| 158 bool GetSystemDirectory(base::string16* path); | 159 bool GetSystemDirectory(base::string16* path); |
| 159 } // namespace | 160 } // namespace |
| 160 | 161 |
| 161 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { | 162 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { |
| 162 return new Win32WifiDataProvider(); | 163 return new Win32WifiDataProvider(); |
| 163 } | 164 } |
| 164 | 165 |
| 165 Win32WifiDataProvider::Win32WifiDataProvider() { | 166 Win32WifiDataProvider::Win32WifiDataProvider() { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 462 |
| 462 RegCloseKey(network_cards_key); | 463 RegCloseKey(network_cards_key); |
| 463 return true; | 464 return true; |
| 464 } | 465 } |
| 465 | 466 |
| 466 | 467 |
| 467 bool WindowsNdisApi::GetInterfaceDataNDIS(HANDLE adapter_handle, | 468 bool WindowsNdisApi::GetInterfaceDataNDIS(HANDLE adapter_handle, |
| 468 WifiData::AccessPointDataSet* data) { | 469 WifiData::AccessPointDataSet* data) { |
| 469 DCHECK(data); | 470 DCHECK(data); |
| 470 | 471 |
| 471 scoped_ptr_malloc<BYTE> buffer( | 472 scoped_ptr<BYTE, base::FreeDeleter> buffer( |
| 472 reinterpret_cast<BYTE*>(malloc(oid_buffer_size_))); | 473 static_cast<BYTE*>(malloc(oid_buffer_size_))); |
| 473 if (buffer == NULL) { | 474 if (buffer == NULL) { |
| 474 return false; | 475 return false; |
| 475 } | 476 } |
| 476 | 477 |
| 477 DWORD bytes_out; | 478 DWORD bytes_out; |
| 478 int result; | 479 int result; |
| 479 | 480 |
| 480 while (true) { | 481 while (true) { |
| 481 bytes_out = 0; | 482 bytes_out = 0; |
| 482 result = PerformQuery(adapter_handle, buffer.get(), | 483 result = PerformQuery(adapter_handle, buffer.get(), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 sizeof(oid), | 591 sizeof(oid), |
| 591 buffer, | 592 buffer, |
| 592 buffer_size, | 593 buffer_size, |
| 593 bytes_out, | 594 bytes_out, |
| 594 NULL)) { | 595 NULL)) { |
| 595 return GetLastError(); | 596 return GetLastError(); |
| 596 } | 597 } |
| 597 return ERROR_SUCCESS; | 598 return ERROR_SUCCESS; |
| 598 } | 599 } |
| 599 | 600 |
| 600 bool ResizeBuffer(int requested_size, scoped_ptr_malloc<BYTE>* buffer) { | 601 bool ResizeBuffer(int requested_size, |
| 602 scoped_ptr<BYTE, base::FreeDeleter>* buffer) { |
| 601 DCHECK_GT(requested_size, 0); | 603 DCHECK_GT(requested_size, 0); |
| 602 DCHECK(buffer); | 604 DCHECK(buffer); |
| 603 if (requested_size > kMaximumBufferSize) { | 605 if (requested_size > kMaximumBufferSize) { |
| 604 buffer->reset(); | 606 buffer->reset(); |
| 605 return false; | 607 return false; |
| 606 } | 608 } |
| 607 | 609 |
| 608 buffer->reset(reinterpret_cast<BYTE*>( | 610 buffer->reset(reinterpret_cast<BYTE*>( |
| 609 realloc(buffer->release(), requested_size))); | 611 realloc(buffer->release(), requested_size))); |
| 610 return buffer != NULL; | 612 return buffer != NULL; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 630 | 632 |
| 631 if (*path->rbegin() != L'\\') { | 633 if (*path->rbegin() != L'\\') { |
| 632 path->append(L"\\"); | 634 path->append(L"\\"); |
| 633 } | 635 } |
| 634 DCHECK_EQ(L'\\', *path->rbegin()); | 636 DCHECK_EQ(L'\\', *path->rbegin()); |
| 635 return true; | 637 return true; |
| 636 } | 638 } |
| 637 } // namespace | 639 } // namespace |
| 638 | 640 |
| 639 } // namespace content | 641 } // namespace content |
| OLD | NEW |