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 COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_ | 5 #ifndef COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_ |
6 #define COMPONENTS_METRICS_NET_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 "components/metrics/metrics_provider.h" | 11 #include "components/metrics/metrics_provider.h" |
12 #include "components/metrics/net/wifi_access_point_info_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 namespace metrics { | 17 namespace metrics { |
18 | 18 |
19 // Registers as observer with net::NetworkChangeNotifier and keeps track of | 19 // Registers as observer with net::NetworkChangeNotifier and keeps track of |
20 // the network environment. | 20 // the network environment. |
21 class NetworkMetricsProvider | 21 class NetworkMetricsProvider |
22 : public MetricsProvider, | 22 : public MetricsProvider, |
23 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 23 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
24 public: | 24 public: |
25 // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post | 25 // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post |
26 // network info collection tasks. | 26 // network info collection tasks. |
27 explicit NetworkMetricsProvider(base::TaskRunner* io_task_runner); | 27 explicit NetworkMetricsProvider(base::TaskRunner* io_task_runner); |
28 ~NetworkMetricsProvider() override; | 28 ~NetworkMetricsProvider() override; |
29 | 29 |
30 // Returns true if the connection type is 2G, 3G, or 4G. | |
31 bool IsCellularConnection(); | |
32 | |
33 // Assigns the passed |is_cellular_out| parameter based on whether current | |
34 // network connection is cellular. | |
35 void GetIsCellularConnection(bool* is_cellular_out); | |
Alexei Svitkine (slow)
2015/02/23 18:54:06
This can be private.
gayane -on leave until 09-2017
2015/02/23 20:14:09
Done.
| |
36 | |
37 // Returns callback function which can be used to get whether current | |
38 // connection type is cellular. | |
39 base::Callback<void(bool*)> GetConnectionCallback(); | |
40 | |
30 private: | 41 private: |
31 // MetricsProvider: | 42 // MetricsProvider: |
32 void OnDidCreateMetricsLog() override; | 43 void OnDidCreateMetricsLog() override; |
33 void ProvideSystemProfileMetrics(SystemProfileProto* system_profile) override; | 44 void ProvideSystemProfileMetrics(SystemProfileProto* system_profile) override; |
34 | 45 |
35 // ConnectionTypeObserver: | 46 // ConnectionTypeObserver: |
36 void OnConnectionTypeChanged( | 47 void OnConnectionTypeChanged( |
37 net::NetworkChangeNotifier::ConnectionType type) override; | 48 net::NetworkChangeNotifier::ConnectionType type) override; |
38 | 49 |
39 SystemProfileProto::Network::ConnectionType GetConnectionType() const; | 50 SystemProfileProto::Network::ConnectionType GetConnectionType() const; |
(...skipping 30 matching lines...) Expand all Loading... | |
70 scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_; | 81 scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_; |
71 | 82 |
72 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; | 83 base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; |
73 | 84 |
74 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); | 85 DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); |
75 }; | 86 }; |
76 | 87 |
77 } // namespace metrics | 88 } // namespace metrics |
78 | 89 |
79 #endif // COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_ | 90 #endif // COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_ |
OLD | NEW |