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

dimich at chromium.org dimich at chromium.org
Wed Apr 7 23:13:48 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit b600fc8a3efef47c8ee4a2a91f82eb0701a3207f
Author: dimich at chromium.org <dimich at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 28 23:21:31 2009 +0000

    JavaScriptCore: Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
    Existing Database tests cover this since Database removes tasks when it is stopped.
    https://bugs.webkit.org/show_bug.cgi?id=30805
    
    Reviewed by David Levin.
    
    * wtf/MessageQueue.h:
    (WTF::::removeIf):
    
    WebCore: Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
    Existing Database tests cover this, no change in functionality.
    https://bugs.webkit.org/show_bug.cgi?id=30805
    
    Reviewed by David Levin.
    
    * storage/DatabaseThread.cpp:
    (WebCore::SameDatabasePredicate::SameDatabasePredicate): Added predicate that flags the tasks belonging to a specified database.
    (WebCore::SameDatabasePredicate::operator()):
    (WebCore::DatabaseThread::unscheduleDatabaseTasks): changed to use the new removeIf method.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6cd6d54..b56d3f9 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-28  Dmitry Titov  <dimich at chromium.org>
+
+        Reviewed by David Levin.
+
+        https://bugs.webkit.org/show_bug.cgi?id=30805
+        Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
+        Existing Database tests cover this since Database removes tasks when it is stopped.
+
+        * wtf/MessageQueue.h:
+        (WTF::::removeIf):
+
 2009-10-28  Afonso R. Costa Jr.  <afonso.costa at openbossa.org>
 
         Reviewed by Oliver Hunt.
diff --git a/JavaScriptCore/wtf/MessageQueue.h b/JavaScriptCore/wtf/MessageQueue.h
index 12291cc..9c9a4a7 100644
--- a/JavaScriptCore/wtf/MessageQueue.h
+++ b/JavaScriptCore/wtf/MessageQueue.h
@@ -55,9 +55,13 @@ namespace WTF {
         bool waitForMessage(DataType&);
         template<typename Predicate>
         MessageQueueWaitResult waitForMessageFilteredWithTimeout(DataType&, Predicate&, double absoluteTime);
-        void kill();
+
+        template<typename Predicate>
+        void removeIf(Predicate&);
 
         bool tryGetMessage(DataType&);
+
+        void kill();
         bool killed() const;
 
         // The result of isEmpty() is only valid if no other thread is manipulating the queue at the same time.
@@ -149,6 +153,17 @@ namespace WTF {
     }
 
     template<typename DataType>
+    template<typename Predicate>
+    inline void MessageQueue<DataType>::removeIf(Predicate& predicate)
+    {
+        MutexLocker lock(m_mutex);
+        DequeConstIterator<DataType> found = m_queue.end();
+        while ((found = m_queue.findIf(predicate)) != m_queue.end()) {
+            m_queue.remove(found);
+       }
+    }
+
+    template<typename DataType>
     inline bool MessageQueue<DataType>::isEmpty()
     {
         MutexLocker lock(m_mutex);
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8c02b32..e521437 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2009-10-28  Dmitry Titov  <dimich at chromium.org>
+
+        Reviewed by David Levin.
+
+        https://bugs.webkit.org/show_bug.cgi?id=30805
+        Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
+        Existing Database tests cover this, no change in functionality.
+
+        * storage/DatabaseThread.cpp:
+        (WebCore::SameDatabasePredicate::SameDatabasePredicate): Added predicate that flags the tasks belonging to a specified database.
+        (WebCore::SameDatabasePredicate::operator()):
+        (WebCore::DatabaseThread::unscheduleDatabaseTasks): changed to use the new removeIf method.
+
 2009-10-28  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/storage/DatabaseThread.cpp b/WebCore/storage/DatabaseThread.cpp
index 9e3afdd..40c83ee 100644
--- a/WebCore/storage/DatabaseThread.cpp
+++ b/WebCore/storage/DatabaseThread.cpp
@@ -152,22 +152,20 @@ void DatabaseThread::scheduleImmediateTask(PassRefPtr<DatabaseTask> task)
     m_queue.prepend(task);
 }
 
+class SameDatabasePredicate {
+public:
+    SameDatabasePredicate(const Database* database) : m_database(database) { }
+    bool operator()(RefPtr<DatabaseTask>& task) const { return task->database() == m_database; }
+private:
+    const Database* m_database;
+};
+
 void DatabaseThread::unscheduleDatabaseTasks(Database* database)
 {
     // Note that the thread loop is running, so some tasks for the database
     // may still be executed. This is unavoidable.
-
-    Deque<RefPtr<DatabaseTask> > filteredReverseQueue;
-    RefPtr<DatabaseTask> task;
-    while (m_queue.tryGetMessage(task)) {
-        if (task->database() != database)
-            filteredReverseQueue.append(task);
-    }
-
-    while (!filteredReverseQueue.isEmpty()) {
-        m_queue.append(filteredReverseQueue.first());
-        filteredReverseQueue.removeFirst();
-    }
+    SameDatabasePredicate predicate(database);
+    m_queue.removeIf(predicate);
 }
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list