Commit 4cc4b915 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

NetworkService: Hook up NetworkChangeNotifier's HistogramWatcher.

Unfortunately, the old patch to set it up in IOThread is still needed,
since the in-process NetworkService is leaked when the OOP network
service is disabled.

Bug=853211

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ic216b2d83d703cff776a77aaea6a2244a9eca367
Reviewed-on: https://chromium-review.googlesource.com/1105068Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568806}
parent 6220ec58
......@@ -744,6 +744,7 @@ void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request,
void NetworkChangeNotifier::InitHistogramWatcher() {
if (!g_network_change_notifier)
return;
DCHECK(!g_network_change_notifier->histogram_watcher_);
g_network_change_notifier->histogram_watcher_.reset(new HistogramWatcher());
g_network_change_notifier->histogram_watcher_->Init();
}
......@@ -752,6 +753,7 @@ void NetworkChangeNotifier::InitHistogramWatcher() {
void NetworkChangeNotifier::ShutdownHistogramWatcher() {
if (!g_network_change_notifier)
return;
DCHECK(g_network_change_notifier->histogram_watcher_);
g_network_change_notifier->histogram_watcher_.reset();
}
......
......@@ -18,9 +18,19 @@ NetworkChangeManager::NetworkChangeManager(
net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
connection_type_ =
mojom::ConnectionType(net::NetworkChangeNotifier::GetConnectionType());
// Only initialize the NetworkChangeNotifier's HistogramWatcher if this class
// owns the NCN. Otherwise, can't ensure lifetime guarantees are met, so just
// rely on the embedder to set it up, if needed.
// TODO(mmenke): Once the network service ships, this class should always own
// the NCN, and then this can be done unconditionally.
if (network_change_notifier_)
net::NetworkChangeNotifier::InitHistogramWatcher();
}
NetworkChangeManager::~NetworkChangeManager() {
// Shut down the HistogramWatcher, if it was started in the constructor.
if (network_change_notifier_)
net::NetworkChangeNotifier::ShutdownHistogramWatcher();
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
}
......
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