[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

steveblock at google.com steveblock at google.com
Wed Apr 7 23:09:12 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 2ce3bb57ba4037d767d9d4c5dfdccc6504aec349
Author: steveblock at google.com <steveblock at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 27 17:54:27 2009 +0000

    Use a pair of maps to store Geolocation watchers.
    https://bugs.webkit.org/show_bug.cgi?id=29178
    
    Reviewed by Darin Adler.
    
    The pair of maps allows us to look up a watcher either by its ID or by its GeoNotifier object.
    The ability to look up by a watcher by its GeoNotifier object will be required when implementing
    Geolocation::fatalErrorOccurred. See https://bugs.webkit.org/show_bug.cgi?id=27944
    
    * page/Geolocation.cpp: Modified.
    (WebCore::Geolocation::Watchers::set): Added. Adds a watcher with the given ID.
    (WebCore::Geolocation::Watchers::remove): Added. Removes a watcher by ID.
    (WebCore::Geolocation::Watchers::remove): Added. Removes a watcher by GeoNotifier object.
    (WebCore::Geolocation::Watchers::clear): Added. Removes all watchers.
    (WebCore::Geolocation::Watchers::isEmpty): Added. Determines if there are no watchers.
    (WebCore::Geolocation::Watchers::getNotifiersVector): Added. Gets a vector of the GeoNotifier objects.
    (WebCore::Geolocation::watchPosition): Modified. Rename watcher identifier static variable.
    (WebCore::Geolocation::stopTimersForWatchers): Modified. Use Watchers::getNotifiersVector.
    (WebCore::Geolocation::handleError): Modified. Use Watchers::getNotifiersVector.
    (WebCore::Geolocation::makeSuccessCallbacks): Modified. Use Watchers::getNotifiersVector.
    * page/Geolocation.h: Modified. Adds Geolocation::Watchers class.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50159 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3db4707..895448f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2009-10-27  Steve Block  <steveblock at google.com>
+
+        Reviewed by Darin Adler.
+
+        Use a pair of maps to store Geolocation watchers.
+        https://bugs.webkit.org/show_bug.cgi?id=29178
+
+        The pair of maps allows us to look up a watcher either by its ID or by its GeoNotifier object.
+        The ability to look up by a watcher by its GeoNotifier object will be required when implementing
+        Geolocation::fatalErrorOccurred. See https://bugs.webkit.org/show_bug.cgi?id=27944
+
+        * page/Geolocation.cpp: Modified.
+        (WebCore::Geolocation::Watchers::set): Added. Adds a watcher with the given ID.
+        (WebCore::Geolocation::Watchers::remove): Added. Removes a watcher by ID.
+        (WebCore::Geolocation::Watchers::remove): Added. Removes a watcher by GeoNotifier object.
+        (WebCore::Geolocation::Watchers::clear): Added. Removes all watchers.
+        (WebCore::Geolocation::Watchers::isEmpty): Added. Determines if there are no watchers.
+        (WebCore::Geolocation::Watchers::getNotifiersVector): Added. Gets a vector of the GeoNotifier objects.
+        (WebCore::Geolocation::watchPosition): Modified. Rename watcher identifier static variable.
+        (WebCore::Geolocation::stopTimersForWatchers): Modified. Use Watchers::getNotifiersVector.
+        (WebCore::Geolocation::handleError): Modified. Use Watchers::getNotifiersVector.
+        (WebCore::Geolocation::makeSuccessCallbacks): Modified. Use Watchers::getNotifiersVector.
+        * page/Geolocation.h: Modified. Adds Geolocation::Watchers class.
+
 2009-10-27  Jeremy Orlow  <jorlow at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 86127d7..3590f84 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -70,6 +70,46 @@ void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
     m_geolocation->requestTimedOut(this);
 }
 
