[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:23:42 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 0c1101d8cbc23ca51993e7a246b0c264e9424e0c
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Nov 5 09:31:14 2009 +0000
2009-11-04 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Darin Fisher.
Simplify LocalStorageThread
https://bugs.webkit.org/show_bug.cgi?id=30935
This is a re-submit of 50519. LocalStorageTask should have never been ref
counted. I've removed that and switched a PassRefPtr over to a PassOwnPtr.
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/LocalStorageTask.h:
* 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@50558 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4a2b989..49ad3fa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,43 @@
Reviewed by Darin Fisher.
+ Simplify LocalStorageThread
+ https://bugs.webkit.org/show_bug.cgi?id=30935
+
+ This is a re-submit of 50519. LocalStorageTask should have never been ref
+ counted. I've removed that and switched a PassRefPtr over to a PassOwnPtr.
+
+ 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/LocalStorageTask.h:
+ * 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 Jeremy Orlow <jorlow at chromium.org>
+
+ Reviewed by Darin Fisher.
+
Calling databaseIdentifier on LocalStorage's background thread is not safe.
https://bugs.webkit.org/show_bug.cgi?id=31149
diff --git a/WebCore/storage/LocalStorageTask.h b/WebCore/storage/LocalStorageTask.h
index 3256df7..dc3e7e2 100644
--- a/WebCore/storage/LocalStorageTask.h
+++ b/WebCore/storage/LocalStorageTask.h
@@ -37,7 +37,7 @@ namespace WebCore {
class LocalStorageThread;
// FIXME: Rename this class to StorageTask
- class LocalStorageTask : public ThreadSafeShared<LocalStorageTask> {
+ class LocalStorageTask : public Noncopyable {
public:
enum Type { AreaImport, AreaSync, TerminateThread };
diff --git a/WebCore/storage/LocalStorageThread.cpp b/WebCore/storage/LocalStorageThread.cpp
index 005156b..d4a7b4c 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(PassOwnPtr<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..6f05911 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(PassOwnPtr<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 b17f4ff..d9641b7 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(const String& databaseIdentifier)
{
if (!makeAllDirectories(m_path)) {
@@ -84,19 +86,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 2ee7d0e..e2dfa76 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