Skip to content
Permalink
Browse files
Pass local storage directory to StorageManager::create
https://bugs.webkit.org/show_bug.cgi?id=132827

Reviewed by Tim Horton.

Since we know the local storage directory at creation time and we know it never changes,
we can get rid of setLocalStorageDirectory and just pass the local storage directory at creation time.

* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::create):
(WebKit::LocalStorageDatabaseTracker::LocalStorageDatabaseTracker):
(WebKit::LocalStorageDatabaseTracker::~LocalStorageDatabaseTracker):
(WebKit::LocalStorageDatabaseTracker::setLocalStorageDirectory): Deleted.
(WebKit::LocalStorageDatabaseTracker::setLocalStorageDirectoryInternal): Deleted.
* UIProcess/Storage/LocalStorageDatabaseTracker.h:
* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::create):
(WebKit::StorageManager::StorageManager):
(WebKit::StorageManager::setLocalStorageDirectory): Deleted.
* UIProcess/Storage/StorageManager.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):

Canonical link: https://commits.webkit.org/150869@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed May 12, 2014
1 parent d6e3942 commit 83c104b32fa280971ee8d8a8b91d5606aa61432e
Showing 6 changed files with 48 additions and 47 deletions.
@@ -1,3 +1,28 @@
2014-05-12 Anders Carlsson <andersca@apple.com>

Pass local storage directory to StorageManager::create
https://bugs.webkit.org/show_bug.cgi?id=132827

Reviewed by Tim Horton.

Since we know the local storage directory at creation time and we know it never changes,
we can get rid of setLocalStorageDirectory and just pass the local storage directory at creation time.

* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::create):
(WebKit::LocalStorageDatabaseTracker::LocalStorageDatabaseTracker):
(WebKit::LocalStorageDatabaseTracker::~LocalStorageDatabaseTracker):
(WebKit::LocalStorageDatabaseTracker::setLocalStorageDirectory): Deleted.
(WebKit::LocalStorageDatabaseTracker::setLocalStorageDirectoryInternal): Deleted.
* UIProcess/Storage/LocalStorageDatabaseTracker.h:
* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::create):
(WebKit::StorageManager::StorageManager):
(WebKit::StorageManager::setLocalStorageDirectory): Deleted.
* UIProcess/Storage/StorageManager.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):

2014-05-11 Anders Carlsson <andersca@apple.com>

Replace WKContextSetLocalStorageDirectory with a context configuration getter/setter
@@ -31,34 +31,35 @@
#include <WebCore/FileSystem.h>
#include <WebCore/SQLiteStatement.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/TextEncoding.h>
#include <wtf/text/CString.h>

using namespace WebCore;

namespace WebKit {

PassRefPtr<LocalStorageDatabaseTracker> LocalStorageDatabaseTracker::create(PassRefPtr<WorkQueue> queue)
PassRefPtr<LocalStorageDatabaseTracker> LocalStorageDatabaseTracker::create(PassRefPtr<WorkQueue> queue, const String& localStorageDirectory)
{
return adoptRef(new LocalStorageDatabaseTracker(queue));
return adoptRef(new LocalStorageDatabaseTracker(queue, localStorageDirectory));
}

LocalStorageDatabaseTracker::LocalStorageDatabaseTracker(PassRefPtr<WorkQueue> queue)
LocalStorageDatabaseTracker::LocalStorageDatabaseTracker(PassRefPtr<WorkQueue> queue, const String& localStorageDirectory)
: m_queue(queue)
, m_localStorageDirectory(localStorageDirectory.isolatedCopy())
{
}
ASSERT(!m_localStorageDirectory.isEmpty());

LocalStorageDatabaseTracker::~LocalStorageDatabaseTracker()
{
// Make sure the encoding is initialized before we start dispatching things to the queue.
UTF8Encoding();

RefPtr<LocalStorageDatabaseTracker> localStorageDatabaseTracker(this);
m_queue->dispatch([localStorageDatabaseTracker] {
localStorageDatabaseTracker->importOriginIdentifiers();
});
}

void LocalStorageDatabaseTracker::setLocalStorageDirectory(const String& localStorageDirectory)
LocalStorageDatabaseTracker::~LocalStorageDatabaseTracker()
{
// FIXME: We should come up with a better idiom for safely copying strings across threads.
RefPtr<StringImpl> copiedLocalStorageDirectory;
if (localStorageDirectory.impl())
copiedLocalStorageDirectory = localStorageDirectory.impl()->isolatedCopy();

m_queue->dispatch(bind(&LocalStorageDatabaseTracker::setLocalStorageDirectoryInternal, this, copiedLocalStorageDirectory.release()));
}

String LocalStorageDatabaseTracker::databasePath(SecurityOrigin* securityOrigin) const
@@ -154,17 +155,6 @@ Vector<LocalStorageDetails> LocalStorageDatabaseTracker::details()
return result;
}

