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

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

Issue 2717153002: NQE: Plumb RTT and throughput estimates to the UI thread (Closed)
Patch Set: Rebase, Fix more compilation errors 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_test_util.cc
diff --git a/chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.cc b/chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.cc
index fe3e55cb9248d53d068dd8bc8e5c53f518626571..d1eac6a2218bbf726ca4e3bd6713b8e79fca544c 100644
--- a/chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.cc
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.cc
@@ -28,6 +28,16 @@ void OverrideEffectiveConnectionTypeOnIO(net::EffectiveConnectionType type,
network_quality_estimator->ReportEffectiveConnectionTypeForTesting(type);
}
+void OverrideRTTsAndWaitOnIO(base::TimeDelta rtt, IOThread* io_thread) {
+ if (!io_thread->globals()->network_quality_estimator)
+ return;
+ net::NetworkQualityEstimator* network_quality_estimator =
+ io_thread->globals()->network_quality_estimator.get();
+ if (!network_quality_estimator)
+ return;
+ network_quality_estimator->ReportRTTsAndThroughputForTesting(rtt, rtt, -1);
+}
+
} // namespace
void OverrideEffectiveConnectionTypeAndWait(net::EffectiveConnectionType type) {
@@ -43,4 +53,16 @@ void OverrideEffectiveConnectionTypeAndWait(net::EffectiveConnectionType type) {
run_loop.Run();
}
+void OverrideRTTsAndWait(base::TimeDelta rtt) {
+ // Block |run_loop| until OverrideRTTsAndWaitOnIO has completed.
+ // Any UI tasks posted by calling OverrideRTTsAndWaitOnIO will complete before
+ // the reply unblocks |run_loop|.
+ base::RunLoop run_loop;
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&OverrideRTTsAndWaitOnIO, rtt, g_browser_process->io_thread()),
+ run_loop.QuitClosure());
+ run_loop.Run();
+}
+
} // namespace nqe_test_util

Powered by Google App Engine
This is Rietveld 408576698