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

Side by Side Diff: chrome/browser/geolocation/wifi_data_provider_mac.cc

Issue 570006: Revert 37989 - unit test failed on Mac builder despite passing on try server... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_linux.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // We use the OSX system API function WirelessScanSplit. This function is not 5 // We use the OSX system API function WirelessScanSplit. This function is not
6 // documented or included in the SDK, so we use a reverse-engineered header, 6 // documented or included in the SDK, so we use a reverse-engineered header,
7 // osx_wifi_.h. This file is taken from the iStumbler project 7 // osx_wifi_.h. This file is taken from the iStumbler project
8 // (http://www.istumbler.net). 8 // (http://www.istumbler.net).
9 9
10 // TODO(joth): port to chromium 10 // TODO(joth): port to chromium
(...skipping 21 matching lines...) Expand all
32 OsxWifiDataProvider::OsxWifiDataProvider() : is_first_scan_complete_(false) { 32 OsxWifiDataProvider::OsxWifiDataProvider() : is_first_scan_complete_(false) {
33 Start(); 33 Start();
34 } 34 }
35 35
36 OsxWifiDataProvider::~OsxWifiDataProvider() { 36 OsxWifiDataProvider::~OsxWifiDataProvider() {
37 stop_event_.Signal(); 37 stop_event_.Signal();
38 Join(); 38 Join();
39 } 39 }
40 40
41 bool OsxWifiDataProvider::GetData(WifiData *data) { 41 bool OsxWifiDataProvider::GetData(WifiData *data) {
42 DCHECK(data); 42 assert(data);
43 MutexLock lock(&data_mutex_); 43 MutexLock lock(&data_mutex_);
44 *data = wifi_data_; 44 *data = wifi_data_;
45 // If we've successfully completed a scan, indicate that we have all of the 45 // If we've successfully completed a scan, indicate that we have all of the
46 // data we can get. 46 // data we can get.
47 return is_first_scan_complete_; 47 return is_first_scan_complete_;
48 } 48 }
49 49
50 // Thread implementation 50 // Thread implementation
51 void OsxWifiDataProvider::Run() { 51 void OsxWifiDataProvider::Run() {
52 void *apple_80211_library = dlopen( 52 void *apple_80211_library = dlopen(
53 "/System/Library/PrivateFrameworks/Apple80211.framework/Apple80211", 53 "/System/Library/PrivateFrameworks/Apple80211.framework/Apple80211",
54 RTLD_LAZY); 54 RTLD_LAZY);
55 if (!apple_80211_library) { 55 if (!apple_80211_library) {
56 is_first_scan_complete_ = true; 56 is_first_scan_complete_ = true;
57 return; 57 return;
58 } 58 }
59 59
60 WirelessAttach_function_ = reinterpret_cast<WirelessAttachFunction>( 60 WirelessAttach_function_ = reinterpret_cast<WirelessAttachFunction>(
61 dlsym(apple_80211_library, "WirelessAttach")); 61 dlsym(apple_80211_library, "WirelessAttach"));
62 WirelessScanSplit_function_ = reinterpret_cast<WirelessScanSplitFunction>( 62 WirelessScanSplit_function_ = reinterpret_cast<WirelessScanSplitFunction>(
63 dlsym(apple_80211_library, "WirelessScanSplit")); 63 dlsym(apple_80211_library, "WirelessScanSplit"));
64 WirelessDetach_function_ = reinterpret_cast<WirelessDetachFunction>( 64 WirelessDetach_function_ = reinterpret_cast<WirelessDetachFunction>(
65 dlsym(apple_80211_library, "WirelessDetach")); 65 dlsym(apple_80211_library, "WirelessDetach"));
66 DCHECK(WirelessAttach_function_ && 66 assert(WirelessAttach_function_ &&
67 WirelessScanSplit_function_ && 67 WirelessScanSplit_function_ &&
68 WirelessDetach_function_); 68 WirelessDetach_function_);
69 69
70 if ((*WirelessAttach_function_)(&wifi_context_, 0) != noErr) { 70 if ((*WirelessAttach_function_)(&wifi_context_, 0) != noErr) {
71 is_first_scan_complete_ = true; 71 is_first_scan_complete_ = true;
72 return; 72 return;
73 } 73 }
74 74
75 // Regularly get the access point data. 75 // Regularly get the access point data.
76 int polling_interval = kDefaultPollingInterval; 76 int polling_interval = kDefaultPollingInterval;
(...skipping 13 matching lines...) Expand all
90 } 90 }
91 } while (!stop_event_.WaitWithTimeout(polling_interval)); 91 } while (!stop_event_.WaitWithTimeout(polling_interval));
92 92
93 (*WirelessDetach_function_)(wifi_context_); 93 (*WirelessDetach_function_)(wifi_context_);
94 94
95 dlclose(apple_80211_library); 95 dlclose(apple_80211_library);
96 } 96 }
97 97
98 void OsxWifiDataProvider::GetAccessPointData( 98 void OsxWifiDataProvider::GetAccessPointData(
99 WifiData::AccessPointDataSet *access_points) { 99 WifiData::AccessPointDataSet *access_points) {
100 DCHECK(access_points); 100 assert(access_points);
101 DCHECK(WirelessScanSplit_function_); 101 assert(WirelessScanSplit_function_);
102 CFArrayRef managed_access_points = NULL; 102 CFArrayRef managed_access_points = NULL;
103 CFArrayRef adhoc_access_points = NULL; 103 CFArrayRef adhoc_access_points = NULL;
104 if ((*WirelessScanSplit_function_)(wifi_context_, 104 if ((*WirelessScanSplit_function_)(wifi_context_,
105 &managed_access_points, 105 &managed_access_points,
106 &adhoc_access_points, 106 &adhoc_access_points,
107 0) != noErr) { 107 0) != noErr) {
108 return; 108 return;
109 } 109 }
110 110
111 if (managed_access_points == NULL) { 111 if (managed_access_points == NULL) {
(...skipping 25 matching lines...) Expand all
137 access_point_info->nameLen, 137 access_point_info->nameLen,
138 &ssid)) { 138 &ssid)) {
139 access_point_data.ssid = ssid; 139 access_point_data.ssid = ssid;
140 } 140 }
141 141
142 access_points->insert(access_point_data); 142 access_points->insert(access_point_data);
143 } 143 }
144 } 144 }
145 145
146 #endif // 0 146 #endif // 0
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_linux.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698