Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: content/browser/geolocation/wifi_data_provider_win.cc

Issue 2192683003: Revert of Reland: Geolocation: move from content/browser to device/ (patchset #2 id:20001 of https:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2810
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 // locally using data from the MSDN. 11 // locally using data from the MSDN.
12 // 12 //
13 // Windows XP from Service Pack 2 onwards supports the Wireless Zero 13 // Windows XP from Service Pack 2 onwards supports the Wireless Zero
14 // Configuration (WZC) programming interface. See 14 // Configuration (WZC) programming interface. See
15 // http://msdn.microsoft.com/en-us/library/ms706587(VS.85).aspx. 15 // http://msdn.microsoft.com/en-us/library/ms706587(VS.85).aspx.
16 // 16 //
17 // The MSDN recommends that one use the WLAN API where available, and WZC 17 // The MSDN recommends that one use the WLAN API where available, and WZC
18 // otherwise. 18 // otherwise.
19 // 19 //
20 // However, it seems that WZC fails for some wireless cards. Also, WLAN seems 20 // However, it seems that WZC fails for some wireless cards. Also, WLAN seems
21 // not to work on XP SP3. So we use WLAN on Vista, and use NDIS directly 21 // not to work on XP SP3. So we use WLAN on Vista, and use NDIS directly
22 // otherwise. 22 // otherwise.
23 23
24 #include "device/geolocation/wifi_data_provider_win.h" 24 #include "content/browser/geolocation/wifi_data_provider_win.h"
25 25
26 #include <windows.h> 26 #include <windows.h>
27 #include <winioctl.h> 27 #include <winioctl.h>
28 #include <wlanapi.h> 28 #include <wlanapi.h>
29 29
30 #include "base/memory/free_deleter.h" 30 #include "base/memory/free_deleter.h"
31 #include "base/metrics/histogram.h" 31 #include "base/metrics/histogram.h"
32 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
33 #include "base/win/windows_version.h" 33 #include "base/win/windows_version.h"
34 #include "device/geolocation/wifi_data_provider_common.h" 34 #include "content/browser/geolocation/wifi_data_provider_common.h"
35 #include "device/geolocation/wifi_data_provider_common_win.h" 35 #include "content/browser/geolocation/wifi_data_provider_common_win.h"
36 #include "device/geolocation/wifi_data_provider_manager.h" 36 #include "content/browser/geolocation/wifi_data_provider_manager.h"
37 37
38 // Taken from ndis.h for WinCE. 38 // Taken from ndis.h for WinCE.
39 #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L) 39 #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
40 #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L) 40 #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
41 41
42 namespace device { 42 namespace content {
43 namespace { 43 namespace {
44 // The limits on the size of the buffer used for the OID query. 44 // The limits on the size of the buffer used for the OID query.
45 const int kInitialBufferSize = 2 << 12; // Good for about 50 APs. 45 const int kInitialBufferSize = 2 << 12; // Good for about 50 APs.
46 const int kMaximumBufferSize = 2 << 20; // 2MB 46 const int kMaximumBufferSize = 2 << 20; // 2MB
47 47
48 // Length for generic string buffers passed to Windows APIs. 48 // Length for generic string buffers passed to Windows APIs.
49 const int kStringLength = 512; 49 const int kStringLength = 512;
50 50
51 // The time periods, in milliseconds, between successive polls of the wifi data. 51 // The time periods, in milliseconds, between successive polls of the wifi data.
52 const int kDefaultPollingInterval = 10000; // 10s 52 const int kDefaultPollingInterval = 10000; // 10s
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 device 643 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geolocation/wifi_data_provider_win.h ('k') | content/browser/geolocation/wifi_data_provider_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698