+void Geolocation::Watchers::set(int id, PassRefPtr<GeoNotifier> notifier)
+{
+    m_idToNotifierMap.set(id, notifier);
+    m_notifierToIdMap.set(notifier, id);
+}
+
+void Geolocation::Watchers::remove(int id)
+{
+    IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id);
+    if (iter == m_idToNotifierMap.end())
+        return;
+    m_notifierToIdMap.remove(iter->second);
+    m_idToNotifierMap.remove(iter);
+}
+
+void Geolocation::Watchers::remove(GeoNotifier* notifier)
+{
+    NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier);
+    if (iter == m_notifierToIdMap.end())
+        return;
+    m_idToNotifierMap.remove(iter->second);
+    m_notifierToIdMap.remove(iter);
+}
+
+void Geolocation::Watchers::clear()
+{
+    m_idToNotifierMap.clear();
+    m_notifierToIdMap.clear();
+}
+
+bool Geolocation::Watchers::isEmpty() const
+{
+    return m_idToNotifierMap.isEmpty();
+}
+
+void Geolocation::Watchers::getNotifiersVector(Vector<RefPtr<GeoNotifier> >& copy) const
+{
+    copyValuesToVector(m_idToNotifierMap, copy);
+}
+
 Geolocation::Geolocation(Frame* frame)
     : m_frame(frame)
     , m_service(GeolocationService::create(this))
@@ -121,11 +161,9 @@ int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, Pas
         return 0;
     }
     
-    static int sIdentifier = 0;
-    
-    m_watchers.set(++sIdentifier, notifier);
-
-    return sIdentifier;
+    static int nextAvailableWatchId = 1;
+    m_watchers.set(nextAvailableWatchId, notifier.release());
+    return nextAvailableWatchId++;
 }
 
 void Geolocation::requestTimedOut(GeoNotifier* notifier)
@@ -212,7 +250,7 @@ void Geolocation::stopTimersForOneShots()
 void Geolocation::stopTimersForWatchers()
 {
     Vector<RefPtr<GeoNotifier> > copy;
-    copyValuesToVector(m_watchers, copy);
+    m_watchers.getNotifiersVector(copy);
     
     stopTimer(copy);
 }
@@ -231,7 +269,7 @@ void Geolocation::handleError(PositionError* error)
     copyToVector(m_oneShots, oneShotsCopy);
 
     Vector<RefPtr<GeoNotifier> > watchersCopy;
-    copyValuesToVector(m_watchers, watchersCopy);
+    m_watchers.getNotifiersVector(watchersCopy);
 
     // Clear the lists before we make the callbacks, to avoid clearing notifiers
     // added by calls to Geolocation methods from the callbacks, and to prevent
@@ -294,7 +332,7 @@ void Geolocation::makeSuccessCallbacks()
     copyToVector(m_oneShots, oneShotsCopy);
     
     Vector<RefPtr<GeoNotifier> > watchersCopy;
-    copyValuesToVector(m_watchers, watchersCopy);
+    m_watchers.getNotifiersVector(watchersCopy);
     
     // Clear the lists before we make the callbacks, to avoid clearing notifiers
     // added by calls to Geolocation methods from the callbacks, and to prevent
diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h
index 07a587f..c230826 100644
--- a/WebCore/page/Geolocation.h
+++ b/WebCore/page/Geolocation.h
@@ -89,6 +89,21 @@ private:
         GeoNotifier(Geolocation*, PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
     };
 
+    class Watchers {
+    public:
+        void set(int id, PassRefPtr<GeoNotifier>);
+        void remove(int id);
+        void remove(GeoNotifier*);
+        void clear();
+        bool isEmpty() const;
+        void getNotifiersVector(Vector<RefPtr<GeoNotifier> >&) const;
+    private:
+        typedef HashMap<int, RefPtr<GeoNotifier> > IdToNotifierMap;
+        typedef HashMap<RefPtr<GeoNotifier>, int> NotifierToIdMap;
+        IdToNotifierMap m_idToNotifierMap;
+        NotifierToIdMap m_notifierToIdMap;
+    };
+
     bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEmpty(); }
 
     void sendError(Vector<RefPtr<GeoNotifier> >&, PositionError*);
@@ -111,10 +126,9 @@ private:
     void requestTimedOut(GeoNotifier*);
 
     typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet;
-    typedef HashMap<int, RefPtr<GeoNotifier> > GeoNotifierMap;
     
     GeoNotifierSet m_oneShots;
-    GeoNotifierMap m_watchers;
+    Watchers m_watchers;
     Frame* m_frame;
     OwnPtr<GeolocationService> m_service;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list