summaryrefslogtreecommitdiffstats
path: root/WebCore/page/Geolocation.cpp
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2010-12-07 17:22:45 -0800
committerShimeng (Simon) Wang <swang@google.com>2010-12-22 14:15:40 -0800
commit4576aa36e9a9671459299c7963ac95aa94beaea9 (patch)
tree3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/page/Geolocation.cpp
parent55323ac613cc31553107b68603cb627264d22bb0 (diff)
downloadexternal_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/page/Geolocation.cpp')
-rw-r--r--WebCore/page/Geolocation.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 65c8902..cabfdef 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -525,6 +525,30 @@ void Geolocation::cancelAllRequests()
cancelRequests(copy);
}
+void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, GeoNotifierVector* cached)
+{
+ GeoNotifierVector nonCached;
+ GeoNotifierVector::iterator end = notifiers.end();
+ for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) {
+ GeoNotifier* notifier = it->get();
+ if (notifier->m_useCachedPosition) {
+ if (cached)
+ cached->append(notifier);
+ } else
+ nonCached.append(notifier);
+ }
+ notifiers.swap(nonCached);
+}
+
+void Geolocation::copyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest)
+{
+ GeoNotifierVector::const_iterator end = src.end();
+ for (GeoNotifierVector::const_iterator it = src.begin(); it != end; ++it) {
+ GeoNotifier* notifier = it->get();
+ dest.add(notifier);
+ }
+}
+
void Geolocation::handleError(PositionError* error)
{
ASSERT(error);
@@ -538,15 +562,27 @@ void Geolocation::handleError(PositionError* error)
// Clear the lists before we make the callbacks, to avoid clearing notifiers
// added by calls to Geolocation methods from the callbacks, and to prevent
// further callbacks to these notifiers.
+ GeoNotifierVector oneShotsWithCachedPosition;
m_oneShots.clear();
if (error->isFatal())
m_watchers.clear();
+ else {
+ // Don't send non-fatal errors to notifiers due to receive a cached position.
+ extractNotifiersWithCachedPosition(oneShotsCopy, &oneShotsWithCachedPosition);
+ extractNotifiersWithCachedPosition(watchersCopy, 0);
+ }
sendError(oneShotsCopy, error);
sendError(watchersCopy, error);
+ // hasListeners() doesn't distinguish between notifiers due to receive a
+ // cached position and those requiring a fresh position. Perform the check
+ // before restoring the notifiers below.
if (!hasListeners())
stopUpdating();
+
+ // Maintain a reference to the cached notifiers until their timer fires.
+ copyToSet(oneShotsWithCachedPosition, m_oneShots);
}
void Geolocation::requestPermission()