| OLD | NEW |
| 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 "chrome/browser/metrics/network_metrics_provider.h" | 5 #include "components/metrics/net/network_metrics_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | |
| 16 #include "content/public/browser/browser_thread.h" | |
| 17 | 15 |
| 18 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 19 #include "chrome/browser/metrics/wifi_access_point_info_provider_chromeos.h" | 17 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" |
| 20 #endif // OS_CHROMEOS | 18 #endif // OS_CHROMEOS |
| 21 | 19 |
| 22 using metrics::SystemProfileProto; | 20 using metrics::SystemProfileProto; |
| 23 | 21 |
| 24 NetworkMetricsProvider::NetworkMetricsProvider() | 22 NetworkMetricsProvider::NetworkMetricsProvider( |
| 25 : connection_type_is_ambiguous_(false), | 23 base::TaskRunner* io_task_runner) |
| 24 : io_task_runner_(io_task_runner), |
| 25 connection_type_is_ambiguous_(false), |
| 26 wifi_phy_layer_protocol_is_ambiguous_(false), | 26 wifi_phy_layer_protocol_is_ambiguous_(false), |
| 27 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN), | 27 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN), |
| 28 weak_ptr_factory_(this) { | 28 weak_ptr_factory_(this) { |
| 29 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 29 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 30 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); | 30 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); |
| 31 ProbeWifiPHYLayerProtocol(); | 31 ProbeWifiPHYLayerProtocol(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 NetworkMetricsProvider::~NetworkMetricsProvider() { | 34 NetworkMetricsProvider::~NetworkMetricsProvider() { |
| 35 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 35 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_N; | 124 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_N; |
| 125 case net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN: | 125 case net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN: |
| 126 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 126 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
| 127 } | 127 } |
| 128 NOTREACHED(); | 128 NOTREACHED(); |
| 129 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 129 return SystemProfileProto::Network::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void NetworkMetricsProvider::ProbeWifiPHYLayerProtocol() { | 132 void NetworkMetricsProvider::ProbeWifiPHYLayerProtocol() { |
| 133 PostTaskAndReplyWithResult( | 133 PostTaskAndReplyWithResult( |
| 134 content::BrowserThread::GetBlockingPool(), | 134 io_task_runner_, |
| 135 FROM_HERE, | 135 FROM_HERE, |
| 136 base::Bind(&net::GetWifiPHYLayerProtocol), | 136 base::Bind(&net::GetWifiPHYLayerProtocol), |
| 137 base::Bind(&NetworkMetricsProvider::OnWifiPHYLayerProtocolResult, | 137 base::Bind(&NetworkMetricsProvider::OnWifiPHYLayerProtocolResult, |
| 138 weak_ptr_factory_.GetWeakPtr())); | 138 weak_ptr_factory_.GetWeakPtr())); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void NetworkMetricsProvider::OnWifiPHYLayerProtocolResult( | 141 void NetworkMetricsProvider::OnWifiPHYLayerProtocolResult( |
| 142 net::WifiPHYLayerProtocol mode) { | 142 net::WifiPHYLayerProtocol mode) { |
| 143 if (wifi_phy_layer_protocol_ != net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN && | 143 if (wifi_phy_layer_protocol_ != net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN && |
| 144 mode != wifi_phy_layer_protocol_) { | 144 mode != wifi_phy_layer_protocol_) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 for (std::vector<std::string>::const_iterator it = oui_list.begin(); | 219 for (std::vector<std::string>::const_iterator it = oui_list.begin(); |
| 220 it != oui_list.end(); | 220 it != oui_list.end(); |
| 221 ++it) { | 221 ++it) { |
| 222 uint32 oui; | 222 uint32 oui; |
| 223 if (base::HexStringToUInt(*it, &oui)) | 223 if (base::HexStringToUInt(*it, &oui)) |
| 224 vendor->add_element_identifier(oui); | 224 vendor->add_element_identifier(oui); |
| 225 else | 225 else |
| 226 NOTREACHED(); | 226 NOTREACHED(); |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |