⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136164 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 2:18:32 PM (14 years ago)
Author:
jknotten@chromium.org
Message:

Use GeolocationController's last geoposition as cached position.
​https://bugs.webkit.org/show_bug.cgi?id=103540

Reviewed by Benjamin Poulain.

The page's GeolocationController mediates access to the
GeolocationClient for multiple frames' Geolocation instances. This
patch changes the position cache to be on the GeolocationController
rather than on the Geolocation instance.

This fixes a bug where if one frame has has received a fresh
position, then a request for a cached position from a second frame
does not succeed because the Geolocation instance in the second
frame's position cache hasn't received the position update that
went to the first frame.

Source/WebCore:

Test: fast/dom/Geolocation/cached-position-iframe.html

  • Modules/geolocation/Geolocation.cpp:

(WebCore::Geolocation::makeCachedPositionCallbacks):
(WebCore::Geolocation::haveSuitableCachedPosition):
(WebCore::Geolocation::positionChanged):

  • Modules/geolocation/Geolocation.h:
  • Modules/geolocation/GeolocationController.h:

(GeolocationController):

LayoutTests:

  • fast/dom/Geolocation/cached-position-iframe-expected.txt: Added.
  • fast/dom/Geolocation/cached-position-iframe.html: Added.
  • fast/dom/Geolocation/resources/cached-position-iframe-inner.html: Added.
  • fast/dom/Geolocation/script-tests/cached-position-iframe.js: Added.

(window.onmessage):

Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136161 r136164  
     12012-11-29  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Use GeolocationController's last geoposition as cached position.
     4        https://bugs.webkit.org/show_bug.cgi?id=103540
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        The page's GeolocationController mediates access to the
     9        GeolocationClient for multiple frames' Geolocation instances. This
     10        patch changes the position cache to be on the GeolocationController
     11        rather than on the Geolocation instance.
     12
     13        This fixes a bug where if one frame has has received a fresh
     14        position, then a request for a cached position from a second frame
     15        does not succeed because the Geolocation instance in the second
     16        frame's position cache hasn't received the position update that
     17        went to the first frame.
     18
     19        * fast/dom/Geolocation/cached-position-iframe-expected.txt: Added.
     20        * fast/dom/Geolocation/cached-position-iframe.html: Added.
     21        * fast/dom/Geolocation/resources/cached-position-iframe-inner.html: Added.
     22        * fast/dom/Geolocation/script-tests/cached-position-iframe.js: Added.
     23        (window.onmessage):
     24
    1252012-11-29  Zhenyao Mo  <zmo@google.com>
    226
  • trunk/Source/WebCore/ChangeLog

    r136163 r136164  
     12012-11-29  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Use GeolocationController's last geoposition as cached position.
     4        https://bugs.webkit.org/show_bug.cgi?id=103540
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        The page's GeolocationController mediates access to the
     9        GeolocationClient for multiple frames' Geolocation instances. This
     10        patch changes the position cache to be on the GeolocationController
     11        rather than on the Geolocation instance.
     12
     13        This fixes a bug where if one frame has has received a fresh
     14        position, then a request for a cached position from a second frame
     15        does not succeed because the Geolocation instance in the second
     16        frame's position cache hasn't received the position update that
     17        went to the first frame.
     18
     19        Test: fast/dom/Geolocation/cached-position-iframe.html
     20
     21        * Modules/geolocation/Geolocation.cpp:
     22        (WebCore::Geolocation::makeCachedPositionCallbacks):
     23        (WebCore::Geolocation::haveSuitableCachedPosition):
     24        (WebCore::Geolocation::positionChanged):
     25        * Modules/geolocation/Geolocation.h:
     26        * Modules/geolocation/GeolocationController.h:
     27        (GeolocationController):
     28
    1292012-11-29  Alexei Filippov  <alph@chromium.org>
    230
  • trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp

    r135478 r136164  
    374374    for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) {
    375375        GeoNotifier* notifier = iter->get();
    376         notifier->runSuccessCallback(m_cachedPosition.get());
     376        notifier->runSuccessCallback(lastPosition());
    377377
    378378        // If this is a one-shot request, stop it. Otherwise, if the watch still
    … …  
    405405bool Geolocation::haveSuitableCachedPosition(PositionOptions* options)
    406406{
    407     if (!m_cachedPosition)
     407    Geoposition* cachedPosition = lastPosition();
     408    if (!cachedPosition)
    408409        return false;
    409410    if (!options->hasMaximumAge())
    … …  
    412413        return false;
    413414    DOMTimeStamp currentTimeMillis = convertSecondsToDOMTimeStamp(currentTime());
    414     return m_cachedPosition->timestamp() > currentTimeMillis - options->maximumAge();
     415    return cachedPosition->timestamp() > currentTimeMillis - options->maximumAge();
    415416}
    416417
    … …  
    625626    ASSERT(isAllowed());
    626627
    627     m_cachedPosition = lastPosition();
    628 
    629628    // Stop all currently running timers.
    630629    stopTimers();
  • trunk/Source/WebCore/Modules/geolocation/Geolocation.h

    r135478 r136164  
    174174    } m_allowGeolocation;
    175175
    176     RefPtr<Geoposition> m_cachedPosition;
    177176    GeoNotifierSet m_requestsAwaitingCachedPosition;
    178177};
Note: See TracChangeset for help on using the changeset viewer.