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

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

Issue 246553003: Record Mobile Operator ID in UMA report. This is Android only for now. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@operator_id
Patch Set: addressed comments. Created 6 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/metrics_network_observer.h" 5 #include "chrome/browser/metrics/metrics_network_observer.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 #if defined(OS_ANDROID)
13 #include "content/common/android/device_telephony_info.h"
14 #endif
15
16 #if defined(OS_ANDROID)
17 namespace {
18
19 std::string GetAndroidNetworkOperatorID() {
20 content::DeviceTelephonyInfo device_info;
21 return device_info.GetNetworkOperator();
bengr 2014/04/25 20:39:41 Sorry to have not caught this in your last CL, but
bolian 2014/04/25 23:33:05 It is existing code. I added a method. Anyway, it
22 }
23
24 }
25 #endif
12 26
13 MetricsNetworkObserver::MetricsNetworkObserver() 27 MetricsNetworkObserver::MetricsNetworkObserver()
14 : weak_ptr_factory_(this), 28 : weak_ptr_factory_(this),
15 connection_type_is_ambiguous_(false), 29 connection_type_is_ambiguous_(false),
16 wifi_phy_layer_protocol_is_ambiguous_(false), 30 wifi_phy_layer_protocol_is_ambiguous_(false),
17 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN) { 31 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN) {
18 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 32 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
19 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); 33 connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
20 ProbeWifiPHYLayerProtocol(); 34 ProbeWifiPHYLayerProtocol();
35 GetNetworkOperatorID();
21 } 36 }
22 37
23 MetricsNetworkObserver::~MetricsNetworkObserver() { 38 MetricsNetworkObserver::~MetricsNetworkObserver() {
24 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 39 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
25 } 40 }
26 41
27 void MetricsNetworkObserver::Reset() { 42 void MetricsNetworkObserver::Reset() {
28 connection_type_is_ambiguous_ = false; 43 connection_type_is_ambiguous_ = false;
29 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); 44 connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
30 wifi_phy_layer_protocol_is_ambiguous_ = false; 45 wifi_phy_layer_protocol_is_ambiguous_ = false;
31 } 46 }
32 47
33 void MetricsNetworkObserver::OnConnectionTypeChanged( 48 void MetricsNetworkObserver::OnConnectionTypeChanged(
34 net::NetworkChangeNotifier::ConnectionType type) { 49 net::NetworkChangeNotifier::ConnectionType type) {
35 if (type == net::NetworkChangeNotifier::CONNECTION_NONE) 50 if (type == net::NetworkChangeNotifier::CONNECTION_NONE)
36 return; 51 return;
37 if (type != connection_type_ && 52 if (type != connection_type_ &&
38 connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE) { 53 connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE) {
39 connection_type_is_ambiguous_ = true; 54 connection_type_is_ambiguous_ = true;
40 } 55 }
41 connection_type_ = type; 56 connection_type_ = type;
42 57
43 ProbeWifiPHYLayerProtocol(); 58 ProbeWifiPHYLayerProtocol();
59 GetNetworkOperatorID();
44 } 60 }
45 61
46 SystemProfileProto::Network::ConnectionType 62 SystemProfileProto::Network::ConnectionType
47 MetricsNetworkObserver::connection_type() const { 63 MetricsNetworkObserver::connection_type() const {
48 switch (connection_type_) { 64 switch (connection_type_) {
49 case net::NetworkChangeNotifier::CONNECTION_NONE: 65 case net::NetworkChangeNotifier::CONNECTION_NONE:
50 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: 66 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN:
51 return SystemProfileProto::Network::CONNECTION_UNKNOWN; 67 return SystemProfileProto::Network::CONNECTION_UNKNOWN;
52 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: 68 case net::NetworkChangeNotifier::CONNECTION_ETHERNET:
53 return SystemProfileProto::Network::CONNECTION_ETHERNET; 69 return SystemProfileProto::Network::CONNECTION_ETHERNET;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 113
98 void MetricsNetworkObserver::OnWifiPHYLayerProtocolResult( 114 void MetricsNetworkObserver::OnWifiPHYLayerProtocolResult(
99 net::WifiPHYLayerProtocol mode) { 115 net::WifiPHYLayerProtocol mode) {
100 if (wifi_phy_layer_protocol_ != net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN && 116 if (wifi_phy_layer_protocol_ != net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN &&
101 mode != wifi_phy_layer_protocol_) { 117 mode != wifi_phy_layer_protocol_) {
102 wifi_phy_layer_protocol_is_ambiguous_ = true; 118 wifi_phy_layer_protocol_is_ambiguous_ = true;
103 } 119 }
104 wifi_phy_layer_protocol_ = mode; 120 wifi_phy_layer_protocol_ = mode;
105 } 121 }
106 122
123 void MetricsNetworkObserver::GetNetworkOperatorID() {
124 #if defined(OS_ANDROID)
125 PostTaskAndReplyWithResult(
126 content::BrowserThread::GetBlockingPool(),
127 FROM_HERE,
128 base::Bind(&GetAndroidNetworkOperatorID),
129 base::Bind(&MetricsNetworkObserver::OnNetworkOperatorID,
130 weak_ptr_factory_.GetWeakPtr()));
131 #endif
132 }
133
134 void MetricsNetworkObserver::OnNetworkOperatorID(std::string id) {
bengr 2014/04/25 20:39:41 const std::string&
bolian 2014/04/25 23:33:05 reverted in the new CL.
135 network_operator_id_ = id;
136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698