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

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

Issue 556106: Add tests for the geolocation network provider... (Closed) Base URL: svn://chrome-svn/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
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 // WiFi card drivers for Linux implement the Wireless Extensions interface. 5 // WiFi card drivers for Linux implement the Wireless Extensions interface.
6 // This interface is part of the Linux kernel. 6 // This interface is part of the Linux kernel.
7 // 7 //
8 // Various sets of tools are available to manipulate the Wireless Extensions, 8 // Various sets of tools are available to manipulate the Wireless Extensions,
9 // of which Wireless Tools is the default implementation. Wireless Tools 9 // of which Wireless Tools is the default implementation. Wireless Tools
10 // provides a C++ library (libiw) as well as a set of command line tools 10 // provides a C++ library (libiw) as well as a set of command line tools
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 : is_first_scan_complete_(false) { 73 : is_first_scan_complete_(false) {
74 Start(); 74 Start();
75 } 75 }
76 76
77 LinuxWifiDataProvider::~LinuxWifiDataProvider() { 77 LinuxWifiDataProvider::~LinuxWifiDataProvider() {
78 stop_event_.Signal(); 78 stop_event_.Signal();
79 Join(); 79 Join();
80 } 80 }
81 81
82 bool LinuxWifiDataProvider::GetData(WifiData *data) { 82 bool LinuxWifiDataProvider::GetData(WifiData *data) {
83 assert(data); 83 DCHECK(data);
84 MutexLock lock(&data_mutex_); 84 MutexLock lock(&data_mutex_);
85 *data = wifi_data_; 85 *data = wifi_data_;
86 // If we've successfully completed a scan, indicate that we have all of the 86 // If we've successfully completed a scan, indicate that we have all of the
87 // data we can get. 87 // data we can get.
88 return is_first_scan_complete_; 88 return is_first_scan_complete_;
89 } 89 }
90 90
91 // Thread implementation 91 // Thread implementation
92 void LinuxWifiDataProvider::Run() { 92 void LinuxWifiDataProvider::Run() {
93 // Regularly get the access point data. 93 // Regularly get the access point data.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 size_t bytes_read; 212 size_t bytes_read;
213 std::string result; 213 std::string result;
214 do { 214 do {
215 bytes_read = fread(buffer, 1, kBufferSize, result_pipe); 215 bytes_read = fread(buffer, 1, kBufferSize, result_pipe);
216 result.append(buffer, bytes_read); 216 result.append(buffer, bytes_read);
217 } while (static_cast<int>(bytes_read) == kBufferSize); 217 } while (static_cast<int>(bytes_read) == kBufferSize);
218 pclose(result_pipe); 218 pclose(result_pipe);
219 219
220 220
221 // Parse results. 221 // Parse results.
222 assert(access_points); 222 DCHECK(access_points);
223 access_points->clear(); 223 access_points->clear();
224 std::string::size_type start = result.find(delimiter); 224 std::string::size_type start = result.find(delimiter);
225 while (start != std::string::npos) { 225 while (start != std::string::npos) {
226 std::string::size_type end = result.find(delimiter, start + 1); 226 std::string::size_type end = result.find(delimiter, start + 1);
227 std::string::size_type length = (end == std::string::npos) ? 227 std::string::size_type length = (end == std::string::npos) ?
228 std::string::npos : end - start; 228 std::string::npos : end - start;
229 AccessPointData access_point_data; 229 AccessPointData access_point_data;
230 ParseAccessPoint(result.substr(start, length), 230 ParseAccessPoint(result.substr(start, length),
231 mac_address_string, 231 mac_address_string,
232 ssid_string, 232 ssid_string,
(...skipping 15 matching lines...) Expand all
248 access_points) || 248 access_points) ||
249 IssueCommandAndParseResult("iwconfig 2> /dev/null", 249 IssueCommandAndParseResult("iwconfig 2> /dev/null",
250 "ESSID:\"", 250 "ESSID:\"",
251 "Access Point: ", 251 "Access Point: ",
252 "ESSID:", 252 "ESSID:",
253 "Signal level=", 253 "Signal level=",
254 access_points); 254 access_points);
255 } 255 }
256 256
257 #endif // 0 257 #endif // 0
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_common_win.cc ('k') | chrome/browser/geolocation/wifi_data_provider_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698