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

Side by Side Diff: chrome/browser/metrics/network_metrics_provider.cc

Issue 532623003: Remove MetricsServiceObserver in favor of MetricsProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN build. Created 6 years, 3 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 "chrome/browser/metrics/network_metrics_provider.h" 5 #include "chrome/browser/metrics/network_metrics_provider.h"
6 6
7 #include <string>
8 #include <vector>
9
7 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
8 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
11 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
12 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
13 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
14 17
15 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
16 #include "chrome/browser/metrics/wifi_access_point_info_provider_chromeos.h" 19 #include "chrome/browser/metrics/wifi_access_point_info_provider_chromeos.h"
17 #endif // OS_CHROMEOS 20 #endif // OS_CHROMEOS
18 21
19 using metrics::SystemProfileProto; 22 using metrics::SystemProfileProto;
20 23
21 NetworkMetricsProvider::NetworkMetricsProvider() 24 NetworkMetricsProvider::NetworkMetricsProvider()
22 : connection_type_is_ambiguous_(false), 25 : connection_type_is_ambiguous_(false),
23 wifi_phy_layer_protocol_is_ambiguous_(false), 26 wifi_phy_layer_protocol_is_ambiguous_(false),
24 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN), 27 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN),
25 weak_ptr_factory_(this) { 28 weak_ptr_factory_(this) {
26 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 29 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
27 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); 30 connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
28 ProbeWifiPHYLayerProtocol(); 31 ProbeWifiPHYLayerProtocol();
29 } 32 }
30 33
31 NetworkMetricsProvider::~NetworkMetricsProvider() { 34 NetworkMetricsProvider::~NetworkMetricsProvider() {
32 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 35 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
33 } 36 }
34 37
38 void NetworkMetricsProvider::OnDidCreateMetricsLog() {
39 net::NetworkChangeNotifier::LogOperatorCodeHistogram(
40 net::NetworkChangeNotifier::GetConnectionType());
41 }
42
35 void NetworkMetricsProvider::ProvideSystemProfileMetrics( 43 void NetworkMetricsProvider::ProvideSystemProfileMetrics(
36 SystemProfileProto* system_profile) { 44 SystemProfileProto* system_profile) {
37 SystemProfileProto::Network* network = system_profile->mutable_network(); 45 SystemProfileProto::Network* network = system_profile->mutable_network();
38 network->set_connection_type_is_ambiguous(connection_type_is_ambiguous_); 46 network->set_connection_type_is_ambiguous(connection_type_is_ambiguous_);
39 network->set_connection_type(GetConnectionType()); 47 network->set_connection_type(GetConnectionType());
40 network->set_wifi_phy_layer_protocol_is_ambiguous( 48 network->set_wifi_phy_layer_protocol_is_ambiguous(
41 wifi_phy_layer_protocol_is_ambiguous_); 49 wifi_phy_layer_protocol_is_ambiguous_);
42 network->set_wifi_phy_layer_protocol(GetWifiPHYLayerProtocol()); 50 network->set_wifi_phy_layer_protocol(GetWifiPHYLayerProtocol());
43 51
44 // Resets the "ambiguous" flags, since a new metrics log session has started. 52 // Resets the "ambiguous" flags, since a new metrics log session has started.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 for (std::vector<std::string>::const_iterator it = oui_list.begin(); 219 for (std::vector<std::string>::const_iterator it = oui_list.begin();
212 it != oui_list.end(); 220 it != oui_list.end();
213 ++it) { 221 ++it) {
214 uint32 oui; 222 uint32 oui;
215 if (base::HexStringToUInt(*it, &oui)) 223 if (base::HexStringToUInt(*it, &oui))
216 vendor->add_element_identifier(oui); 224 vendor->add_element_identifier(oui);
217 else 225 else
218 NOTREACHED(); 226 NOTREACHED();
219 } 227 }
220 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698