Commit d554bbb9 authored by zandobersek@gmail.com's avatar zandobersek@gmail.com

Manage StorageThread through std::unique_ptr

https://bugs.webkit.org/show_bug.cgi?id=124197

Reviewed by Anders Carlsson.

New StorageThread objects are crafted through std::make_unique. This removes the need for the static
StorageThread::create() method but requires that the StorageThread constructor is made public.

* storage/StorageSyncManager.cpp:
(WebCore::StorageSyncManager::StorageSyncManager):
* storage/StorageSyncManager.h:
* storage/StorageThread.cpp:
* storage/StorageThread.h:
* storage/StorageTracker.cpp:
(WebCore::StorageTracker::StorageTracker):
* storage/StorageTracker.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 54afa34e
2013-11-12 Zan Dobersek <zdobersek@igalia.com>
Manage StorageThread through std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=124197
Reviewed by Anders Carlsson.
New StorageThread objects are crafted through std::make_unique. This removes the need for the static
StorageThread::create() method but requires that the StorageThread constructor is made public.
* storage/StorageSyncManager.cpp:
(WebCore::StorageSyncManager::StorageSyncManager):
* storage/StorageSyncManager.h:
* storage/StorageThread.cpp:
* storage/StorageThread.h:
* storage/StorageTracker.cpp:
(WebCore::StorageTracker::StorageTracker):
* storage/StorageTracker.h:
2013-11-12 Zan Dobersek <zdobersek@igalia.com>
Remove unnecessary PassOwnPtr.h header includes under Source/WebCore/fileapi
......
......@@ -46,7 +46,7 @@ PassRefPtr<StorageSyncManager> StorageSyncManager::create(const String& path)
}
StorageSyncManager::StorageSyncManager(const String& path)
: m_thread(StorageThread::create())
: m_thread(std::make_unique<StorageThread>())
, m_path(path.isolatedCopy())
{
ASSERT(isMainThread());
......
......@@ -29,7 +29,6 @@
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/OwnPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
......@@ -48,7 +47,7 @@ public:
private:
explicit StorageSyncManager(const String& path);
OwnPtr<StorageThread> m_thread;
std::unique_ptr<StorageThread> m_thread;
// The following members are subject to thread synchronization issues
public:
......
......@@ -40,11 +40,6 @@ static HashSet<StorageThread*>& activeStorageThreads()
return threads;
}
PassOwnPtr<StorageThread> StorageThread::create()
{
return adoptPtr(new StorageThread);
}
StorageThread::StorageThread()
: m_threadID(0)
{
......
......@@ -29,7 +29,6 @@
#include <wtf/Functional.h>
#include <wtf/HashSet.h>
#include <wtf/MessageQueue.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Threading.h>
......@@ -41,7 +40,7 @@ class StorageTask;
class StorageThread {
WTF_MAKE_NONCOPYABLE(StorageThread); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<StorageThread> create();
StorageThread();
~StorageThread();
bool start();
......@@ -52,8 +51,6 @@ public:
static void releaseFastMallocFreeMemoryInAllThreads();
private:
StorageThread();
// Called on background thread.
static void threadEntryPointCallback(void*);
void threadEntryPoint();
......
......@@ -90,7 +90,7 @@ StorageTracker& StorageTracker::tracker()
StorageTracker::StorageTracker(const String& storagePath)
: m_storageDirectoryPath(storagePath.isolatedCopy())
, m_client(0)
, m_thread(StorageThread::create())
, m_thread(std::make_unique<StorageThread>())
, m_isActive(false)
, m_needsInitialization(false)
, m_StorageDatabaseIdleInterval(DefaultStorageDatabaseIdleInterval)
......
......@@ -28,7 +28,6 @@
#include "SQLiteDatabase.h"
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
......@@ -109,7 +108,7 @@ private:
OriginSet m_originSet;
OriginSet m_originsBeingDeleted;
OwnPtr<StorageThread> m_thread;
std::unique_ptr<StorageThread> m_thread;
bool m_isActive;
bool m_needsInitialization;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment