Commit 1b4aedb2 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Move PublicIpAddressGeolocationProvider to main device service thread

This class has been updated to use network::SimpleURLLoader and so no
longer needs to run on the IO thread in order to access a
URLRequestContextGetter. It is now incorrect to run on the IO thread
because as long as the device service is hosted in the browser process
it is using a SharedURLLoaderFactory that can only be accessed from the
UI thread.

Bug: 875283
Change-Id: I68181566aeb50dc460a32acc6afc58a9054f46a6
Reviewed-on: https://chromium-review.googlesource.com/1183969Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585063}
parent 33bd6642
......@@ -110,11 +110,6 @@ DeviceService::~DeviceService() {
#if !defined(OS_ANDROID)
device::BatteryStatusService::GetInstance()->Shutdown();
#endif
if (public_ip_address_geolocation_provider_) {
DCHECK(io_task_runner_);
io_task_runner_->DeleteSoon(
FROM_HERE, std::move(public_ip_address_geolocation_provider_));
}
}
void DeviceService::OnStart() {
......@@ -130,8 +125,7 @@ void DeviceService::OnStart() {
&DeviceService::BindPowerMonitorRequest, base::Unretained(this)));
registry_.AddInterface<mojom::PublicIpAddressGeolocationProvider>(
base::Bind(&DeviceService::BindPublicIpAddressGeolocationProviderRequest,
base::Unretained(this)),
io_task_runner_);
base::Unretained(this)));
registry_.AddInterface<mojom::ScreenOrientationListener>(
base::Bind(&DeviceService::BindScreenOrientationListenerRequest,
base::Unretained(this)));
......@@ -255,16 +249,11 @@ void DeviceService::BindPowerMonitorRequest(
void DeviceService::BindPublicIpAddressGeolocationProviderRequest(
mojom::PublicIpAddressGeolocationProviderRequest request) {
// This needs to run on IO thread because it uses URLRequestContextGetters
// which must not outlive that thread.
DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
if (!public_ip_address_geolocation_provider_) {
public_ip_address_geolocation_provider_ =
std::make_unique<PublicIpAddressGeolocationProvider>(
url_loader_factory_, geolocation_api_key_);
}
public_ip_address_geolocation_provider_->Bind(std::move(request));
}
......
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