Commit 524692f9 authored by ryansturm's avatar ryansturm Committed by Commit bot

Cleaning up some code in UINQEService

This should allow some unittests (specifically offline pages related
unittests) to create the UINQEService despite not being a browser
process with no IOThread.

BUG=

Review-Url: https://codereview.chromium.org/2172393002
Cr-Commit-Position: refs/heads/master@{#407274}
parent 0fd36aeb
......@@ -64,12 +64,15 @@ class UINetworkQualityEstimatorService::IONetworkQualityObserver
DISALLOW_COPY_AND_ASSIGN(IONetworkQualityObserver);
};
UINetworkQualityEstimatorService::UINetworkQualityEstimatorService(
Profile* profile)
UINetworkQualityEstimatorService::UINetworkQualityEstimatorService()
: type_(net::NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
io_observer_(nullptr),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// If this is running in a context without an IOThread, don't try to create
// the IO object.
if (!g_browser_process->io_thread())
return;
io_observer_ = new IONetworkQualityObserver(weak_factory_.GetWeakPtr());
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
......
......@@ -7,16 +7,13 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "components/keyed_service/core/keyed_service.h"
#include "net/nqe/network_quality_estimator.h"
class Profile;
// UI service to determine the current EffectiveConnectionType.
class UINetworkQualityEstimatorService : public KeyedService {
public:
explicit UINetworkQualityEstimatorService(Profile* profile);
UINetworkQualityEstimatorService();
~UINetworkQualityEstimatorService() override;
// The current EffectiveConnectionType.
......
......@@ -34,6 +34,5 @@ UINetworkQualityEstimatorServiceFactory::
KeyedService* UINetworkQualityEstimatorServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
return new UINetworkQualityEstimatorService(profile);
return new UINetworkQualityEstimatorService();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment