diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-11-28 17:53:02 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-23 13:31:33 +0200 |
commit | 6a297c72dd8764dae831178e42335c37705f1084 (patch) | |
tree | 05e1a97bbe5a1fba4c10a6893fbe8c5f9eb06fc8 | |
parent | a8319f6aea3a14e60c23d4f14a681519aa78669d (diff) |
Leave a chance to all location providers to get a fix
In our case, the NetworkLocationProvider will always fail
for lack of a valid API token, and we don't want that to
take precedence over the QtPositioning-based backend.
Change-Id: Ic175bd3fb527a76a578ef3568f7ac7ed07c4ccad
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r-- | chromium/device/geolocation/location_arbitrator.cc | 15 | ||||
-rw-r--r-- | chromium/device/geolocation/location_arbitrator.h | 5 |
2 files changed, 14 insertions, 6 deletions
diff --git a/chromium/device/geolocation/location_arbitrator.cc b/chromium/device/geolocation/location_arbitrator.cc index 61370c6f813..a1ef78ca9b2 100644 --- a/chromium/device/geolocation/location_arbitrator.cc +++ b/chromium/device/geolocation/location_arbitrator.cc @@ -142,12 +142,15 @@ void LocationArbitrator::OnLocationUpdate( const mojom::Geoposition& new_position) { DCHECK(ValidateGeoposition(new_position) || new_position.error_code != mojom::Geoposition::ErrorCode::NONE); - if (!IsNewPositionBetter(position_, new_position, - provider == position_provider_)) - return; - position_provider_ = provider; - position_ = new_position; - arbitrator_update_callback_.Run(this, position_); + providers_polled_.insert(provider); + if (IsNewPositionBetter(position_, new_position, + provider == position_provider_)) { + position_provider_ = provider; + position_ = new_position; + } + // Don't fail until all providers had their say. + if (ValidateGeoposition(position_) || (providers_polled_.size() == providers_.size())) + arbitrator_update_callback_.Run(this, position_); } const mojom::Geoposition& LocationArbitrator::GetPosition() { diff --git a/chromium/device/geolocation/location_arbitrator.h b/chromium/device/geolocation/location_arbitrator.h index 8e1e9eced54..825af4d4c43 100644 --- a/chromium/device/geolocation/location_arbitrator.h +++ b/chromium/device/geolocation/location_arbitrator.h @@ -22,6 +22,8 @@ #include "services/device/public/mojom/geoposition.mojom.h" #include "url/gurl.h" +#include <set> + namespace net { class URLRequestContextGetter; } @@ -121,6 +123,9 @@ class DEVICE_GEOLOCATION_EXPORT LocationArbitrator // The current best estimate of our position. mojom::Geoposition position_; + // Used to track if all providers had a chance to provide a location. + std::set<const LocationProvider*> providers_polled_; + // The most recent position estimate returned by the network location // provider. This must be preserved by LocationArbitrator so it is not lost // when the provider is destroyed in StopProvider. |