| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 AccessPointData* access_point_data); | 148 AccessPointData* access_point_data); |
| 149 bool UndefineDosDevice(const base::string16& device_name); | 149 bool UndefineDosDevice(const base::string16& device_name); |
| 150 bool DefineDosDeviceIfNotExists(const base::string16& device_name); | 150 bool DefineDosDeviceIfNotExists(const base::string16& device_name); |
| 151 HANDLE GetFileHandle(const base::string16& device_name); | 151 HANDLE GetFileHandle(const base::string16& device_name); |
| 152 // Makes the OID query and returns a Windows API error code. | 152 // Makes the OID query and returns a Windows API error code. |
| 153 int PerformQuery(HANDLE adapter_handle, | 153 int PerformQuery(HANDLE adapter_handle, |
| 154 BYTE* buffer, | 154 BYTE* buffer, |
| 155 DWORD buffer_size, | 155 DWORD buffer_size, |
| 156 DWORD* bytes_out); | 156 DWORD* bytes_out); |
| 157 bool ResizeBuffer(int requested_size, | 157 bool ResizeBuffer(int requested_size, |
| 158 scoped_ptr<BYTE, base::FreeDeleter>* buffer); | 158 std::unique_ptr<BYTE, base::FreeDeleter>* buffer); |
| 159 // Gets the system directory and appends a trailing slash if not already | 159 // Gets the system directory and appends a trailing slash if not already |
| 160 // present. | 160 // present. |
| 161 bool GetSystemDirectory(base::string16* path); | 161 bool GetSystemDirectory(base::string16* path); |
| 162 } // namespace | 162 } // namespace |
| 163 | 163 |
| 164 WifiDataProvider* WifiDataProviderManager::DefaultFactoryFunction() { | 164 WifiDataProvider* WifiDataProviderManager::DefaultFactoryFunction() { |
| 165 return new WifiDataProviderWin(); | 165 return new WifiDataProviderWin(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 WifiDataProviderWin::WifiDataProviderWin() { | 168 WifiDataProviderWin::WifiDataProviderWin() { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 RegCloseKey(network_cards_key); | 465 RegCloseKey(network_cards_key); |
| 466 return true; | 466 return true; |
| 467 } | 467 } |
| 468 | 468 |
| 469 | 469 |
| 470 bool WindowsNdisApi::GetInterfaceDataNDIS(HANDLE adapter_handle, | 470 bool WindowsNdisApi::GetInterfaceDataNDIS(HANDLE adapter_handle, |
| 471 WifiData::AccessPointDataSet* data) { | 471 WifiData::AccessPointDataSet* data) { |
| 472 DCHECK(data); | 472 DCHECK(data); |
| 473 | 473 |
| 474 scoped_ptr<BYTE, base::FreeDeleter> buffer( | 474 std::unique_ptr<BYTE, base::FreeDeleter> buffer( |
| 475 static_cast<BYTE*>(malloc(oid_buffer_size_))); | 475 static_cast<BYTE*>(malloc(oid_buffer_size_))); |
| 476 if (buffer == NULL) { | 476 if (buffer == NULL) { |
| 477 return false; | 477 return false; |
| 478 } | 478 } |
| 479 | 479 |
| 480 DWORD bytes_out; | 480 DWORD bytes_out; |
| 481 int result; | 481 int result; |
| 482 | 482 |
| 483 while (true) { | 483 while (true) { |
| 484 bytes_out = 0; | 484 bytes_out = 0; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 buffer, | 594 buffer, |
| 595 buffer_size, | 595 buffer_size, |
| 596 bytes_out, | 596 bytes_out, |
| 597 NULL)) { | 597 NULL)) { |
| 598 return GetLastError(); | 598 return GetLastError(); |
| 599 } | 599 } |
| 600 return ERROR_SUCCESS; | 600 return ERROR_SUCCESS; |
| 601 } | 601 } |
| 602 | 602 |
| 603 bool ResizeBuffer(int requested_size, | 603 bool ResizeBuffer(int requested_size, |
| 604 scoped_ptr<BYTE, base::FreeDeleter>* buffer) { | 604 std::unique_ptr<BYTE, base::FreeDeleter>* buffer) { |
| 605 DCHECK_GT(requested_size, 0); | 605 DCHECK_GT(requested_size, 0); |
| 606 DCHECK(buffer); | 606 DCHECK(buffer); |
| 607 if (requested_size > kMaximumBufferSize) { | 607 if (requested_size > kMaximumBufferSize) { |
| 608 buffer->reset(); | 608 buffer->reset(); |
| 609 return false; | 609 return false; |
| 610 } | 610 } |
| 611 | 611 |
| 612 buffer->reset(reinterpret_cast<BYTE*>( | 612 buffer->reset(reinterpret_cast<BYTE*>( |
| 613 realloc(buffer->release(), requested_size))); | 613 realloc(buffer->release(), requested_size))); |
| 614 return buffer != NULL; | 614 return buffer != NULL; |
| 615 } | 615 } |
| 616 | 616 |
| 617 bool GetSystemDirectory(base::string16* path) { | 617 bool GetSystemDirectory(base::string16* path) { |
| 618 DCHECK(path); | 618 DCHECK(path); |
| 619 // Return value includes terminating NULL. | 619 // Return value includes terminating NULL. |
| 620 int buffer_size = ::GetSystemDirectory(NULL, 0); | 620 int buffer_size = ::GetSystemDirectory(NULL, 0); |
| 621 if (buffer_size == 0) { | 621 if (buffer_size == 0) { |
| 622 return false; | 622 return false; |
| 623 } | 623 } |
| 624 scoped_ptr<base::char16[]> buffer(new base::char16[buffer_size]); | 624 std::unique_ptr<base::char16[]> buffer(new base::char16[buffer_size]); |
| 625 | 625 |
| 626 // Return value excludes terminating NULL. | 626 // Return value excludes terminating NULL. |
| 627 int characters_written = ::GetSystemDirectory(buffer.get(), buffer_size); | 627 int characters_written = ::GetSystemDirectory(buffer.get(), buffer_size); |
| 628 if (characters_written == 0) { | 628 if (characters_written == 0) { |
| 629 return false; | 629 return false; |
| 630 } | 630 } |
| 631 DCHECK_EQ(buffer_size - 1, characters_written); | 631 DCHECK_EQ(buffer_size - 1, characters_written); |
| 632 | 632 |
| 633 path->assign(buffer.get(), characters_written); | 633 path->assign(buffer.get(), characters_written); |
| 634 | 634 |
| 635 if (*path->rbegin() != L'\\') { | 635 if (*path->rbegin() != L'\\') { |
| 636 path->append(L"\\"); | 636 path->append(L"\\"); |
| 637 } | 637 } |
| 638 DCHECK_EQ(L'\\', *path->rbegin()); | 638 DCHECK_EQ(L'\\', *path->rbegin()); |
| 639 return true; | 639 return true; |
| 640 } | 640 } |
| 641 } // namespace | 641 } // namespace |
| 642 | 642 |
| 643 } // namespace content | 643 } // namespace content |
| OLD | NEW |