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

jorlow at chromium.org jorlow at chromium.org
Wed Apr 7 23:22:35 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit b268dfce7807fd4b8ab586534e490e2150f31138
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 4 19:11:24 2009 +0000

    2009-11-03  Jeremy Orlow  <jorlow at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Simplify LocalStorageThread
            https://bugs.webkit.org/show_bug.cgi?id=30935
    
            On LocalStoragethread: Remove reference counting. Get rid of locking. Make some
            of the method names a bit more clear. Assert proper thread usage. Join rather
            than detaching the thread and doing an ad-hoc form of join. Avoid touching
            variables on the background thread when simple to do so.  Also create a generic
            scheduleTask function rather than one for each task.
    
            No behavior should have changed.
    
            * storage/LocalStorageThread.cpp:
            (WebCore::LocalStorageThread::create):
            (WebCore::LocalStorageThread::LocalStorageThread):
            (WebCore::LocalStorageThread::~LocalStorageThread):
            (WebCore::LocalStorageThread::start):
            (WebCore::LocalStorageThread::threadEntryPointCallback):
            (WebCore::LocalStorageThread::threadEntryPoint):
            (WebCore::LocalStorageThread::scheduleTask):
            (WebCore::LocalStorageThread::terminate):
            (WebCore::LocalStorageThread::performTerminate):
            * storage/LocalStorageThread.h:
            * storage/StorageSyncManager.cpp:
            (WebCore::StorageSyncManager::StorageSyncManager):
            (WebCore::StorageSyncManager::~StorageSyncManager):
            (WebCore::StorageSyncManager::scheduleImport):
            (WebCore::StorageSyncManager::scheduleSync):
            * storage/StorageSyncManager.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50519 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1d0b1d3..6d7ffa7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2009-11-03  Jeremy Orlow  <jorlow at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Simplify LocalStorageThread
+        https://bugs.webkit.org/show_bug.cgi?id=30935
+
+        On LocalStoragethread: Remove reference counting. Get rid of locking. Make some
+        of the method names a bit more clear. Assert proper thread usage. Join rather
+        than detaching the thread and doing an ad-hoc form of join. Avoid touching
+        variables on the background thread when simple to do so.  Also create a generic
+        scheduleTask function rather than one for each task.
+
+        No behavior should have changed.
+
+        * storage/LocalStorageThread.cpp:
+        (WebCore::LocalStorageThread::create):
+        (WebCore::LocalStorageThread::LocalStorageThread):
+        (WebCore::LocalStorageThread::~LocalStorageThread):
+        (WebCore::LocalStorageThread::start):
+        (WebCore::LocalStorageThread::threadEntryPointCallback):
+        (WebCore::LocalStorageThread::threadEntryPoint):
+        (WebCore::LocalStorageThread::scheduleTask):
+        (WebCore::LocalStorageThread::terminate):
+        (WebCore::LocalStorageThread::performTerminate):
+        * storage/LocalStorageThread.h:
+        * storage/StorageSyncManager.cpp:
+        (WebCore::StorageSyncManager::StorageSyncManager):
+        (WebCore::StorageSyncManager::~StorageSyncManager):
+        (WebCore::StorageSyncManager::scheduleImport):
+        (WebCore::StorageSyncManager::scheduleSync):
+        * storage/StorageSyncManager.h:
+
 2009-11-04  Vadim Zeitlin  <vadim at wxwidgets.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/storage/LocalStorageThread.cpp b/WebCore/storage/LocalStorageThread.cpp
