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

Side by Side Diff: net/nqe/network_quality_estimator.h

Issue 2183153002: NQE: Move ECT to net:: namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, also fixed comnpilation error Created 4 years, 4 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 | « net/nqe/effective_connection_type.h ('k') | net/nqe/network_quality_estimator.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/threading/thread_checker.h" 20 #include "base/threading/thread_checker.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 #include "net/nqe/cached_network_quality.h" 24 #include "net/nqe/cached_network_quality.h"
25 #include "net/nqe/effective_connection_type.h"
25 #include "net/nqe/external_estimate_provider.h" 26 #include "net/nqe/external_estimate_provider.h"
26 #include "net/nqe/network_id.h" 27 #include "net/nqe/network_id.h"
27 #include "net/nqe/network_quality.h" 28 #include "net/nqe/network_quality.h"
28 #include "net/nqe/network_quality_observation.h" 29 #include "net/nqe/network_quality_observation.h"
29 #include "net/nqe/network_quality_observation_source.h" 30 #include "net/nqe/network_quality_observation_source.h"
30 #include "net/nqe/network_quality_store.h" 31 #include "net/nqe/network_quality_store.h"
31 #include "net/nqe/observation_buffer.h" 32 #include "net/nqe/observation_buffer.h"
32 #include "net/socket/socket_performance_watcher_factory.h" 33 #include "net/socket/socket_performance_watcher_factory.h"
33 34
34 namespace base { 35 namespace base {
(...skipping 15 matching lines...) Expand all
50 // The estimates are based on the observed organic traffic. 51 // The estimates are based on the observed organic traffic.
51 // A NetworkQualityEstimator instance is attached to URLRequestContexts and 52 // A NetworkQualityEstimator instance is attached to URLRequestContexts and
52 // observes the traffic of URLRequests spawned from the URLRequestContexts. 53 // observes the traffic of URLRequests spawned from the URLRequestContexts.
53 // A single instance of NQE can be attached to multiple URLRequestContexts, 54 // A single instance of NQE can be attached to multiple URLRequestContexts,
54 // thereby increasing the single NQE instance's accuracy by providing more 55 // thereby increasing the single NQE instance's accuracy by providing more
55 // observed traffic characteristics. 56 // observed traffic characteristics.
56 class NET_EXPORT NetworkQualityEstimator 57 class NET_EXPORT NetworkQualityEstimator
57 : public NetworkChangeNotifier::ConnectionTypeObserver, 58 : public NetworkChangeNotifier::ConnectionTypeObserver,
58 public ExternalEstimateProvider::UpdatedEstimateDelegate { 59 public ExternalEstimateProvider::UpdatedEstimateDelegate {
59 public: 60 public:
60 // EffectiveConnectionType is the connection type whose typical performance is
61 // most similar to the measured performance of the network in use. In many
62 // cases, the "effective" connection type and the actual type of connection in
63 // use are the same, but often a network connection performs significantly
64 // different, usually worse, from its expected capabilities.
65 // EffectiveConnectionType of a network is independent of if the current
66 // connection is metered or not. For example, an unmetered slow connection may
67 // have EFFECTIVE_CONNECTION_TYPE_SLOW_2G as its effective connection type.
68 enum EffectiveConnectionType {
69 // The connection types should be in increasing order of quality.
70 EFFECTIVE_CONNECTION_TYPE_UNKNOWN = 0,
71 EFFECTIVE_CONNECTION_TYPE_OFFLINE,
72 EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
73 EFFECTIVE_CONNECTION_TYPE_2G,
74 EFFECTIVE_CONNECTION_TYPE_3G,
75 EFFECTIVE_CONNECTION_TYPE_4G,
76 EFFECTIVE_CONNECTION_TYPE_BROADBAND,
77 EFFECTIVE_CONNECTION_TYPE_LAST,
78 };
79
80 // Observes changes in effective connection type. 61 // Observes changes in effective connection type.
81 class NET_EXPORT EffectiveConnectionTypeObserver { 62 class NET_EXPORT EffectiveConnectionTypeObserver {
82 public: 63 public:
83 // Notifies the observer of a change in the effective connection type. 64 // Notifies the observer of a change in the effective connection type.
84 // NetworkQualityEstimator computes the effective connection type once in 65 // NetworkQualityEstimator computes the effective connection type once in
85 // every interval of duration 66 // every interval of duration
86 // |effective_connection_type_recomputation_interval_|. Additionally, when 67 // |effective_connection_type_recomputation_interval_|. Additionally, when
87 // there is a change in the connection type of the device, then the 68 // there is a change in the connection type of the device, then the
88 // effective connection type is immediately recomputed. The observer must 69 // effective connection type is immediately recomputed. The observer must
89 // register and unregister itself on the IO thread. All the observers would 70 // register and unregister itself on the IO thread. All the observers would
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 // Default network quality observations obtained from the network quality 543 // Default network quality observations obtained from the network quality
563 // estimator field trial parameters. The observations are indexed by 544 // estimator field trial parameters. The observations are indexed by
564 // ConnectionType. 545 // ConnectionType.
565 nqe::internal::NetworkQuality 546 nqe::internal::NetworkQuality
566 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; 547 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1];
567 548
568 // Default thresholds for different effective connection types. The default 549 // Default thresholds for different effective connection types. The default
569 // values are used if the thresholds are unavailable from the variation 550 // values are used if the thresholds are unavailable from the variation
570 // params. 551 // params.
571 nqe::internal::NetworkQuality default_effective_connection_type_thresholds_ 552 nqe::internal::NetworkQuality default_effective_connection_type_thresholds_
572 [EFFECTIVE_CONNECTION_TYPE_LAST]; 553 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST];
573 554
574 // Thresholds for different effective connection types obtained from field 555 // Thresholds for different effective connection types obtained from field
575 // trial variation params. These thresholds encode how different connection 556 // trial variation params. These thresholds encode how different connection
576 // types behave in general. In future, complex encodings (e.g., curve 557 // types behave in general. In future, complex encodings (e.g., curve
577 // fitting) may be used. 558 // fitting) may be used.
578 nqe::internal::NetworkQuality 559 nqe::internal::NetworkQuality connection_thresholds_
579 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST]; 560 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST];
580 561
581 // Latest time when the headers for a main frame request were received. 562 // Latest time when the headers for a main frame request were received.
582 base::TimeTicks last_main_frame_request_; 563 base::TimeTicks last_main_frame_request_;
583 564
584 // Estimated network quality when the response headers for the last mainframe 565 // Estimated network quality when the response headers for the last mainframe
585 // request were received. 566 // request were received.
586 nqe::internal::NetworkQuality estimated_quality_at_last_main_frame_; 567 nqe::internal::NetworkQuality estimated_quality_at_last_main_frame_;
587 EffectiveConnectionType effective_connection_type_at_last_main_frame_; 568 EffectiveConnectionType effective_connection_type_at_last_main_frame_;
588 569
589 // Estimated network quality obtained from external estimate provider when the 570 // Estimated network quality obtained from external estimate provider when the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 base::ThreadChecker thread_checker_; 615 base::ThreadChecker thread_checker_;
635 616
636 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 617 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
637 618
638 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 619 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
639 }; 620 };
640 621
641 } // namespace net 622 } // namespace net
642 623
643 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 624 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « net/nqe/effective_connection_type.h ('k') | net/nqe/network_quality_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698