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 #include "components/metrics/net/network_metrics_provider.h" | 5 #include "components/metrics/net/network_metrics_provider.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 24 #include "net/nqe/effective_connection_type_observer.h" |
24 #include "net/nqe/network_quality_estimator.h" | 25 #include "net/nqe/network_quality_estimator.h" |
25 | 26 |
26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
27 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" | 28 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" |
28 #endif // OS_CHROMEOS | 29 #endif // OS_CHROMEOS |
29 | 30 |
30 namespace metrics { | 31 namespace metrics { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 // Gets the network quality estimator from |network_quality_estimator_provider|, | 35 // Gets the network quality estimator from |network_quality_estimator_provider|, |
35 // and provides it to the |callback|. | 36 // and provides it to the |callback|. |
36 void GetAndSetNetworkQualityEstimator( | 37 void GetAndSetNetworkQualityEstimator( |
37 const base::Callback<void(net::NetworkQualityEstimator*)>& callback, | 38 const base::Callback<void(net::NetworkQualityEstimator*)>& callback, |
38 NetworkMetricsProvider::NetworkQualityEstimatorProvider* | 39 NetworkMetricsProvider::NetworkQualityEstimatorProvider* |
39 network_quality_estimator_provider) { | 40 network_quality_estimator_provider) { |
40 callback.Run( | 41 callback.Run( |
41 network_quality_estimator_provider->GetNetworkQualityEstimator()); | 42 network_quality_estimator_provider->GetNetworkQualityEstimator()); |
42 } | 43 } |
43 | 44 |
44 } // namespace | 45 } // namespace |
45 | 46 |
46 // Listens to the changes in the effective conection type. | 47 // Listens to the changes in the effective conection type. |
47 class NetworkMetricsProvider::EffectiveConnectionTypeObserver | 48 class NetworkMetricsProvider::EffectiveConnectionTypeObserver |
48 : public net::NetworkQualityEstimator::EffectiveConnectionTypeObserver { | 49 : public net::EffectiveConnectionTypeObserver { |
49 public: | 50 public: |
50 // |network_quality_estimator| is used to provide the network quality | 51 // |network_quality_estimator| is used to provide the network quality |
51 // estimates. Guaranteed to be non-null. |callback| is run on | 52 // estimates. Guaranteed to be non-null. |callback| is run on |
52 // |callback_task_runner|, and provides notifications about the changes in the | 53 // |callback_task_runner|, and provides notifications about the changes in the |
53 // effective connection type. | 54 // effective connection type. |
54 EffectiveConnectionTypeObserver( | 55 EffectiveConnectionTypeObserver( |
55 base::Callback<void(net::EffectiveConnectionType)> callback, | 56 base::Callback<void(net::EffectiveConnectionType)> callback, |
56 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) | 57 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) |
57 : network_quality_estimator_(nullptr), | 58 : network_quality_estimator_(nullptr), |
58 callback_(callback), | 59 callback_(callback), |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 DCHECK(thread_checker_.CalledOnValidThread()); | 432 DCHECK(thread_checker_.CalledOnValidThread()); |
432 if (effective_connection_type_ != type && | 433 if (effective_connection_type_ != type && |
433 type != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN && | 434 type != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN && |
434 effective_connection_type_ != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { | 435 effective_connection_type_ != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { |
435 effective_connection_type_is_ambiguous_ = true; | 436 effective_connection_type_is_ambiguous_ = true; |
436 } | 437 } |
437 effective_connection_type_ = type; | 438 effective_connection_type_ = type; |
438 } | 439 } |
439 | 440 |
440 } // namespace metrics | 441 } // namespace metrics |
OLD | NEW |