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

Side by Side Diff: components/metrics/net/network_metrics_provider.cc

Issue 1548113002: Switch to standard integer types in components/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/metrics/net/network_metrics_provider.h" 5 #include "components/metrics/net/network_metrics_provider.h"
6 6
7 #include <stdint.h>
8
7 #include <string> 9 #include <string>
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
14 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
17 #include "build/build_config.h"
15 18
16 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
17 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" 20 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h"
18 #endif // OS_CHROMEOS 21 #endif // OS_CHROMEOS
19 22
20 namespace metrics { 23 namespace metrics {
21 24
22 NetworkMetricsProvider::NetworkMetricsProvider( 25 NetworkMetricsProvider::NetworkMetricsProvider(
23 base::TaskRunner* io_task_runner) 26 base::TaskRunner* io_task_runner)
24 : io_task_runner_(io_task_runner), 27 : io_task_runner_(io_task_runner),
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 case WifiAccessPointInfoProvider::WIFI_SECURITY_PSK: 188 case WifiAccessPointInfoProvider::WIFI_SECURITY_PSK:
186 security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_PSK; 189 security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_PSK;
187 break; 190 break;
188 case WifiAccessPointInfoProvider::WIFI_SECURITY_UNKNOWN: 191 case WifiAccessPointInfoProvider::WIFI_SECURITY_UNKNOWN:
189 security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN; 192 security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN;
190 break; 193 break;
191 } 194 }
192 access_point_info->set_security_mode(security); 195 access_point_info->set_security_mode(security);
193 196
194 // |bssid| is xx:xx:xx:xx:xx:xx, extract the first three components and 197 // |bssid| is xx:xx:xx:xx:xx:xx, extract the first three components and
195 // pack into a uint32. 198 // pack into a uint32_t.
196 std::string bssid = info.bssid; 199 std::string bssid = info.bssid;
197 if (bssid.size() == 17 && bssid[2] == ':' && bssid[5] == ':' && 200 if (bssid.size() == 17 && bssid[2] == ':' && bssid[5] == ':' &&
198 bssid[8] == ':' && bssid[11] == ':' && bssid[14] == ':') { 201 bssid[8] == ':' && bssid[11] == ':' && bssid[14] == ':') {
199 std::string vendor_prefix_str; 202 std::string vendor_prefix_str;
200 uint32 vendor_prefix; 203 uint32_t vendor_prefix;
201 204
202 base::RemoveChars(bssid.substr(0, 9), ":", &vendor_prefix_str); 205 base::RemoveChars(bssid.substr(0, 9), ":", &vendor_prefix_str);
203 DCHECK_EQ(6U, vendor_prefix_str.size()); 206 DCHECK_EQ(6U, vendor_prefix_str.size());
204 if (base::HexStringToUInt(vendor_prefix_str, &vendor_prefix)) 207 if (base::HexStringToUInt(vendor_prefix_str, &vendor_prefix))
205 access_point_info->set_vendor_prefix(vendor_prefix); 208 access_point_info->set_vendor_prefix(vendor_prefix);
206 else 209 else
207 NOTREACHED(); 210 NOTREACHED();
208 } 211 }
209 212
210 // Return if vendor information is not provided. 213 // Return if vendor information is not provided.
(...skipping 10 matching lines...) Expand all
221 if (!info.device_name.empty()) 224 if (!info.device_name.empty())
222 vendor->set_device_name(info.device_name); 225 vendor->set_device_name(info.device_name);
223 226
224 // Return if OUI list is not provided. 227 // Return if OUI list is not provided.
225 if (info.oui_list.empty()) 228 if (info.oui_list.empty())
226 return; 229 return;
227 230
228 // Parse OUI list. 231 // Parse OUI list.
229 for (const base::StringPiece& oui_str : base::SplitStringPiece( 232 for (const base::StringPiece& oui_str : base::SplitStringPiece(
230 info.oui_list, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { 233 info.oui_list, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
231 uint32 oui; 234 uint32_t oui;
232 if (base::HexStringToUInt(oui_str, &oui)) 235 if (base::HexStringToUInt(oui_str, &oui))
233 vendor->add_element_identifier(oui); 236 vendor->add_element_identifier(oui);
234 else 237 else
235 NOTREACHED(); 238 NOTREACHED();
236 } 239 }
237 } 240 }
238 241
239 } // namespace metrics 242 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/net/network_metrics_provider.h ('k') | components/metrics/net/wifi_access_point_info_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698