Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/message_loop/message_loop.h" | |
| 9 #include "base/task_runner.h" | |
| 10 #include "chrome/browser/browser_process.h" | |
| 11 #include "chrome/browser/net/nqe/io_network_quality_observer.h" | |
| 12 | |
| 13 UINetworkQualityEstimatorService::UINetworkQualityEstimatorService( | |
| 14 Profile* profile) | |
| 15 : type_(net::NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN), | |
| 16 observer_(nullptr), | |
| 17 weak_factory_(this) { | |
| 18 } | |
| 19 | |
| 20 UINetworkQualityEstimatorService::~UINetworkQualityEstimatorService() { | |
| 21 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.
| |
| 22 } | |
| 23 | |
| 24 void UINetworkQualityEstimatorService::Initialize( | |
| 25 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 26 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { | |
| 27 io_task_runner_ = io_task_runner; | |
| 28 observer_ = | |
| 29 new IONetworkQualityObserver(ui_task_runner, weak_factory_.GetWeakPtr()); | |
| 30 io_task_runner_->PostTask( | |
| 31 FROM_HERE, | |
| 32 base::Bind(&IONetworkQualityObserver::InitializeOnIOThread, | |
| 33 base::Unretained(observer_), g_browser_process->io_thread())); | |
| 34 } | |
| 35 | |
| 36 void UINetworkQualityEstimatorService::Shutdown() { | |
| 37 LOG(WARNING) << "UINetworkQualityEstimatorService::Shutdown"; | |
| 38 weak_factory_.InvalidateWeakPtrs(); | |
| 39 } | |
| 40 | |
| 41 void UINetworkQualityEstimatorService::EffectiveConnectionTypeChanged( | |
| 42 net::NetworkQualityEstimator::EffectiveConnectionType type) { | |
| 43 type_ = type; | |
| 44 } | |
| OLD | NEW |