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

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: ps 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..bdfd49e585dc053dc3c905809bf9aaf1e5ee181d 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,36 @@ void UINetworkQualityEstimatorService::RemoveEffectiveConnectionTypeObserver(
effective_connection_type_observer_list_.RemoveObserver(observer);
}
+bool UINetworkQualityEstimatorService::GetHttpRTT(
+ base::TimeDelta* http_rtt) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (http_rtt_ == net::nqe::internal::InvalidRTT())
+ return false;
+ *http_rtt = http_rtt_;
+ return true;
+}
+
+bool UINetworkQualityEstimatorService::GetTransportRTT(
+ base::TimeDelta* transport_rtt) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (transport_rtt_ == net::nqe::internal::InvalidRTT())
+ return false;
+ *transport_rtt = transport_rtt_;
+ return true;
+}
+
+bool UINetworkQualityEstimatorService::GetDownstreamThroughputKbps(
+ int32_t* downstream_throughput_kbps) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (downstream_throughput_kbps_ == net::nqe::internal::kInvalidThroughput)
+ return false;
+ *downstream_throughput_kbps = downstream_throughput_kbps_;
+ return true;
+}
+
void UINetworkQualityEstimatorService::AddRTTAndThroughputEstimatesObserver(
net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver* observer) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);

Powered by Google App Engine
This is Rietveld 408576698