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

Side by Side Diff: components/metrics/net/network_metrics_provider.h

Issue 558873002: Moves NetworkMetricsProvider to //components/metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed asvitkine comments 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
« no previous file with comments | « components/metrics/net/DEPS ('k') | components/metrics/net/network_metrics_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ 5 #ifndef COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ 6 #define COMPONENTS_METRICS_NET_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 "chrome/browser/metrics/wifi_access_point_info_provider.h"
12 #include "components/metrics/metrics_provider.h" 11 #include "components/metrics/metrics_provider.h"
12 #include "components/metrics/net/wifi_access_point_info_provider.h"
13 #include "components/metrics/proto/system_profile.pb.h" 13 #include "components/metrics/proto/system_profile.pb.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/base/network_change_notifier.h" 15 #include "net/base/network_change_notifier.h"
16 16
17 // Registers as observer with net::NetworkChangeNotifier and keeps track of 17 // Registers as observer with net::NetworkChangeNotifier and keeps track of
18 // the network environment. 18 // the network environment.
19 class NetworkMetricsProvider 19 class NetworkMetricsProvider
20 : public metrics::MetricsProvider, 20 : public metrics::MetricsProvider,
21 public net::NetworkChangeNotifier::ConnectionTypeObserver { 21 public net::NetworkChangeNotifier::ConnectionTypeObserver {
22 public: 22 public:
23 NetworkMetricsProvider(); 23 // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post
24 // network info collection tasks.
25 explicit NetworkMetricsProvider(base::TaskRunner* io_task_runner);
24 virtual ~NetworkMetricsProvider(); 26 virtual ~NetworkMetricsProvider();
25 27
26 private: 28 private:
27 // metrics::MetricsProvider: 29 // metrics::MetricsProvider:
28 virtual void OnDidCreateMetricsLog() OVERRIDE; 30 virtual void OnDidCreateMetricsLog() OVERRIDE;
29 virtual void ProvideSystemProfileMetrics( 31 virtual void ProvideSystemProfileMetrics(
30 metrics::SystemProfileProto* system_profile) OVERRIDE; 32 metrics::SystemProfileProto* system_profile) OVERRIDE;
31 33
32 // ConnectionTypeObserver: 34 // ConnectionTypeObserver:
33 virtual void OnConnectionTypeChanged( 35 virtual void OnConnectionTypeChanged(
34 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 36 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
35 37
36 metrics::SystemProfileProto::Network::ConnectionType 38 metrics::SystemProfileProto::Network::ConnectionType
37 GetConnectionType() const; 39 GetConnectionType() const;
38 metrics::SystemProfileProto::Network::WifiPHYLayerProtocol 40 metrics::SystemProfileProto::Network::WifiPHYLayerProtocol
39 GetWifiPHYLayerProtocol() const; 41 GetWifiPHYLayerProtocol() const;
40 42
41 // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. 43 // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool.
42 void ProbeWifiPHYLayerProtocol(); 44 void ProbeWifiPHYLayerProtocol();
43 // Callback from the blocking pool with the result of 45 // Callback from the blocking pool with the result of
44 // net::GetWifiPHYLayerProtocol. 46 // net::GetWifiPHYLayerProtocol.
45 void OnWifiPHYLayerProtocolResult(net::WifiPHYLayerProtocol mode); 47 void OnWifiPHYLayerProtocolResult(net::WifiPHYLayerProtocol mode);
46 48
47 // Writes info about the wireless access points that this system is 49 // Writes info about the wireless access points that this system is
48 // connected to. 50 // connected to.
49 void WriteWifiAccessPointProto( 51 void WriteWifiAccessPointProto(
50 const WifiAccessPointInfoProvider::WifiAccessPointInfo& info, 52 const WifiAccessPointInfoProvider::WifiAccessPointInfo& info,
51 metrics::SystemProfileProto::Network* network_proto); 53 metrics::SystemProfileProto::Network* network_proto);
52 54
55 // Task runner used for blocking file I/O.
56 base::TaskRunner* io_task_runner_;
57
53 // True if |connection_type_| changed during the lifetime of the log. 58 // True if |connection_type_| changed during the lifetime of the log.
54 bool connection_type_is_ambiguous_; 59 bool connection_type_is_ambiguous_;
55 // The connection type according to net::NetworkChangeNotifier. 60 // The connection type according to net::NetworkChangeNotifier.
56 net::NetworkChangeNotifier::ConnectionType connection_type_; 61 net::NetworkChangeNotifier::ConnectionType connection_type_;
57 62
58 // True if |wifi_phy_layer_protocol_| changed during the lifetime of the log. 63 // True if |wifi_phy_layer_protocol_| changed during the lifetime of the log.
59 bool wifi_phy_layer_protocol_is_ambiguous_; 64 bool wifi_phy_layer_protocol_is_ambiguous_;
60 // The PHY mode of the currently associated access point obtained via 65 // The PHY mode of the currently associated access point obtained via
61 // net::GetWifiPHYLayerProtocol. 66 // net::GetWifiPHYLayerProtocol.
62 net::WifiPHYLayerProtocol wifi_phy_layer_protocol_; 67 net::WifiPHYLayerProtocol wifi_phy_layer_protocol_;
63 68
64 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; 69 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_;
65 70
66 // Helper object for retrieving connected wifi access point information. 71 // Helper object for retrieving connected wifi access point information.
67 scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_; 72 scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_;
68 73
69 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); 74 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider);
70 }; 75 };
71 76
72 #endif // CHROME_BROWSER_METRICS_NETWORK_METRICS_PROVIDER_H_ 77 #endif // COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_
OLDNEW
« no previous file with comments | « components/metrics/net/DEPS ('k') | components/metrics/net/network_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698