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