Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/metrics/metrics_provider.h" | 11 #include "components/metrics/metrics_provider.h" |
| 12 #include "components/metrics/proto/system_profile.pb.h" | 12 #include "components/metrics/proto/system_profile.pb.h" |
| 13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 14 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) | |
| 17 #include "chromeos/network/wifi_access_point_info_provider_chromeos.h" | |
| 18 #else | |
| 19 #include "net/base/wifi_access_point_info_provider_stub.h" | |
| 20 #endif // OS_CHROMEOS | |
|
stevenjb
2014/07/23 22:21:15
Put this in the .cc file, not the header. Just inc
zqiu1
2014/07/23 22:41:32
Done.
| |
| 21 | |
| 16 // Registers as observer with net::NetworkChangeNotifier and keeps track of | 22 // Registers as observer with net::NetworkChangeNotifier and keeps track of |
| 17 // the network environment. | 23 // the network environment. |
| 18 class NetworkMetricsProvider | 24 class NetworkMetricsProvider |
| 19 : public metrics::MetricsProvider, | 25 : public metrics::MetricsProvider, |
| 20 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 26 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 21 public: | 27 public: |
| 22 NetworkMetricsProvider(); | 28 NetworkMetricsProvider(); |
| 23 virtual ~NetworkMetricsProvider(); | 29 virtual ~NetworkMetricsProvider(); |
| 24 | 30 |
| 25 // metrics::MetricsProvider: | 31 // metrics::MetricsProvider: |
| 26 virtual void ProvideSystemProfileMetrics( | 32 virtual void ProvideSystemProfileMetrics( |
| 27 metrics::SystemProfileProto* system_profile) OVERRIDE; | 33 metrics::SystemProfileProto* system_profile) OVERRIDE; |
| 28 | 34 |
| 29 // ConnectionTypeObserver: | 35 // ConnectionTypeObserver: |
| 30 virtual void OnConnectionTypeChanged( | 36 virtual void OnConnectionTypeChanged( |
| 31 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 37 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 32 | 38 |
| 33 private: | 39 private: |
| 34 metrics::SystemProfileProto::Network::ConnectionType | 40 metrics::SystemProfileProto::Network::ConnectionType |
| 35 GetConnectionType() const; | 41 GetConnectionType() const; |
| 36 metrics::SystemProfileProto::Network::WifiPHYLayerProtocol | 42 metrics::SystemProfileProto::Network::WifiPHYLayerProtocol |
| 37 GetWifiPHYLayerProtocol() const; | 43 GetWifiPHYLayerProtocol() const; |
| 38 | 44 |
| 39 // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. | 45 // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. |
| 40 void ProbeWifiPHYLayerProtocol(); | 46 void ProbeWifiPHYLayerProtocol(); |
| 41 // Callback from the blocking pool with the result of | 47 // Callback from the blocking pool with the result of |
| 42 // net::GetWifiPHYLayerProtocol. | 48 // net::GetWifiPHYLayerProtocol. |
| 43 void OnWifiPHYLayerProtocolResult(net::WifiPHYLayerProtocol mode); | 49 void OnWifiPHYLayerProtocolResult(net::WifiPHYLayerProtocol mode); |
| 44 | 50 |
| 51 // Writes info about the wireless access points that this system is | |
| 52 // connected to. | |
| 53 void WriteWifiAccessPointProto( | |
| 54 const net::WifiAccessPointInfo& info, | |
| 55 metrics::SystemProfileProto::Network* network_proto); | |
| 56 | |
| 45 // True if |connection_type_| changed during the lifetime of the log. | 57 // True if |connection_type_| changed during the lifetime of the log. |
| 46 bool connection_type_is_ambiguous_; | 58 bool connection_type_is_ambiguous_; |
| 47 // The connection type according to net::NetworkChangeNotifier. | 59 // The connection type according to net::NetworkChangeNotifier. |
| 48 net::NetworkChangeNotifier::ConnectionType connection_type_; | 60 net::NetworkChangeNotifier::ConnectionType connection_type_; |
| 49 | 61 |
| 50 // True if |wifi_phy_layer_protocol_| changed during the lifetime of the log. | 62 // True if |wifi_phy_layer_protocol_| changed during the lifetime of the log. |
| 51 bool wifi_phy_layer_protocol_is_ambiguous_; | 63 bool wifi_phy_layer_protocol_is_ambiguous_; |
| 52 // The PHY mode of the currently associated access point obtained via | 64 // The PHY mode of the currently associated access point obtained via |
| 53 // net::GetWifiPHYLayerProtocol. | 65 // net::GetWifiPHYLayerProtocol. |
| 54 net::WifiPHYLayerProtocol wifi_phy_layer_protocol_; | 66 net::WifiPHYLayerProtocol wifi_phy_layer_protocol_; |
| 55 | 67 |
| 56 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; | 68 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; |
| 57 | 69 |
| 70 // Helper object for retrieving connected wifi access point information. | |
| 71 scoped_ptr<net::WifiAccessPointInfoProvider> wifi_access_point_info_provider_; | |
| 72 | |
| 58 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); | 73 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); |
| 59 }; | 74 }; |
| 60 | 75 |
| 61 #endif // CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ | 76 #endif // CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ |
| OLD | NEW |