diff options
author | Steve Block <steveblock@google.com> | 2010-02-24 11:11:00 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-03-11 11:40:32 +0000 |
commit | 159531f4ce4c04455cd544a7c0f7c1644a50ccbe (patch) | |
tree | bd6ac2887510f9da0ee1569b3c29f719ee0326d5 /WebCore/page | |
parent | 5d59fc68790cda4c64b9e13133704e8d9c94fe57 (diff) | |
download | external_webkit-159531f4ce4c04455cd544a7c0f7c1644a50ccbe.zip external_webkit-159531f4ce4c04455cd544a7c0f7c1644a50ccbe.tar.gz external_webkit-159531f4ce4c04455cd544a7c0f7c1644a50ccbe.tar.bz2 |
Update Android to reflect final version submitted to webkit.org for Geolocation maximumAge
See http://trac.webkit.org/changeset/55841
Change-Id: Ib504563b7be40b0ff794cdcc625b07f494bb6483
Diffstat (limited to 'WebCore/page')
-rw-r--r-- | WebCore/page/Geolocation.cpp | 57 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 2 |
2 files changed, 28 insertions, 31 deletions
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index d021f7b..ad5f8d6 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -48,6 +48,7 @@ namespace WebCore { static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; +static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service"; #if ENABLE(CLIENT_BASED_GEOLOCATION) @@ -101,18 +102,18 @@ void Geolocation::GeoNotifier::setFatalError(PassRefPtr<PositionError> error) m_timer.startOneShot(0); } -bool Geolocation::GeoNotifier::hasZeroTimeout() const -{ - return m_options->hasTimeout() && m_options->timeout() == 0; -} - void Geolocation::GeoNotifier::setUseCachedPosition() { m_useCachedPosition = true; m_timer.startOneShot(0); } -void Geolocation::GeoNotifier::makeSuccessCallback(Geoposition* position) +bool Geolocation::GeoNotifier::hasZeroTimeout() const +{ + return m_options->hasTimeout() && m_options->timeout() == 0; +} + +void Geolocation::GeoNotifier::runSuccessCallback(Geoposition* position) { m_successCallback->handleEvent(position); } @@ -285,20 +286,16 @@ PassRefPtr<Geolocation::GeoNotifier> Geolocation::startRequest(PassRefPtr<Positi // the permission state can not change again in the lifetime of this page. if (isDenied()) notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage)); - else { - if (haveSuitableCachedPosition(notifier->m_options.get())) - notifier->setUseCachedPosition(); - else { - if (notifier->hasZeroTimeout() || startUpdating(notifier.get())) { + else if (haveSuitableCachedPosition(notifier->m_options.get())) + notifier->setUseCachedPosition(); + else if (notifier->hasZeroTimeout() || startUpdating(notifier.get())) { #if ENABLE(CLIENT_BASED_GEOLOCATION) - // Only start timer if we're not waiting for user permission. - if (!m_startRequestPermissionNotifier) + // Only start timer if we're not waiting for user permission. + if (!m_startRequestPermissionNotifier) #endif - notifier->startTimerIfNeeded(); - } else - notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); - } - } + notifier->startTimerIfNeeded(); + } else + notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage)); return notifier.release(); } @@ -313,15 +310,6 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) stopUpdating(); } -void Geolocation::requestTimedOut(GeoNotifier* notifier) -{ - // If this is a one-shot request, stop it. - m_oneShots.remove(notifier); - - if (!hasListeners()) - stopUpdating(); -} - void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier) { // This is called asynchronously, so the permissions could have been denied @@ -351,7 +339,7 @@ void Geolocation::makeCachedPositionCallbacks() GeoNotifierSet::const_iterator end = m_requestsAwaitingCachedPosition.end(); for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) { GeoNotifier* notifier = iter->get(); - notifier->makeSuccessCallback(m_positionCache->cachedPosition()); + notifier->runSuccessCallback(m_positionCache->cachedPosition()); // If this is a one-shot request, stop it. Otherwise, if the watch still // exists, start the service to get updates. @@ -361,7 +349,7 @@ void Geolocation::makeCachedPositionCallbacks() if (notifier->hasZeroTimeout() || startUpdating(notifier)) notifier->startTimerIfNeeded(); else - notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); + notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage)); } } @@ -371,13 +359,22 @@ void Geolocation::makeCachedPositionCallbacks() stopUpdating(); } +void Geolocation::requestTimedOut(GeoNotifier* notifier) +{ + // If this is a one-shot request, stop it. + m_oneShots.remove(notifier); + + if (!hasListeners()) + stopUpdating(); +} + bool Geolocation::haveSuitableCachedPosition(PositionOptions* options) { if (!m_positionCache->cachedPosition()) return false; if (!options->hasMaximumAge()) return true; - if (options->maximumAge() == 0) + if (!options->maximumAge()) return false; DOMTimeStamp currentTimeMillis = currentTime() * 1000.0; return m_positionCache->cachedPosition()->timestamp() > currentTimeMillis - options->maximumAge(); diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index ade4ffe..2a282b5 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -97,7 +97,7 @@ private: void setFatalError(PassRefPtr<PositionError>); bool hasZeroTimeout() const; void setUseCachedPosition(); - void makeSuccessCallback(Geoposition*); + void runSuccessCallback(Geoposition*); void startTimerIfNeeded(); void timerFired(Timer<GeoNotifier>*); |