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

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

Issue 2103323007: Exposing NQE on the Browser UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
new file mode 100644
index 0000000000000000000000000000000000000000..c2e6b12f360e25b0e8ab57095aefb5679a9b629d
--- /dev/null
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/task_runner.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/net/nqe/io_network_quality_observer.h"
+
+UINetworkQualityEstimatorService::UINetworkQualityEstimatorService(
+ Profile* profile)
+ : type_(net::NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
+ observer_(nullptr),
+ weak_factory_(this) {
+}
+
+UINetworkQualityEstimatorService::~UINetworkQualityEstimatorService() {
+ io_task_runner_->DeleteSoon(FROM_HERE, observer_);
tbansal1 2016/07/01 22:22:02 DCHECK the return value.
RyanSturm 2016/07/11 22:00:19 Done.
+}
+
+void UINetworkQualityEstimatorService::Initialize(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) {
+ io_task_runner_ = io_task_runner;
+ observer_ =
+ new IONetworkQualityObserver(ui_task_runner, weak_factory_.GetWeakPtr());
+ io_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&IONetworkQualityObserver::InitializeOnIOThread,
+ base::Unretained(observer_), g_browser_process->io_thread()));
+}
+
+void UINetworkQualityEstimatorService::Shutdown() {
+ LOG(WARNING) << "UINetworkQualityEstimatorService::Shutdown";
+ weak_factory_.InvalidateWeakPtrs();
+}
+
+void UINetworkQualityEstimatorService::EffectiveConnectionTypeChanged(
+ net::NetworkQualityEstimator::EffectiveConnectionType type) {
+ type_ = type;
+}

Powered by Google App Engine
This is Rietveld 408576698