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

Unified Diff: chrome/browser/net/nqe/ui_network_quality_estimator_service.cc

Issue 2742293004: Expose getters methods for NQE on UI thread (Closed)
Patch Set: ryansturm comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
diff --git a/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
index fd5cf787d7f91b7e5546b6f0a8ffed9494bd5606..1ea9d129e11ce50754b4f658ee28a5d4dc127222 100644
--- a/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
@@ -21,6 +21,7 @@
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_thread.h"
#include "net/nqe/network_qualities_prefs_manager.h"
+#include "net/nqe/network_quality.h"
namespace {
@@ -145,9 +146,9 @@ class UINetworkQualityEstimatorService::IONetworkQualityObserver
UINetworkQualityEstimatorService::UINetworkQualityEstimatorService(
Profile* profile)
: type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
- http_rtt_(base::TimeDelta::FromMilliseconds(-1)),
- transport_rtt_(base::TimeDelta::FromMilliseconds(-1)),
- downstream_throughput_kbps_(-1),
+ http_rtt_(net::nqe::internal::InvalidRTT()),
+ transport_rtt_(net::nqe::internal::InvalidRTT()),
+ downstream_throughput_kbps_(net::nqe::internal::kInvalidThroughput),
weak_factory_(this) {
DCHECK(profile);
// If this is running in a context without an IOThread, don't try to create
@@ -239,6 +240,33 @@ void UINetworkQualityEstimatorService::RemoveEffectiveConnectionTypeObserver(
effective_connection_type_observer_list_.RemoveObserver(observer);
}
+base::Optional<base::TimeDelta> UINetworkQualityEstimatorService::GetHttpRTT()
+ const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (http_rtt_ == net::nqe::internal::InvalidRTT())
+ return base::Optional<base::TimeDelta>();
+ return http_rtt_;
+}
+
+base::Optional<base::TimeDelta>
+UINetworkQualityEstimatorService::GetTransportRTT() const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (transport_rtt_ == net::nqe::internal::InvalidRTT())
+ return base::Optional<base::TimeDelta>();
+ return transport_rtt_;
+}
+
+base::Optional<int32_t>
+UINetworkQualityEstimatorService::GetDownstreamThroughputKbps() const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (downstream_throughput_kbps_ == net::nqe::internal::kInvalidThroughput)
+ return base::Optional<int32_t>();
+ return downstream_throughput_kbps_;
+}
+
void UINetworkQualityEstimatorService::AddRTTAndThroughputEstimatesObserver(
net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver* observer) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);

Powered by Google App Engine
This is Rietveld 408576698