index 005156b..a19ffa8 100644
--- a/WebCore/storage/LocalStorageThread.cpp
+++ b/WebCore/storage/LocalStorageThread.cpp
@@ -33,93 +33,70 @@
 
 namespace WebCore {
 
-PassRefPtr<LocalStorageThread> LocalStorageThread::create()
+PassOwnPtr<LocalStorageThread> LocalStorageThread::create()
 {
-    return adoptRef(new LocalStorageThread);
+    return new LocalStorageThread;
 }
 
 LocalStorageThread::LocalStorageThread()
     : m_threadID(0)
-    , m_terminated(false)
 {
-    m_selfRef = this;
 }
 
-bool LocalStorageThread::start()
+LocalStorageThread::~LocalStorageThread()
 {
-    MutexLocker lock(m_threadCreationMutex);
-
-    if (m_threadID)
-        return true;
-
-    m_threadID = createThread(LocalStorageThread::localStorageThreadStart, this, "WebCore: LocalStorage");
+    ASSERT(isMainThread());
+    ASSERT(!m_threadID);
+}
 
+bool LocalStorageThread::start()
+{
+    ASSERT(isMainThread());
+    if (!m_threadID)
+        m_threadID = createThread(LocalStorageThread::threadEntryPointCallback, this, "WebCore: LocalStorage");
     return m_threadID;
 }
 
-void* LocalStorageThread::localStorageThreadStart(void* thread)
+void* LocalStorageThread::threadEntryPointCallback(void* thread)
 {
-    return static_cast<LocalStorageThread*>(thread)->localStorageThread();
+    return static_cast<LocalStorageThread*>(thread)->threadEntryPoint();
 }
 
-void* LocalStorageThread::localStorageThread()
+void* LocalStorageThread::threadEntryPoint()
 {
-    {
-        // Wait for LocalStorageThread::start() to complete.
-        MutexLocker lock(m_threadCreationMutex);
-    }
-
+    ASSERT(!isMainThread());
     while (OwnPtr<LocalStorageTask> task = m_queue.waitForMessage())
         task->performTask();
 
-    // Detach the thread so its resources are no longer of any concern to anyone else
-    detachThread(m_threadID);
-    m_threadID = 0;
-
-    // Clear the self refptr, possibly resulting in deletion
-    m_selfRef = 0;
-
     return 0;
 }
 
-void LocalStorageThread::scheduleImport(StorageAreaSync* area)
-{
-    ASSERT(!m_queue.killed() && m_threadID);
-    m_queue.append(LocalStorageTask::createImport(area));
-}
-
-void LocalStorageThread::scheduleSync(StorageAreaSync* area)
+void LocalStorageThread::scheduleTask(PassRefPtr<LocalStorageTask> task)
 {
+    ASSERT(isMainThread());
     ASSERT(!m_queue.killed() && m_threadID);
-    m_queue.append(LocalStorageTask::createSync(area));
+    m_queue.append(task);
 }
 
 void LocalStorageThread::terminate()
 {
     ASSERT(isMainThread());
-
-    // Ideally we'd never be killing a thread that wasn't live, so ASSERT it.
-    // But if we do in a release build, make sure to not wait on a condition that will never get signalled
     ASSERT(!m_queue.killed() && m_threadID);
+    // Even in weird, exceptional cases, don't wait on a nonexistent thread to terminate.
     if (!m_threadID)
         return;
 
+    void* returnValue;
     m_queue.append(LocalStorageTask::createTerminate(this));
-
-    MutexLocker locker(m_terminateLock);
-    while (!m_terminated)
-        m_terminateCondition.wait(m_terminateLock);
+    waitForThreadCompletion(m_threadID, &returnValue);
+    ASSERT(m_queue.killed());
+    m_threadID = 0;
 }
 
 void LocalStorageThread::performTerminate()
 {
     ASSERT(!isMainThread());
-
     m_queue.kill();
-
-    MutexLocker locker(m_terminateLock);
-    m_terminated = true;
-    m_terminateCondition.signal();
 }
 
 }
diff --git a/WebCore/storage/LocalStorageThread.h b/WebCore/storage/LocalStorageThread.h
index 616b809..6989ce6 100644
--- a/WebCore/storage/LocalStorageThread.h
+++ b/WebCore/storage/LocalStorageThread.h
@@ -30,6 +30,7 @@
 
 #include <wtf/HashSet.h>
 #include <wtf/MessageQueue.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Threading.h>
 
