OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/common/metrics/proto/system_profile.pb.h" |
| 12 #include "net/base/net_util.h" |
| 13 #include "net/base/network_change_notifier.h" |
| 14 |
| 15 using metrics::SystemProfileProto; |
| 16 |
| 17 // Registers as observer with net::NetworkChangeNotifier and keeps track of |
| 18 // the network environment. |
| 19 class MetricsNetworkObserver |
| 20 : public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 21 public: |
| 22 MetricsNetworkObserver(); |
| 23 virtual ~MetricsNetworkObserver(); |
| 24 |
| 25 // Resets the "ambiguous" flags. Call when the environment is recorded. |
| 26 void Reset(); |
| 27 |
| 28 // ConnectionTypeObserver: |
| 29 virtual void OnConnectionTypeChanged( |
| 30 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 31 |
| 32 bool connection_type_is_ambiguous() const { |
| 33 return connection_type_is_ambiguous_; |
| 34 } |
| 35 |
| 36 SystemProfileProto::Network::ConnectionType connection_type() const; |
| 37 |
| 38 bool wifi_phy_layer_protocol_is_ambiguous() const { |
| 39 return wifi_phy_layer_protocol_is_ambiguous_; |
| 40 } |
| 41 |
| 42 SystemProfileProto::Network::WifiPHYLayerProtocol |
| 43 wifi_phy_layer_protocol() const; |
| 44 |
| 45 private: |
| 46 // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. |
| 47 void ProbeWifiPHYLayerProtocol(); |
| 48 // Callback from the blocking pool with the result of |
| 49 // net::GetWifiPHYLayerProtocol. |
| 50 void OnWifiPHYLayerProtocolResult(net::WifiPHYLayerProtocol* mode); |
| 51 |
| 52 base::WeakPtrFactory<MetricsNetworkObserver> weak_ptr_factory_; |
| 53 |
| 54 // True if |connection_type_| changed during the lifetime of the log. |
| 55 bool connection_type_is_ambiguous_; |
| 56 // The connection type according to net::NetworkChangeNotifier. |
| 57 net::NetworkChangeNotifier::ConnectionType connection_type_; |
| 58 |
| 59 // True if |wifi_phy_layer_protocol_| changed during the lifetime of the log. |
| 60 bool wifi_phy_layer_protocol_is_ambiguous_; |
| 61 // The PHY mode of the currently associated access point obtained via |
| 62 // net::GetWifiPHYLayerProtocol. |
| 63 net::WifiPHYLayerProtocol wifi_phy_layer_protocol_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(MetricsNetworkObserver); |
| 66 }; |
| 67 |
| 68 #endif // CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_ |
OLD | NEW |