DatabaseProcess IndexedDB: Establish a metadata backing store on disk
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 00:42:14 +0000 (00:42 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 00:42:14 +0000 (00:42 +0000)
commitaf2265a6cd62d212742af0b265ba6324cc994ef2
tree849beb9190e8d22b7d28edafebd79f633733b8be
parent14f994ef8713c637a3054b4308ea8c00113721d3
DatabaseProcess IndexedDB: Establish a metadata backing store on disk
https://bugs.webkit.org/show_bug.cgi?id=125258

Reviewed by Alexey Proskuryakov, Anders Carlsson, and Tim Horton.

Source/WebCore:

Teach CrossThreadCopier how to handle IDBDatabaseMetadata.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:

* Modules/indexeddb/IDBDatabaseMetadata.cpp: Added.
(WebCore::IDBDatabaseMetadata::isolatedCopy):
(WebCore::IDBObjectStoreMetadata::isolatedCopy):
(WebCore::IDBIndexMetadata::isolatedCopy):
* Modules/indexeddb/IDBDatabaseMetadata.h:

* Modules/indexeddb/IDBKeyPath.cpp:
(WebCore::IDBKeyPath::isolatedCopy):
* Modules/indexeddb/IDBKeyPath.h:

* platform/CrossThreadCopier.cpp:
(WebCore::::copy): Add an IDBDatabaseMetadata specialization.
* platform/CrossThreadCopier.h:

Source/WebKit2:

The DatabaseProcess already has an "Indexed Database path".
Each SecurityOrigin with indexed databases will have a subdirectory under the path.
Each indexed database will have a subdirectory under its SecurityOrigin's path.
Inside that directory will exist (1) metadata database, and 0-N ObjectStore databases.

This patch establishes the directory structure and the (1) metadata database.

* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::initializeDatabaseProcess): Asynchronously ensure the indexed database directory exists.
(WebKit::DatabaseProcess::ensureIndexedDatabaseRelativePathExists): Allow anyone to make necessary directories relative to
  the indexed database directory.
(WebKit::DatabaseProcess::ensurePathExists):
(WebKit::DatabaseProcess::absoluteIndexedDatabasePathFromDatabaseRelativePath): Instead of exposing the indexed database directory,
  give DatabaseProcess a method to allow others to compute a path relative to the indexed database directory.
(WebKit::DatabaseProcess::postDatabaseTask):
(WebKit::DatabaseProcess::performNextDatabaseTask):
* DatabaseProcess/DatabaseProcess.h:
(WebKit::DatabaseProcess::queue):

* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
(WebKit::DatabaseProcessIDBConnection::getOrEstablishIDBDatabaseMetadata):

* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::UniqueIDBDatabase):
(WebKit::UniqueIDBDatabase::filenameForDatabaseName):
(WebKit::UniqueIDBDatabase::databaseFilenameIdentifier):
(WebKit::UniqueIDBDatabase::canShareDatabases):
(WebKit::UniqueIDBDatabase::shutdown): Method to cleanly shutdown a database, emptying its task and request queues.
(WebKit::UniqueIDBDatabase::getOrEstablishIDBDatabaseMetadata):
(WebKit::UniqueIDBDatabase::openBackingStoreAndReadMetadata): To be run on the database work queue, establishes a backing store
  and extracts metadata from it.
(WebKit::UniqueIDBDatabase::didOpenBackingStoreAndReadMetadata): Callback once metadata from the backing store is ready for use.
(WebKit::UniqueIDBDatabase::absoluteDatabaseDirectory):
(WebKit::UniqueIDBDatabase::postMainThreadTask): Add a main thread task for this database.
(WebKit::UniqueIDBDatabase::performNextMainThreadTask):
(WebKit::UniqueIDBDatabase::postDatabaseTask): Add a database queue task for this database.
(WebKit::UniqueIDBDatabase::performNextDatabaseTask):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:

Add a virtual backing store interface:
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
(WebKit::UniqueIDBDatabaseBackingStore::~UniqueIDBDatabaseBackingStore):

Add a SQLite implementation of that interface:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp: Added.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::UniqueIDBDatabaseBackingStoreSQLite):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::extractExistingMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::openSQLiteDatabaseAtPath):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata):
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

Add a general purpose asynchronous task that does cross thread copying:
* Shared/AsyncTask.h: Added.
(WebKit::AsyncTask::~AsyncTask):
(WebKit::AsyncTask::AsyncTask):
(WebKit::createAsyncTask):

Add more isolated copiers and introduce WebKit CrossThreadCopier specializations:
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseIdentifier.cpp:
(WebKit::UniqueIDBDatabaseIdentifier::isolatedCopy):
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseIdentifier.h:

* Shared/SecurityOriginData.cpp:
(WebKit::SecurityOriginData::isolatedCopy):
* Shared/SecurityOriginData.h:

* Shared/WebCrossThreadCopier.cpp:
(WebCore::::copy):
* Shared/WebCrossThreadCopier.h:

* WebKit2.xcodeproj/project.pbxproj:

Source/WTF:

* wtf/text/WTFString.h: Export toUInt64Strict().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160517 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/text/WTFString.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.cpp [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.h
Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp
Source/WebCore/Modules/indexeddb/IDBKeyPath.h
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/CrossThreadCopier.cpp
Source/WebCore/platform/CrossThreadCopier.h
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
Source/WebKit2/DatabaseProcess/DatabaseProcess.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseIdentifier.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseIdentifier.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h [new file with mode: 0644]
Source/WebKit2/Shared/AsyncTask.h [new file with mode: 0644]
Source/WebKit2/Shared/SecurityOriginData.cpp
Source/WebKit2/Shared/SecurityOriginData.h
Source/WebKit2/Shared/WebCrossThreadCopier.cpp [new file with mode: 0644]
Source/WebKit2/Shared/WebCrossThreadCopier.h [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj