From 12bbceb234bd2e8a559ad968a5c43b82145d7710 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 28 Nov 2014 17:53:02 +0100 Subject: Leave a chance to all location providers to get a fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- chromium/device/geolocation/location_arbitrator.cc | 15 +++++++++------ 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 2e10c303e63..a83983bf3a8 100644 --- a/chromium/device/geolocation/location_arbitrator.cc +++ b/chromium/device/geolocation/location_arbitrator.cc @@ -130,12 +130,15 @@ void LocationArbitrator::OnLocationUpdate(const LocationProvider* provider, const Geoposition& new_position) { DCHECK(new_position.Validate() || new_position.error_code != Geoposition::ERROR_CODE_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 (position_.Validate() || (providers_polled_.size() == providers_.size())) + arbitrator_update_callback_.Run(this, position_); } const Geoposition& LocationArbitrator::GetPosition() { diff --git a/chromium/device/geolocation/location_arbitrator.h b/chromium/device/geolocation/location_arbitrator.h index 6f6684f42ef..72a8ed5f03c 100644 --- a/chromium/device/geolocation/location_arbitrator.h +++ b/chromium/device/geolocation/location_arbitrator.h @@ -21,6 +21,8 @@ #include "device/geolocation/location_provider.h" #include "net/url_request/url_request_context_getter.h" +#include + namespace net { class URLRequestContextGetter; } @@ -115,6 +117,9 @@ class DEVICE_GEOLOCATION_EXPORT LocationArbitrator : public LocationProvider { // The current best estimate of our position. Geoposition position_; + // Used to track if all providers had a chance to provide a location. + std::set providers_polled_; + // Tracks whether providers should be running. bool is_running_; -- cgit v1.2.1