summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@theqtcompany.com>2014-11-28 17:53:02 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-22 15:02:08 +0100
commit12bbceb234bd2e8a559ad968a5c43b82145d7710 (patch)
tree876e3be55918153d0d25e33816103ce22af136da
parent86153a8b45ea0f889278c09d82964f0634d9bfd8 (diff)
downloadqtwebengine-chromium-12bbceb234bd2e8a559ad968a5c43b82145d7710.tar.gz
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.cc15
-rw-r--r--chromium/device/geolocation/location_arbitrator.h5
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 <set>
+
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<const LocationProvider*> providers_polled_;
+
// Tracks whether providers should be running.
bool is_running_;