void LocalStorageDatabaseTracker::setLocalStorageDirectoryInternal(StringImpl* localStorageDirectory)
{
if (m_database.isOpen())
m_database.close();

m_localStorageDirectory = localStorageDirectory;
m_origins.clear();

m_queue->dispatch(bind(&LocalStorageDatabaseTracker::importOriginIdentifiers, this));
}

String LocalStorageDatabaseTracker::databasePath(const String& filename) const
{
if (!makeAllDirectories(m_localStorageDirectory)) {
@@ -46,10 +46,9 @@ struct LocalStorageDetails;

class LocalStorageDatabaseTracker : public ThreadSafeRefCounted<LocalStorageDatabaseTracker> {
public:
static PassRefPtr<LocalStorageDatabaseTracker> create(PassRefPtr<WorkQueue>);
static PassRefPtr<LocalStorageDatabaseTracker> create(PassRefPtr<WorkQueue>, const String& localStorageDirectory);
~LocalStorageDatabaseTracker();

void setLocalStorageDirectory(const String&);
String databasePath(WebCore::SecurityOrigin*) const;

void didOpenDatabaseWithOrigin(WebCore::SecurityOrigin*);
@@ -60,9 +59,7 @@ class LocalStorageDatabaseTracker : public ThreadSafeRefCounted<LocalStorageData
Vector<LocalStorageDetails> details();

private:
explicit LocalStorageDatabaseTracker(PassRefPtr<WorkQueue>);

void setLocalStorageDirectoryInternal(StringImpl*);
LocalStorageDatabaseTracker(PassRefPtr<WorkQueue>, const String& localStorageDirectory);

String databasePath(const String& filename) const;
String trackerDatabasePath() const;
@@ -368,14 +368,14 @@ void StorageManager::SessionStorageNamespace::cloneTo(SessionStorageNamespace& n
newSessionStorageNamespace.m_storageAreaMap.add(it->key, it->value->clone());
}

PassRefPtr<StorageManager> StorageManager::create()
PassRefPtr<StorageManager> StorageManager::create(const String& localStorageDirectory)
{
return adoptRef(new StorageManager);
return adoptRef(new StorageManager(localStorageDirectory));
}

StorageManager::StorageManager()
StorageManager::StorageManager(const String& localStorageDirectory)
: m_queue(WorkQueue::create("com.apple.WebKit.StorageManager"))
, m_localStorageDatabaseTracker(LocalStorageDatabaseTracker::create(m_queue))
, m_localStorageDatabaseTracker(LocalStorageDatabaseTracker::create(m_queue, localStorageDirectory))
{
// Make sure the encoding is initialized before we start dispatching things to the queue.
UTF8Encoding();
@@ -385,13 +385,6 @@ StorageManager::~StorageManager()
{
}

void StorageManager::setLocalStorageDirectory(const String& localStorageDirectory)
{
ASSERT(!localStorageDirectory.isNull());

m_localStorageDatabaseTracker->setLocalStorageDirectory(localStorageDirectory);
}

void StorageManager::createSessionStorageNamespace(uint64_t storageNamespaceID, IPC::Connection* allowedConnection, unsigned quotaInBytes)
{
m_queue->dispatch(bind(&StorageManager::createSessionStorageNamespaceInternal, this, storageNamespaceID, RefPtr<IPC::Connection>(allowedConnection), quotaInBytes));
@@ -47,11 +47,9 @@ class WebProcessProxy;

class StorageManager : public IPC::Connection::WorkQueueMessageReceiver {
public:
static PassRefPtr<StorageManager> create();
static PassRefPtr<StorageManager> create(const String& localStorageDirectory);
~StorageManager();

void setLocalStorageDirectory(const String&);

void createSessionStorageNamespace(uint64_t storageNamespaceID, IPC::Connection* allowedConnection, unsigned quotaInBytes);
void destroySessionStorageNamespace(uint64_t storageNamespaceID);
void setAllowedSessionStorageNamespaceConnection(uint64_t storageNamespaceID, IPC::Connection* allowedConnection);
@@ -68,7 +66,7 @@ class StorageManager : public IPC::Connection::WorkQueueMessageReceiver {
void deleteAllEntries();

private:
StorageManager();
explicit StorageManager(const String& localStorageDirectory);

// IPC::Connection::WorkQueueMessageReceiver.
virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
@@ -160,7 +160,7 @@ WebContext::WebContext(WebContextConfiguration configuration)
, m_cacheModel(CacheModelDocumentViewer)
, m_memorySamplerEnabled(false)
, m_memorySamplerInterval(1400.0)
, m_storageManager(StorageManager::create())
, m_storageManager(StorageManager::create(configuration.localStorageDirectory))
#if USE(SOUP)
, m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain)
#endif
@@ -222,8 +222,6 @@ WebContext::WebContext(WebContextConfiguration configuration)
#ifndef NDEBUG
webContextCounter.increment();
#endif

m_storageManager->setLocalStorageDirectory(configuration.localStorageDirectory);
}

#if !PLATFORM(COCOA)

0 comments on commit 83c104b

Please sign in to comment.