@@ -39,35 +40,27 @@ namespace WebCore {
     class LocalStorageTask;
 
     // FIXME: Rename this class to StorageThread
-    class LocalStorageThread : public ThreadSafeShared<LocalStorageThread> {
+    class LocalStorageThread : public Noncopyable {
     public:
-        static PassRefPtr<LocalStorageThread> create();
+        static PassOwnPtr<LocalStorageThread> create();
+        ~LocalStorageThread();
 
         bool start();
-
-        void scheduleImport(StorageAreaSync*);
-        void scheduleSync(StorageAreaSync*);
-
-        // Called from the main thread to synchronously shut down this thread
         void terminate();
-        // Background thread part of the terminate procedure
+        void scheduleTask(PassRefPtr<LocalStorageTask>);
+
+        // Background thread part of the terminate procedure.
         void performTerminate();
 
     private:
         LocalStorageThread();
 
-        static void* localStorageThreadStart(void*);
-        void* localStorageThread();
+        // Called on background thread.
+        static void* threadEntryPointCallback(void*);
+        void* threadEntryPoint();
 
-        Mutex m_threadCreationMutex;
         ThreadIdentifier m_threadID;
-        RefPtr<LocalStorageThread> m_selfRef;
-
         MessageQueue<LocalStorageTask> m_queue;
-
-        Mutex m_terminateLock;
-        ThreadCondition m_terminateCondition;
-        bool m_terminated;
     };
 
 } // namespace WebCore
diff --git a/WebCore/storage/StorageSyncManager.cpp b/WebCore/storage/StorageSyncManager.cpp
index f9276dd..f7e41e9 100644
--- a/WebCore/storage/StorageSyncManager.cpp
+++ b/WebCore/storage/StorageSyncManager.cpp
@@ -48,19 +48,21 @@ PassRefPtr<StorageSyncManager> StorageSyncManager::create(const String& path)
 }
 
 StorageSyncManager::StorageSyncManager(const String& path)
-    : m_path(path.crossThreadString())
+    : m_thread(LocalStorageThread::create())
+    , m_path(path.crossThreadString())
 {
     ASSERT(isMainThread());
     ASSERT(!m_path.isEmpty());
-    m_thread = LocalStorageThread::create();
     m_thread->start();
 }
 
 StorageSyncManager::~StorageSyncManager()
 {
     ASSERT(isMainThread());
+    ASSERT(!m_thread);
 }
 
+// Called on a background thread.
 String StorageSyncManager::fullDatabaseFilename(SecurityOrigin* origin)
 {
     ASSERT(origin);
@@ -85,19 +87,18 @@ void StorageSyncManager::close()
 bool StorageSyncManager::scheduleImport(PassRefPtr<StorageAreaSync> area)
 {
     ASSERT(isMainThread());
-
+    ASSERT(m_thread);
     if (m_thread)
-        m_thread->scheduleImport(area.get());
-
+        m_thread->scheduleTask(LocalStorageTask::createImport(area.get()));
     return m_thread;
 }
 
 void StorageSyncManager::scheduleSync(PassRefPtr<StorageAreaSync> area)
 {
     ASSERT(isMainThread());
-
+    ASSERT(m_thread);
     if (m_thread)
-        m_thread->scheduleSync(area.get());
+        m_thread->scheduleTask(LocalStorageTask::createSync(area.get()));
 }
 
 } // namespace WebCore
diff --git a/WebCore/storage/StorageSyncManager.h b/WebCore/storage/StorageSyncManager.h
index fe35e3d..6ee767a 100644
--- a/WebCore/storage/StorageSyncManager.h
+++ b/WebCore/storage/StorageSyncManager.h
@@ -32,7 +32,7 @@
 
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
@@ -53,7 +53,7 @@ namespace WebCore {
     private:
         StorageSyncManager(const String& path);
 
-        RefPtr<LocalStorageThread> m_thread;
+        OwnPtr<LocalStorageThread> m_thread;
 
     // The following members are subject to thread synchronization issues
     public:

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list