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

Unified Diff: chrome/browser/metrics/network_metrics_provider.cc

Issue 328793002: Add wifi AP info to system profile metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/network_metrics_provider.cc
diff --git a/chrome/browser/metrics/network_metrics_provider.cc b/chrome/browser/metrics/network_metrics_provider.cc
index b339d4b93adcddd000756500e58073e19f3c359a..1cc4218d13ad23625b44157fc9e54810241c7cf0 100644
--- a/chrome/browser/metrics/network_metrics_provider.cc
+++ b/chrome/browser/metrics/network_metrics_provider.cc
@@ -5,6 +5,10 @@
#include "chrome/browser/metrics/network_metrics_provider.h"
#include "base/compiler_specific.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/public/browser/browser_thread.h"
@@ -39,6 +43,12 @@ void NetworkMetricsProvider::ProvideSystemProfileMetrics(
// TODO(isherman): This line seems unnecessary.
connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
wifi_phy_layer_protocol_is_ambiguous_ = false;
+
+ // Connected wifi AP information.
+ net::NetworkChangeNotifier::WifiApInfo info;
+ if (net::NetworkChangeNotifier::GetWifiApInfo(info)) {
stevenjb 2014/07/08 00:24:53 Is this modifying info? If so it should pass a * n
zqiu1 2014/07/08 20:47:53 Done.
+ WriteWifiApProto(network, &info);
+ }
}
void NetworkMetricsProvider::OnConnectionTypeChanged(
@@ -116,3 +126,80 @@ void NetworkMetricsProvider::OnWifiPHYLayerProtocolResult(
}
wifi_phy_layer_protocol_ = mode;
}
+
+void NetworkMetricsProvider::WriteWifiApProto(
+ SystemProfileProto::Network *network_proto,
+ const net::NetworkChangeNotifier::WifiApInfo *info) {
+ SystemProfileProto::Network::WifiAccessPoint* ap_info =
+ network_proto->mutable_ap_info();
+
+ SystemProfileProto::Network::WifiAccessPoint::SecurityMode security;
+ switch (info->security) {
+ case net::NetworkChangeNotifier::WIFI_SECURITY_NONE:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_NONE;
+ break;
+ case net::NetworkChangeNotifier::WIFI_SECURITY_WPA:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WPA;
+ break;
+ case net::NetworkChangeNotifier::WIFI_SECURITY_WEP:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WEP;
+ break;
+ case net::NetworkChangeNotifier::WIFI_SECURITY_RSN:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_RSN;
+ break;
+ case net::NetworkChangeNotifier::WIFI_SECURITY_802_1X:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_802_1X;
+ break;
+ case net::NetworkChangeNotifier::WIFI_SECURITY_PSK:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_PSK;
+ break;
+ default:
+ security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN;
+ break;
+ }
+ ap_info->set_security_mode(security);
+
+ // |bssid| is xx:xx:xx:xx:xx:xx, extract the first three components and
+ // pack into a uint32.
+ std::string bssid = info->bssid;
+ if (bssid.size() > 9 && bssid[2] == ':' && bssid[5] == ':' &&
+ bssid[8] == ':') {
+ std::string vendor_prefix_str;
+ uint32 vendor_prefix;
+
+ base::RemoveChars(bssid.substr(0, 9), ":", &vendor_prefix_str);
+ DCHECK_EQ(6U, vendor_prefix_str.size());
+ base::HexStringToUInt(vendor_prefix_str, &vendor_prefix);
+
+ ap_info->set_vendor_prefix(vendor_prefix);
+ }
+
+ // Fill in vendor information if it is provided.
+ if (!info->model_number.empty() || !info->model_name.empty() ||
+ !info->device_name.empty() || !info->oui_list.empty()) {
+ SystemProfileProto::Network::WifiAccessPoint::VendorInformation *vendor =
+ ap_info->mutable_vendor_info();
+ if (!info->model_number.empty()) {
+ vendor->set_model_number(info->model_number);
+ }
+ if (!info->model_name.empty()) {
+ vendor->set_model_name(info->model_name);
+ }
+ if (!info->device_name.empty()) {
+ vendor->set_device_name(info->device_name);
+ }
+
+ // Parse OUI list.
+ if (!info->oui_list.empty()) {
+ std::vector<std::string> oui_list;
+ base::SplitString(info->oui_list, ' ', &oui_list);
+ for (std::vector<std::string>::const_iterator i = oui_list.begin();
+ i != oui_list.end();
+ ++i) {
+ uint32 oui;
+ base::HexStringToUInt(*i, &oui);
+ vendor->add_oui(oui);
+ }
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698