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)
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

index d2320b5..f045675 100644 (file)
@@ -1,3 +1,12 @@
+2013-12-12  Brady Eidson  <beidson@apple.com>
+
+        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.
+
+        * wtf/text/WTFString.h: Export toUInt64Strict().
+
 2013-12-12  Sam Weinig  <sam@webkit.org>
 
         Replace uses of WTF::BitArray with std::bitset
index 3c424b4..b3d8406 100644 (file)
@@ -368,7 +368,7 @@ public:
     WTF_EXPORT_STRING_API int toIntStrict(bool* ok = 0, int base = 10) const;
     WTF_EXPORT_STRING_API unsigned toUIntStrict(bool* ok = 0, int base = 10) const;
     WTF_EXPORT_STRING_API int64_t toInt64Strict(bool* ok = 0, int base = 10) const;
-    uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const;
+    WTF_EXPORT_STRING_API uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const;
     intptr_t toIntPtrStrict(bool* ok = 0, int base = 10) const;
 
     WTF_EXPORT_STRING_API int toInt(bool* ok = 0) const;
index 92bc33f..e072f3a 100644 (file)
@@ -800,6 +800,7 @@ set(WebCore_SOURCES
     Modules/indexeddb/IDBDatabaseBackend.cpp
     Modules/indexeddb/IDBDatabaseCallbacksImpl.cpp
     Modules/indexeddb/IDBDatabaseException.cpp
+    Modules/indexeddb/IDBDatabaseMetadata.cpp
     Modules/indexeddb/IDBEventDispatcher.cpp
     Modules/indexeddb/IDBFactory.cpp
     Modules/indexeddb/IDBFactoryBackendInterface.cpp
index 62e5150..909c054 100644 (file)
@@ -1,3 +1,31 @@
+2013-12-12  Brady Eidson  <beidson@apple.com>
+
+        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.
+
+        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:
+
 2013-12-12  Alexey Proskuryakov  <ap@apple.com>
 
         Add support for RSAES-PKCS1-v1_5
index 84639d9..2685f3a 100644 (file)
@@ -1827,6 +1827,7 @@ webcore_modules_sources += \
        Source/WebCore/Modules/indexeddb/IDBDatabaseError.h \
        Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp \
        Source/WebCore/Modules/indexeddb/IDBDatabaseException.h \
+       Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.cpp \
        Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.h \
        Source/WebCore/Modules/indexeddb/IDBEventDispatcher.cpp \
        Source/WebCore/Modules/indexeddb/IDBEventDispatcher.h \
diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabaseMetadata.cpp
new file mode 100644 (file)
index 0000000..0d14288
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBDatabaseMetadata.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+IDBDatabaseMetadata IDBDatabaseMetadata::isolatedCopy() const
+{
+    IDBDatabaseMetadata result;
+    result.id = id;
+    result.version = version;
+    result.maxObjectStoreId = maxObjectStoreId;
+
+    result.name = name.isolatedCopy();
+
+    for (auto i = objectStores.begin(), end = objectStores.end(); i != end; ++i)
+        result.objectStores.set(i->key, i->value.isolatedCopy());
+
+    return result;
+}
+
+IDBObjectStoreMetadata IDBObjectStoreMetadata::isolatedCopy() const
+{
+    IDBObjectStoreMetadata result;
+    result.id = id;
+    result.autoIncrement = autoIncrement;
+    result.maxIndexId = maxIndexId;
+
+    result.name = name.isolatedCopy();
+    result.keyPath = keyPath.isolatedCopy();
+
+    for (auto i = indexes.begin(), end = indexes.end(); i != end; ++i)
+        result.indexes.set(i->key, i->value.isolatedCopy());
+
+    return result;
+}
+
+IDBIndexMetadata IDBIndexMetadata::isolatedCopy() const
+{
+    IDBIndexMetadata result;
+    result.id = id;
+    result.unique = unique;
+    result.multiEntry = multiEntry;
+
+    result.name = name.isolatedCopy();
+    result.keyPath = keyPath.isolatedCopy();
+
+    return result;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
index cda564d..dda53b9 100644 (file)
@@ -53,6 +53,8 @@ struct IDBIndexMetadata {
     bool unique;
     bool multiEntry;
 
+    IDBIndexMetadata isolatedCopy() const;
+
     static const int64_t InvalidId = -1;
 };
 
@@ -77,6 +79,7 @@ struct IDBObjectStoreMetadata {
     typedef HashMap<int64_t, IDBIndexMetadata> IndexMap;
     IndexMap indexes;
 
+    IDBObjectStoreMetadata isolatedCopy() const;
 };
 
 struct IDBDatabaseMetadata {
@@ -120,6 +123,8 @@ struct IDBDatabaseMetadata {
     int64_t maxObjectStoreId;
 
     ObjectStoreMap objectStores;
+
+    IDBDatabaseMetadata isolatedCopy() const;
 };
 
 }
index 7d8c8d2..996f041 100644 (file)
@@ -248,6 +248,18 @@ bool IDBKeyPath::operator==(const IDBKeyPath& other) const
     return false;
 }
 
+IDBKeyPath IDBKeyPath::isolatedCopy() const
+{
+    IDBKeyPath result;
+    result.m_type = m_type;
+    result.m_string = m_string.isolatedCopy();
+
+    result.m_array.reserveInitialCapacity(m_array.size());
+    for (size_t i = 0; i < m_array.size(); ++i)
+        result.m_array.uncheckedAppend(m_array[i].isolatedCopy());
+
+    return result;
+}
 
 } // namespace WebCore
 
index 3d00182..135f613 100644 (file)
@@ -72,6 +72,8 @@ public:
     bool isValid() const;
     bool operator==(const IDBKeyPath& other) const;
 
+    IDBKeyPath isolatedCopy() const;
+
 private:
     Type m_type;
     String m_string;
index dfbb967..08d3eb7 100644 (file)
@@ -367,9 +367,11 @@ __ZN7WebCore14ResourceLoader14cancelledErrorEv
 __ZN7WebCore14ResourceLoader32didCancelAuthenticationChallengeERKNS_23AuthenticationChallengeE
 __ZN7WebCore14ResourceLoader6cancelEv
 __ZN7WebCore14SQLiteDatabase11tableExistsERKN3WTF6StringE
+__ZN7WebCore14SQLiteDatabase12lastErrorMsgEv
 __ZN7WebCore14SQLiteDatabase14executeCommandERKN3WTF6StringE
 __ZN7WebCore14SQLiteDatabase4openERKN3WTF6StringEb
 __ZN7WebCore14SQLiteDatabase5closeEv
+__ZN7WebCore14SQLiteDatabase9lastErrorEv
 __ZN7WebCore14SQLiteDatabaseC1Ev
 __ZN7WebCore14SQLiteDatabaseD1Ev
 __ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKN3WTF6StringE
@@ -574,12 +576,14 @@ __ZN7WebCore15ProtectionSpaceC1Ev
 __ZN7WebCore15ResourceRequest21httpPipeliningEnabledEv
 __ZN7WebCore15ResourceRequest24setHTTPPipeliningEnabledEb
 __ZN7WebCore15SQLiteStatement12getColumnIntEi
+__ZN7WebCore15SQLiteStatement12isColumnNullEi
 __ZN7WebCore15SQLiteStatement13getColumnTextEi
 __ZN7WebCore15SQLiteStatement14executeCommandEv
 __ZN7WebCore15SQLiteStatement21getColumnBlobAsStringEi
 __ZN7WebCore15SQLiteStatement22isColumnDeclaredAsBlobEi
 __ZN7WebCore15SQLiteStatement4stepEv
 __ZN7WebCore15SQLiteStatement5resetEv
+__ZN7WebCore15SQLiteStatement7bindIntEii
 __ZN7WebCore15SQLiteStatement7prepareEv
 __ZN7WebCore15SQLiteStatement8bindBlobEiRKN3WTF6StringE
 __ZN7WebCore15SQLiteStatement8bindTextEiRKN3WTF6StringE
@@ -694,6 +698,7 @@ __ZN7WebCore17SQLiteTransactionD1Ev
 __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
 __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
 __ZN7WebCore17drawLayerContentsEP9CGContextPNS_15PlatformCALayerERN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
+__ZN7WebCore17encodeForFileNameERKN3WTF6StringE
 __ZN7WebCore17languageDidChangeEv
 __ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
 __ZN7WebCore17setCookiesFromDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_RKN3WTF6StringE
@@ -788,6 +793,8 @@ __ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
 __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
 __ZN7WebCore20toUInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore21BackForwardController11itemAtIndexEi
+__ZN7WebCore21CrossThreadCopierBaseILb0ELb0EN3WTF6StringEE4copyERKS2_
+__ZN7WebCore21CrossThreadCopierBaseILb0ELb0ENS_19IDBDatabaseMetadataEE4copyERKS1_
 __ZN7WebCore21MemoryPressureHandler7installEv
 __ZN7WebCore21NetworkStorageSession21defaultStorageSessionEv
 __ZN7WebCore21NetworkStorageSession25switchToNewTestingSessionEv
@@ -1591,6 +1598,7 @@ __ZNK7WebCore18RenderLayerBacking20compositingLayerTypeEv
 __ZNK7WebCore19AnimationController11isSuspendedEv
 __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEPNS_8DocumentE
 __ZNK7WebCore19AnimationController33allowsNewAnimationsWhileSuspendedEv
+__ZNK7WebCore19IDBDatabaseMetadata12isolatedCopyEv
 __ZNK7WebCore19InspectorController12getHighlightEPNS_9HighlightE
 __ZNK7WebCore19InspectorController29buildObjectForHighlightedNodeEv
 __ZNK7WebCore19ResourceRequestBase10httpMethodEv
index 52380c2..1adb991 100644 (file)
                2E4346540F546A8200B0F1BA /* WorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E4346420F546A8200B0F1BA /* WorkerThread.cpp */; };
                2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346430F546A8200B0F1BA /* WorkerThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E4346580F546A9900B0F1BA /* CrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E4346560F546A9900B0F1BA /* CrossThreadCopier.cpp */; };
-               2E4346590F546A9900B0F1BA /* CrossThreadCopier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346570F546A9900B0F1BA /* CrossThreadCopier.h */; };
+               2E4346590F546A9900B0F1BA /* CrossThreadCopier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346570F546A9900B0F1BA /* CrossThreadCopier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E7582EE12764F260062628B /* JSFileReaderCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E7582ED12764F260062628B /* JSFileReaderCustom.cpp */; };
                2E75841D12779ADA0062628B /* FileReaderLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E75841A12779ADA0062628B /* FileReaderLoader.cpp */; };
                2E75841E12779ADA0062628B /* FileReaderLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841B12779ADA0062628B /* FileReaderLoader.h */; };
                5160F4980B0AA75F00C1D2AF /* HistoryItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */; };
                5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */; };
                5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5163117D1851242B00534647 /* IDBDatabaseMetadata.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5163117C1851242B00534647 /* IDBDatabaseMetadata.cpp */; };
                5164ED43183208C700EA8FF1 /* IDBServerConnectionLevelDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5164ED41183208C700EA8FF1 /* IDBServerConnectionLevelDB.cpp */; };
                5164ED44183208C700EA8FF1 /* IDBServerConnectionLevelDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 5164ED42183208C700EA8FF1 /* IDBServerConnectionLevelDB.h */; };
                51660AB61828BB8200074CAD /* IDBBackingStoreLevelDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51660AB01828BB8200074CAD /* IDBBackingStoreLevelDB.cpp */; };
                5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = HistoryItemMac.mm; path = mac/HistoryItemMac.mm; sourceTree = "<group>"; };
                5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchemeRegistry.cpp; sourceTree = "<group>"; };
                5162C7F311F77EFB00612EFE /* SchemeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchemeRegistry.h; sourceTree = "<group>"; };
+               5163117C1851242B00534647 /* IDBDatabaseMetadata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBDatabaseMetadata.cpp; sourceTree = "<group>"; };
                5164ED41183208C700EA8FF1 /* IDBServerConnectionLevelDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBServerConnectionLevelDB.cpp; sourceTree = "<group>"; };
                5164ED42183208C700EA8FF1 /* IDBServerConnectionLevelDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBServerConnectionLevelDB.h; sourceTree = "<group>"; };
                51660AB01828BB8200074CAD /* IDBBackingStoreLevelDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBBackingStoreLevelDB.cpp; sourceTree = "<group>"; };
                                51D71983181106DF0016DC51 /* IDBDatabaseError.h */,
                                51D71984181106DF0016DC51 /* IDBDatabaseException.cpp */,
                                51D71985181106DF0016DC51 /* IDBDatabaseException.h */,
+                               5163117C1851242B00534647 /* IDBDatabaseMetadata.cpp */,
                                51C9611A183D2B8000D2002E /* IDBDatabaseMetadata.h */,
                                51D71986181106DF0016DC51 /* IDBEventDispatcher.cpp */,
                                51D71987181106DF0016DC51 /* IDBEventDispatcher.h */,
                                B2AFFC990D00A5DF0030074D /* TextCodecMac.cpp in Sources */,
                                B2C3DA3F0D006C1D00EF6F26 /* TextCodecUserDefined.cpp in Sources */,
                                E1233F10185A4130008DFAF5 /* CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp in Sources */,
+                               5163117D1851242B00534647 /* IDBDatabaseMetadata.cpp in Sources */,
                                B2C3DA410D006C1D00EF6F26 /* TextCodecUTF16.cpp in Sources */,
                                E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */,
                                9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */,
index 5e8ba79..65df47d 100644 (file)
 #include <wtf/Assertions.h>
 #include <wtf/text/WTFString.h>
 
+#if ENABLE(INDEXED_DATABASE)
+#include "IDBDatabaseMetadata.h"
+#endif
+
 namespace WebCore {
 
 CrossThreadCopierBase<false, false, URL>::Type CrossThreadCopierBase<false, false, URL>::copy(const URL& url)
@@ -67,6 +71,15 @@ CrossThreadCopierBase<false, false, ResourceResponse>::Type CrossThreadCopierBas
     return response.copyData();
 }
 
+#if ENABLE(INDEXED_DATABASE)
+
+CrossThreadCopierBase<false, false, IDBDatabaseMetadata>::Type CrossThreadCopierBase<false, false, IDBDatabaseMetadata>::copy(const IDBDatabaseMetadata& metadata)
+{
+    return metadata.isolatedCopy();
+}
+
+#endif
+
 // Test CrossThreadCopier using COMPILE_ASSERT.
 
 // Verify that ThreadSafeRefCounted objects get handled correctly.
index c77c91b..f4c93d5 100644 (file)
@@ -145,6 +145,14 @@ namespace WebCore {
         static Type copy(const ResourceResponse&);
     };
 
+#if ENABLE(INDEXED_DATABASE)
+    struct IDBDatabaseMetadata;
+    template<> struct CrossThreadCopierBase<false, false, IDBDatabaseMetadata> {
+        typedef IDBDatabaseMetadata Type;
+        static Type copy(const IDBDatabaseMetadata&);
+    };
+#endif
+
     template<typename T>
     struct CrossThreadCopier : public CrossThreadCopierBase<CrossThreadCopierBaseHelper::IsConvertibleToInteger<T>::value, CrossThreadCopierBaseHelper::IsThreadSafeRefCountedPointer<T>::value, T> {
     };
index 2f49b46..01f4422 100644 (file)
@@ -1,3 +1,83 @@
+2013-12-12  Brady Eidson  <beidson@apple.com>
+
+        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.
+
+        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:
+
 2013-12-12  Chris Fleizach  <cfleizach@apple.com>
 
         AX: HANG: virginamerica.com: Pressing the print button on the boarding pass page locks up VoiceOver and Safari.
index b1bdc7c..dd47921 100644 (file)
 
 #if ENABLE(DATABASE_PROCESS)
 
+#include "AsyncTask.h"
 #include "DatabaseProcessCreationParameters.h"
 #include "DatabaseProcessProxyMessages.h"
 #include "DatabaseToWebProcessConnection.h"
 #include "UniqueIDBDatabase.h"
+#include <WebCore/FileSystem.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
 
 namespace WebKit {
 
@@ -87,13 +92,59 @@ void DatabaseProcess::removeUniqueIDBDatabase(const UniqueIDBDatabase& database)
     const UniqueIDBDatabaseIdentifier& identifier = database.identifier();
     ASSERT(m_idbDatabases.contains(identifier));
 
-    // FIXME: Perform necessary shut down of the unique database before it is actually destroyed.
     m_idbDatabases.remove(identifier);
 }
 
 void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationParameters& parameters)
 {
     m_indexedDatabaseDirectory = parameters.indexedDatabaseDirectory;
+
+    ensureIndexedDatabaseRelativePathExists(StringImpl::empty());
+}
+
+void DatabaseProcess::ensureIndexedDatabaseRelativePathExists(const String& relativePath)
+{
+    postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::ensurePathExists, absoluteIndexedDatabasePathFromDatabaseRelativePath(relativePath)));
+}
+
+void DatabaseProcess::ensurePathExists(const String& path)
+{
+    ASSERT(!isMainThread());
+
+    if (!makeAllDirectories(path))
+        LOG_ERROR("Failed to make all directories for path '%s'", path.utf8().data());
+}
+
+String DatabaseProcess::absoluteIndexedDatabasePathFromDatabaseRelativePath(const String& relativePath)
+{
+    // FIXME: pathByAppendingComponent() was originally designed to append individual atomic components.
+    // We don't have a function designed to append a multi-component subpath, but we should.
+    return pathByAppendingComponent(m_indexedDatabaseDirectory, relativePath);
+}
+
+void DatabaseProcess::postDatabaseTask(std::unique_ptr<AsyncTask> task)
+{
+    ASSERT(isMainThread());
+
+    MutexLocker locker(m_databaseTaskMutex);
+
+    m_databaseTasks.append(std::move(task));
+
+    m_queue->dispatch(bind(&DatabaseProcess::performNextDatabaseTask, this));
+}
+
+void DatabaseProcess::performNextDatabaseTask()
+{
+    ASSERT(!isMainThread());
+
+    std::unique_ptr<AsyncTask> task;
+    {
+        MutexLocker locker(m_databaseTaskMutex);
+        ASSERT(!m_databaseTasks.isEmpty());
+        task = m_databaseTasks.takeFirst();
+    }
+
+    task->performTask();
 }
 
 void DatabaseProcess::createDatabaseToWebProcessConnection()
index 8377a4c..247562c 100644 (file)
@@ -35,6 +35,7 @@ class WorkQueue;
 
 namespace WebKit {
 
+class AsyncTask;
 class DatabaseToWebProcessConnection;
 class UniqueIDBDatabase;
 
@@ -50,7 +51,10 @@ public:
     PassRefPtr<UniqueIDBDatabase> getOrCreateUniqueIDBDatabase(const UniqueIDBDatabaseIdentifier&);
     void removeUniqueIDBDatabase(const UniqueIDBDatabase&);
 
-    WorkQueue& queue() const { return const_cast<WorkQueue&>(m_queue.get()); }
+    void ensureIndexedDatabaseRelativePathExists(const String&);
+    String absoluteIndexedDatabasePathFromDatabaseRelativePath(const String&);
+
+    WorkQueue& queue() { return m_queue.get(); }
 
 private:
     DatabaseProcess();
@@ -72,6 +76,12 @@ private:
     void initializeDatabaseProcess(const DatabaseProcessCreationParameters&);
     void createDatabaseToWebProcessConnection();
 
+    void postDatabaseTask(std::unique_ptr<AsyncTask>);
+
+    // For execution on work queue thread only
+    void performNextDatabaseTask();
+    void ensurePathExists(const String&);
+
     Vector<RefPtr<DatabaseToWebProcessConnection>> m_databaseToWebProcessConnections;
 
     Ref<WorkQueue> m_queue;
@@ -79,6 +89,9 @@ private:
     String m_indexedDatabaseDirectory;
 
     HashMap<UniqueIDBDatabaseIdentifier, RefPtr<UniqueIDBDatabase>> m_idbDatabases;
+
+    Deque<std::unique_ptr<AsyncTask>> m_databaseTasks;
+    Mutex m_databaseTaskMutex;
 };
 
 } // namespace WebKit
index bc7245c..e7cd847 100644 (file)
 #if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
 
 #include "AsyncRequest.h"
+#include "AsyncTask.h"
 #include "DatabaseProcess.h"
 #include "DatabaseProcessIDBConnection.h"
+#include "UniqueIDBDatabaseBackingStoreSQLite.h"
+#include "WebCrossThreadCopier.h"
+#include <WebCore/FileSystem.h>
 #include <WebCore/IDBDatabaseMetadata.h>
 #include <wtf/MainThread.h>
 
@@ -40,12 +44,49 @@ namespace WebKit {
 
 UniqueIDBDatabase::UniqueIDBDatabase(const UniqueIDBDatabaseIdentifier& identifier)
     : m_identifier(identifier)
-    , m_processingDatabaseQueueRequests(false)
+    , m_acceptingNewRequests(true)
+    , m_didGetMetadataFromBackingStore(false)
 {
+    m_inMemory = !canShareDatabases(identifier.openingOrigin(), identifier.mainFrameOrigin());
+    if (m_inMemory)
+        return;
+
+    // Each unique Indexed Database exists in a directory named for the database, which exists in a directory representing its opening origin.
+    m_databaseRelativeDirectory = pathByAppendingComponent(databaseFilenameIdentifier(identifier.openingOrigin()), filenameForDatabaseName());
+
+    DatabaseProcess::shared().ensureIndexedDatabaseRelativePathExists(m_databaseRelativeDirectory);
 }
 
 UniqueIDBDatabase::~UniqueIDBDatabase()
 {
+    ASSERT(!m_acceptingNewRequests);
+    ASSERT(m_pendingMetadataRequests.isEmpty());
+}
+
+String UniqueIDBDatabase::filenameForDatabaseName() const
+{
+    ASSERT(!m_identifier.databaseName().isNull());
+
+    if (m_identifier.databaseName().isEmpty())
+        return "%00";
+
+    String filename = encodeForFileName(m_identifier.databaseName());
+    filename.replace('.', "%2E");
+
+    return filename;
+}
+
+String UniqueIDBDatabase::databaseFilenameIdentifier(const SecurityOriginData& originData) const
+{
+    RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(originData.protocol, originData.host, originData.port);
+    return securityOrigin->databaseIdentifier();
+}
+
+bool UniqueIDBDatabase::canShareDatabases(const SecurityOriginData& openingOrigin, const SecurityOriginData& mainFrameOrigin) const
+{
+    // For now, an origin's database access is predicated on equality with the other origin.
+    // We might need to make this more nuanced later.
+    return openingOrigin == mainFrameOrigin;
 }
 
 void UniqueIDBDatabase::registerConnection(DatabaseProcessIDBConnection& connection)
@@ -59,70 +100,171 @@ void UniqueIDBDatabase::unregisterConnection(DatabaseProcessIDBConnection& conne
     ASSERT(m_connections.contains(&connection));
     m_connections.remove(&connection);
 
-    if (m_connections.isEmpty())
+    if (m_connections.isEmpty()) {
+        shutdown();
         DatabaseProcess::shared().removeUniqueIDBDatabase(*this);
+    }
+}
+
+void UniqueIDBDatabase::shutdown()
+{
+    ASSERT(isMainThread());
+
+    m_acceptingNewRequests = false;
+
+    {
+        MutexLocker locker(m_databaseTaskMutex);
+        m_databaseTasks.clear();
+    }
+
+    {
+        MutexLocker locker(m_mainThreadTaskMutex);
+        m_mainThreadTasks.clear();
+    }
+
+    while (!m_pendingMetadataRequests.isEmpty()) {
+        auto request = m_pendingMetadataRequests.takeFirst();
+        request->requestAborted();
+    }
 }
 
-void UniqueIDBDatabase::enqueueDatabaseQueueRequest(PassRefPtr<AsyncRequest> request)
+void UniqueIDBDatabase::getOrEstablishIDBDatabaseMetadata(std::function<void(bool, const IDBDatabaseMetadata&)> completionCallback)
 {
-    ASSERT(request);
+    ASSERT(isMainThread());
+
+    if (!m_acceptingNewRequests) {
+        completionCallback(false, IDBDatabaseMetadata());
+        return;
+    }
 
-    MutexLocker locker(m_databaseQueueRequestsMutex);
-    m_databaseQueueRequests.append(request);
+    // If we've already retrieved metadata from the backing store, return it now.
+    if (m_didGetMetadataFromBackingStore) {
+        if (m_metadata)
+            completionCallback(true, *m_metadata);
+        else
+            completionCallback(false, IDBDatabaseMetadata());
 
-    if (m_processingDatabaseQueueRequests)
         return;
+    }
+
+    // If this is the first unanswered metadata request, post a task to open the backing store and get metadata.
+    if (m_pendingMetadataRequests.isEmpty())
+        postDatabaseTask(createAsyncTask(*this, &UniqueIDBDatabase::openBackingStoreAndReadMetadata, m_identifier, absoluteDatabaseDirectory()));
+
+    // Then remember this metadata request to be answered later.
+    RefPtr<AsyncRequest> request = AsyncRequestImpl<>::create([completionCallback, this]() {
+        completionCallback(!!m_metadata, m_metadata ? *m_metadata : IDBDatabaseMetadata());
+    }, [completionCallback]() {
+        // The boolean flag to the completion callback represents whether the
+        // attempt to get/establish metadata succeeded or failed.
+        // Since we're aborting the attempt, it failed, so we always pass in false.
+        completionCallback(false, IDBDatabaseMetadata());
+    });
 
-    m_processingDatabaseQueueRequests = true;
-    DatabaseProcess::shared().queue().dispatch(bind(&UniqueIDBDatabase::processDatabaseRequestQueue, this));
+    m_pendingMetadataRequests.append(request.release());
 }
 
-void UniqueIDBDatabase::processDatabaseRequestQueue()
+void UniqueIDBDatabase::openBackingStoreAndReadMetadata(const UniqueIDBDatabaseIdentifier& identifier, const String& databaseDirectory)
 {
-    ASSERT(m_processingDatabaseQueueRequests);
+    ASSERT(!isMainThread());
+    ASSERT(!m_backingStore);
 
-    while (true) {
-        RefPtr<AsyncRequest> request;
-        {
-            MutexLocker locker(m_databaseQueueRequestsMutex);
-            if (m_databaseQueueRequests.isEmpty()) {
-                m_processingDatabaseQueueRequests = false;
-                return;
-            }
-            request = m_databaseQueueRequests.takeFirst();
-        }
+    if (m_inMemory) {
+        LOG_ERROR("Support for in-memory databases not yet implemented");
+        return;
+    }
 
+    m_backingStore = UniqueIDBDatabaseBackingStoreSQLite::create(identifier, databaseDirectory);
+    std::unique_ptr<IDBDatabaseMetadata> metadata = m_backingStore->getOrEstablishMetadata();
+
+    postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didOpenBackingStoreAndReadMetadata, metadata ? *metadata : IDBDatabaseMetadata(), !!metadata));
+}
+
+void UniqueIDBDatabase::didOpenBackingStoreAndReadMetadata(const IDBDatabaseMetadata& metadata, bool success)
+{
+    ASSERT(isMainThread());
+    ASSERT(!m_metadata);
+
+    m_didGetMetadataFromBackingStore = true;
+
+    if (success)
+        m_metadata = std::make_unique<IDBDatabaseMetadata>(metadata);
+
+    while (!m_pendingMetadataRequests.isEmpty()) {
+        RefPtr<AsyncRequest> request = m_pendingMetadataRequests.takeFirst();
         request->completeRequest();
     }
 }
 
-void UniqueIDBDatabase::getOrEstablishIDBDatabaseMetadata(std::function<void(bool, const IDBDatabaseMetadata&)> completionCallback)
+String UniqueIDBDatabase::absoluteDatabaseDirectory() const
 {
-    RefPtr<AsyncRequest> request = AsyncRequestImpl<>::create([completionCallback, this]() {
-        IDBDatabaseMetadata metadata;
-        bool success = getOrEstablishIDBDatabaseMetadataInternal(metadata);
+    ASSERT(isMainThread());
+    return DatabaseProcess::shared().absoluteIndexedDatabasePathFromDatabaseRelativePath(m_databaseRelativeDirectory);
+}
 
-        RunLoop::main()->dispatch([metadata, success, completionCallback]() {
-            completionCallback(success, metadata);
-        });
-    }, [completionCallback]() {
-        RunLoop::main()->dispatch([completionCallback]() {
-            // The boolean flag to the completion callback represents whether the attempt to get/establish metadata
-            // succeeded or failed.
-            // Since we're aborting the attempt, it failed, so we always pass in false.
-            completionCallback(false, IDBDatabaseMetadata());
-        });
-    });
+void UniqueIDBDatabase::postMainThreadTask(std::unique_ptr<AsyncTask> task)
+{
+    ASSERT(!isMainThread());
 
-    enqueueDatabaseQueueRequest(request.release());
+    if (!m_acceptingNewRequests)
+        return;
+
+    MutexLocker locker(m_mainThreadTaskMutex);
+
+    m_mainThreadTasks.append(std::move(task));
+
+    RunLoop::main()->dispatch(bind(&UniqueIDBDatabase::performNextMainThreadTask, this));
 }
 
-bool UniqueIDBDatabase::getOrEstablishIDBDatabaseMetadataInternal(const WebCore::IDBDatabaseMetadata&)
+void UniqueIDBDatabase::performNextMainThreadTask()
+{
+    ASSERT(isMainThread());
+
+    std::unique_ptr<AsyncTask> task;
+    {
+        MutexLocker locker(m_mainThreadTaskMutex);
+        ASSERT(!m_mainThreadTasks.isEmpty());
+        task = m_mainThreadTasks.takeFirst();
+    }
+
+    task->performTask();
+}
+
+void UniqueIDBDatabase::postDatabaseTask(std::unique_ptr<AsyncTask> task)
+{
+    ASSERT(isMainThread());
+
+    if (!m_acceptingNewRequests)
+        return;
+
+    MutexLocker locker(m_databaseTaskMutex);
+
+    m_databaseTasks.append(std::move(task));
+
+    DatabaseProcess::shared().queue().dispatch(bind(&UniqueIDBDatabase::performNextDatabaseTask, this));
+}
+
+void UniqueIDBDatabase::performNextDatabaseTask()
 {
-    // FIXME: This method is successfully called by messaging from the WebProcess, and calls back with dummy data.
-    // Needs real implementation.
     ASSERT(!isMainThread());
-    return false;
+
+    // It is possible that this database might be shutting down on the main thread.
+    // In this case, immediately after releasing m_databaseTaskMutex, this database might get deleted.
+    // We take a ref() to make sure the database is still live while this last task is performed.
+    RefPtr<UniqueIDBDatabase> protector(this);
+
+    std::unique_ptr<AsyncTask> task;
+    {
+        MutexLocker locker(m_databaseTaskMutex);
+
+        // This database might be shutting down on the main thread, in which case the task queue might be empty.
+        if (m_databaseTasks.isEmpty())
+            return;
+
+        task = m_databaseTasks.takeFirst();
+    }
+
+    task->performTask();
 }
 
 } // namespace WebKit
index 3de0104..f21d4f5 100644 (file)
@@ -43,11 +43,13 @@ struct IDBDatabaseMetadata;
 namespace WebKit {
 
 class AsyncRequest;
+class AsyncTask;
 class DatabaseProcessIDBConnection;
+class UniqueIDBDatabaseBackingStore;
 
 struct SecurityOriginData;
 
-class UniqueIDBDatabase : public RefCounted<UniqueIDBDatabase> {
+class UniqueIDBDatabase : public ThreadSafeRefCounted<UniqueIDBDatabase> {
 public:
     static PassRefPtr<UniqueIDBDatabase> create(const UniqueIDBDatabaseIdentifier& identifier)
     {
@@ -68,18 +70,48 @@ private:
 
     UniqueIDBDatabaseIdentifier m_identifier;
 
+    bool m_inMemory;
+    String m_databaseRelativeDirectory;
+
     HashSet<RefPtr<DatabaseProcessIDBConnection>> m_connections;
     HashMap<uint64_t, RefPtr<AsyncRequest>> m_databaseRequests;
 
-    void enqueueDatabaseQueueRequest(PassRefPtr<AsyncRequest>);
+    String absoluteDatabaseDirectory() const;
+
+    void postDatabaseTask(std::unique_ptr<AsyncTask>);
+    void shutdown();
+
+    // Method that attempts to make legal filenames from all legal database names
+    String filenameForDatabaseName() const;
 
+    // Returns a string that is appropriate for use as a unique filename
+    String databaseFilenameIdentifier(const SecurityOriginData&) const;
+
+    // Returns true if this origin can use the same databases as the given origin.
+    bool canShareDatabases(const SecurityOriginData&, const SecurityOriginData&) const;
+    
     // To be called from the database workqueue thread only
-    void processDatabaseRequestQueue();
-    bool getOrEstablishIDBDatabaseMetadataInternal(const WebCore::IDBDatabaseMetadata&);
+    void performNextDatabaseTask();
+    void postMainThreadTask(std::unique_ptr<AsyncTask>);
+    void openBackingStoreAndReadMetadata(const UniqueIDBDatabaseIdentifier&, const String& databaseDirectory);
+
+    // Callbacks from the database workqueue thread, to be performed on the main thread only
+    void performNextMainThreadTask();
+    void didOpenBackingStoreAndReadMetadata(const WebCore::IDBDatabaseMetadata&, bool success);
+
+    Deque<RefPtr<AsyncRequest>> m_pendingMetadataRequests;
+    bool m_acceptingNewRequests;
+
+    std::unique_ptr<WebCore::IDBDatabaseMetadata> m_metadata;
+    bool m_didGetMetadataFromBackingStore;
+
+    RefPtr<UniqueIDBDatabaseBackingStore> m_backingStore;
+
+    Deque<std::unique_ptr<AsyncTask>> m_databaseTasks;
+    Mutex m_databaseTaskMutex;
 
-    Mutex m_databaseQueueRequestsMutex;
-    Deque<RefPtr<AsyncRequest>> m_databaseQueueRequests;
-    bool m_processingDatabaseQueueRequests;
+    Deque<std::unique_ptr<AsyncTask>> m_mainThreadTasks;
+    Mutex m_mainThreadTaskMutex;
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h b/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h
new file mode 100644 (file)
index 0000000..24b8d01
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UniqueIDBDatabaseBackingStore_h
+#define UniqueIDBDatabaseBackingStore_h
+
+#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+struct IDBDatabaseMetadata;
+}
+
+namespace WebKit {
+
+class UniqueIDBDatabaseBackingStore : public RefCounted<UniqueIDBDatabaseBackingStore> {
+public:
+    virtual ~UniqueIDBDatabaseBackingStore() { }
+
+    virtual std::unique_ptr<WebCore::IDBDatabaseMetadata> getOrEstablishMetadata() = 0;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#endif // UniqueIDBDatabaseBackingStore_h
index ff8bd7e..198f019 100644 (file)
@@ -75,6 +75,17 @@ bool UniqueIDBDatabaseIdentifier::isNull() const
     return m_databaseName.isNull();
 }
 
+UniqueIDBDatabaseIdentifier UniqueIDBDatabaseIdentifier::isolatedCopy() const
+{
+    UniqueIDBDatabaseIdentifier result;
+
+    result.m_databaseName = m_databaseName.isolatedCopy();
+    result.m_openingOrigin = m_openingOrigin.isolatedCopy();
+    result.m_mainFrameOrigin = m_mainFrameOrigin.isolatedCopy();
+
+    return result;
+}
+
 bool operator==(const UniqueIDBDatabaseIdentifier& a, const UniqueIDBDatabaseIdentifier& b)
 {
     if (&a == &b)
index bebcdc4..dbf9daa 100644 (file)
@@ -50,6 +50,8 @@ public:
     bool isHashTableDeletedValue() const;
     unsigned hash() const;
 
+    UniqueIDBDatabaseIdentifier isolatedCopy() const;
+
 private:
     String m_databaseName;
     SecurityOriginData m_openingOrigin;
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp b/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp
new file mode 100644 (file)
index 0000000..4fa370a
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UniqueIDBDatabaseBackingStoreSQLite.h"
+
+#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+
+#include <WebCore/FileSystem.h>
+#include <WebCore/IDBDatabaseMetadata.h>
+#include <WebCore/SQLiteDatabase.h>
+#include <WebCore/SQLiteStatement.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Current version of the metadata schema being used in the metadata database.
+static const int currentMetadataVersion = 1;
+
+UniqueIDBDatabaseBackingStoreSQLite::UniqueIDBDatabaseBackingStoreSQLite(const UniqueIDBDatabaseIdentifier& identifier, const String& databaseDirectory)
+    : m_identifier(identifier)
+    , m_absoluteDatabaseDirectory(databaseDirectory)
+{
+    // The backing store is meant to be created and used entirely on a background thread.
+    ASSERT(!isMainThread());
+}
+
+std::unique_ptr<WebCore::IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata()
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_metadataDB);
+    ASSERT(m_metadataDB->isOpen());
+
+    if (!m_metadataDB->executeCommand("CREATE TABLE IDBDatabaseInfo (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, value TEXT NOT NULL ON CONFLICT FAIL);")) {
+        LOG_ERROR("Could not create IDBDatabaseInfo table in database (%i) - %s", m_metadataDB->lastError(), m_metadataDB->lastErrorMsg());
+        m_metadataDB = nullptr;
+        return nullptr;
+    }
+
+    {
+        SQLiteStatement sql(*m_metadataDB, "INSERT INTO IDBDatabaseInfo VALUES ('MetadataVersion', ?);");
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt(1, currentMetadataVersion) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR("Could not insert database metadata version into IDBDatabaseInfo table (%i) - %s", m_metadataDB->lastError(), m_metadataDB->lastErrorMsg());
+            m_metadataDB = nullptr;
+            return nullptr;
+        }
+    }
+    {
+        SQLiteStatement sql(*m_metadataDB, "INSERT INTO IDBDatabaseInfo VALUES ('DatabaseName', ?);");
+        if (sql.prepare() != SQLResultOk
+            || sql.bindText(1, m_identifier.databaseName()) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR("Could not insert database name into IDBDatabaseInfo table (%i) - %s", m_metadataDB->lastError(), m_metadataDB->lastErrorMsg());
+            m_metadataDB = nullptr;
+            return nullptr;
+        }
+    }
+    {
+        // Database versions are defined to be a uin64_t in the spec but sqlite3 doesn't support native binding of unsigned integers.
+        // Therefore we'll store the version as a String.
+        SQLiteStatement sql(*m_metadataDB, "INSERT INTO IDBDatabaseInfo VALUES ('DatabaseVersion', ?);");
+        if (sql.prepare() != SQLResultOk
+            || sql.bindText(1, String::number(0)) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR("Could not insert default version into IDBDatabaseInfo table (%i) - %s", m_metadataDB->lastError(), m_metadataDB->lastErrorMsg());
+            m_metadataDB = nullptr;
+            return nullptr;
+        }
+    }
+
+    // This initial metadata matches the default values we just put into the metadata database.
+    auto metadata = std::make_unique<IDBDatabaseMetadata>();
+    metadata->name = m_identifier.databaseName();
+    metadata->version = 0;
+
+    return metadata;
+}
+
+std::unique_ptr<IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::extractExistingMetadata()
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_metadataDB);
+
+    if (!m_metadataDB->tableExists("IDBDatabaseInfo"))
+        return nullptr;
+
+    auto metadata = std::make_unique<IDBDatabaseMetadata>();
+    {
+        SQLiteStatement sql(*m_metadataDB, "SELECT value FROM IDBDatabaseInfo WHERE key = 'MetadataVersion';");
+        if (sql.isColumnNull(0))
+            return nullptr;
+        metadata->version = sql.getColumnInt(0);
+    }
+    {
+        SQLiteStatement sql(*m_metadataDB, "SELECT value FROM IDBDatabaseInfo WHERE key = 'DatabaseName';");
+        if (sql.isColumnNull(0))
+            return nullptr;
+        metadata->name = sql.getColumnText(0);
+        if (metadata->name != m_identifier.databaseName()) {
+            LOG_ERROR("Database name in the metadata database ('%s') does not match the expected name ('%s')", metadata->name.utf8().data(), m_identifier.databaseName().utf8().data());
+            return nullptr;
+        }
+    }
+    {
+        SQLiteStatement sql(*m_metadataDB, "SELECT value FROM IDBDatabaseInfo WHERE key = 'DatabaseVersion';");
+        if (sql.isColumnNull(0))
+            return nullptr;
+        String stringVersion = sql.getColumnText(0);
+        bool ok;
+        metadata->version = stringVersion.toUInt64Strict(&ok);
+        if (!ok) {
+            LOG_ERROR("Database version on disk ('%s') does not cleanly convert to an unsigned 64-bit integer version", stringVersion.utf8().data());
+            return nullptr;
+        }
+    }
+
+    // FIXME: Once we save ObjectStores and indexes we need to extract their metadata, also.
+    return metadata;
+}
+
+std::unique_ptr<SQLiteDatabase> UniqueIDBDatabaseBackingStoreSQLite::openSQLiteDatabaseAtPath(const String& path)
+{
+    ASSERT(!isMainThread());
+
+    auto sqliteDatabase = std::make_unique<SQLiteDatabase>();
+    if (!sqliteDatabase->open(path)) {
+        LOG_ERROR("Failed to open SQLite database at path '%s'", path.utf8().data());
+        return nullptr;
+    }
+
+    return sqliteDatabase;
+}
+
+std::unique_ptr<IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata()
+{
+    ASSERT(!isMainThread());
+
+    String metadataDBFilename = pathByAppendingComponent(m_absoluteDatabaseDirectory, "IDBMetadata.sqlite3");
+    m_metadataDB = openSQLiteDatabaseAtPath(metadataDBFilename);
+    if (!m_metadataDB)
+        return nullptr;
+
+    std::unique_ptr<IDBDatabaseMetadata> metadata = extractExistingMetadata();
+    if (!metadata)
+        metadata = createAndPopulateInitialMetadata();
+
+    if (!metadata)
+        LOG_ERROR("Unable to establish IDB database at path '%s'", metadataDBFilename.utf8().data());
+
+    return metadata;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h b/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h
new file mode 100644 (file)
index 0000000..abf6c95
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UniqueIDBDatabaseBackingStoreSQLite_h
+#define UniqueIDBDatabaseBackingStoreSQLite_h
+
+#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+
+#include "UniqueIDBDatabase.h" 
+#include "UniqueIDBDatabaseBackingStore.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class SQLiteDatabase;
+struct IDBDatabaseMetadata;
+}
+
+namespace WebKit {
+
+class UniqueIDBDatabaseBackingStoreSQLite FINAL : public UniqueIDBDatabaseBackingStore {
+public:
+    static PassRefPtr<UniqueIDBDatabaseBackingStore> create(const UniqueIDBDatabaseIdentifier& identifier, const String& databaseDirectory)
+    {
+        return adoptRef(new UniqueIDBDatabaseBackingStoreSQLite(identifier, databaseDirectory));
+    }
+
+    virtual std::unique_ptr<WebCore::IDBDatabaseMetadata> getOrEstablishMetadata() OVERRIDE;
+
+private:
+    UniqueIDBDatabaseBackingStoreSQLite(const UniqueIDBDatabaseIdentifier&, const String& databaseDirectory);
+
+    std::unique_ptr<WebCore::SQLiteDatabase> openSQLiteDatabaseAtPath(const String&);
+    std::unique_ptr<WebCore::IDBDatabaseMetadata> extractExistingMetadata();
+    std::unique_ptr<WebCore::IDBDatabaseMetadata> createAndPopulateInitialMetadata();
+
+    UniqueIDBDatabaseIdentifier m_identifier;
+    String m_absoluteDatabaseDirectory;
+
+    std::unique_ptr<WebCore::SQLiteDatabase> m_metadataDB;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#endif // UniqueIDBDatabaseBackingStoreSQLite_h
diff --git a/Source/WebKit2/Shared/AsyncTask.h b/Source/WebKit2/Shared/AsyncTask.h
new file mode 100644 (file)
index 0000000..5c2064c
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AsyncTask_h
+#define AsyncTask_h
+
+#include <WebCore/CrossThreadCopier.h>
+#include <functional>
+
+namespace WebKit {
+
+class AsyncTask {
+    WTF_MAKE_NONCOPYABLE(AsyncTask);
+public:
+    virtual ~AsyncTask() { }
+
+    virtual void performTask() = 0;
+
+protected:
+    explicit AsyncTask() { }
+};
+
+template <typename T, typename... Arguments>
+class AsyncTaskImpl FINAL : public AsyncTask {
+public:
+    AsyncTaskImpl(T* callee, void (T::*method)(Arguments...), Arguments&&... arguments)
+    {
+        m_taskFunction = [callee, method, arguments...]() {
+            (callee->*method)(arguments...);
+        };
+    }
+
+    virtual ~AsyncTaskImpl()
+    {
+    }
+
+private:
+    virtual void performTask() OVERRIDE
+    {
+        m_taskFunction();
+    }
+
+    std::function<void()> m_taskFunction;
+};
+
+template<typename T>
+std::unique_ptr<AsyncTask> createAsyncTask(
+    T& callee,
+    void (T::*method)())
+{
+    return std::make_unique<AsyncTaskImpl<T>>(&callee, method);
+}
+
+template<typename T, typename P1, typename MP1>
+std::unique_ptr<AsyncTask> createAsyncTask(
+    T& callee,
+    void (T::*method)(MP1),
+    const P1& parameter1)
+{
+    return std::make_unique<AsyncTaskImpl<T, MP1>>(
+        &callee,
+        method,
+        WebCore::CrossThreadCopier<P1>::copy(parameter1));
+}
+
+template<typename T, typename P1, typename MP1, typename P2, typename MP2>
+std::unique_ptr<AsyncTask> createAsyncTask(
+    T& callee,
+    void (T::*method)(MP1, MP2),
+    const P1& parameter1,
+    const P2& parameter2)
+{
+    return std::make_unique<AsyncTaskImpl<T, MP1, MP2>>(
+        &callee,
+        method,
+        WebCore::CrossThreadCopier<P1>::copy(parameter1),
+        WebCore::CrossThreadCopier<P2>::copy(parameter2));
+
+}
+
+} // namespace WebKit
+
+#endif // AsyncTask_h
index daac6fb..dbf32fa 100644 (file)
@@ -29,6 +29,7 @@
 #include "APIArray.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebSecurityOrigin.h"
+#include <wtf/text/CString.h>
 
 using namespace WebCore;
 
@@ -69,6 +70,17 @@ bool SecurityOriginData::decode(CoreIPC::ArgumentDecoder& decoder, SecurityOrigi
     return true;
 }
 
+SecurityOriginData SecurityOriginData::isolatedCopy() const
+{
+    SecurityOriginData result;
+
+    result.protocol = protocol.isolatedCopy();
+    result.host = host.isolatedCopy();
+    result.port = port;
+
+    return result;
+}
+
 void performAPICallbackWithSecurityOriginDataVector(const Vector<SecurityOriginData>& originDatas, ArrayCallback* callback)
 {
     if (!callback) {
index c3f87a0..2d4169c 100644 (file)
@@ -52,6 +52,8 @@ struct SecurityOriginData {
     String protocol;
     String host;
     int port;
+
+    SecurityOriginData isolatedCopy() const;
 };
 
 void performAPICallbackWithSecurityOriginDataVector(const Vector<SecurityOriginData>&, ArrayCallback*);
diff --git a/Source/WebKit2/Shared/WebCrossThreadCopier.cpp b/Source/WebKit2/Shared/WebCrossThreadCopier.cpp
new file mode 100644 (file)
index 0000000..515767f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "WebCrossThreadCopier.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "UniqueIDBDatabaseIdentifier.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+UniqueIDBDatabaseIdentifier CrossThreadCopierBase<false, false, UniqueIDBDatabaseIdentifier>::copy(const UniqueIDBDatabaseIdentifier& identifier)
+{
+    return identifier.isolatedCopy();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/Shared/WebCrossThreadCopier.h b/Source/WebKit2/Shared/WebCrossThreadCopier.h
new file mode 100644 (file)
index 0000000..bfeda46
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebCrossThreadCopier_h
+#define WebCrossThreadCopier_h
+
+#include <WebCore/CrossThreadCopier.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit {
+class UniqueIDBDatabaseIdentifier;
+}
+
+namespace WebCore {
+
+template<> struct CrossThreadCopierBase<false, false, WebKit::UniqueIDBDatabaseIdentifier> {
+    static WebKit::UniqueIDBDatabaseIdentifier copy(const WebKit::UniqueIDBDatabaseIdentifier&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+#endif // WebCrossThreadCopier_h
index 24b89a2..570162f 100644 (file)
                515E773318402D510007203F /* UniqueIDBDatabaseIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515E773118402D510007203F /* UniqueIDBDatabaseIdentifier.cpp */; };
                515E773418402D510007203F /* UniqueIDBDatabaseIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E773218402D510007203F /* UniqueIDBDatabaseIdentifier.h */; };
                5160BFE113381DF900918999 /* Logging.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160BFE013381DF900918999 /* Logging.mac.mm */; };
+               516311871858446600534647 /* WebCrossThreadCopier.h in Headers */ = {isa = PBXBuildFile; fileRef = 516311861858446600534647 /* WebCrossThreadCopier.h */; };
                516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */; };
                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ACC9341628064800342550 /* NetworkProcessMessageReceiver.cpp */; };
                5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ACC9351628064800342550 /* NetworkProcessMessages.h */; };
+               51654EFD184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51654EFB184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp */; };
+               51654EFE184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 51654EFC184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.h */; };
+               51654F00184EF34A007DC837 /* UniqueIDBDatabaseBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51654EFF184EF34A007DC837 /* UniqueIDBDatabaseBackingStore.h */; };
                5167EEA0170377BF007681CA /* DiskCacheMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 5167EE9E170377BF007681CA /* DiskCacheMonitor.h */; };
                5167EEA1170377BF007681CA /* DiskCacheMonitor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5167EE9F170377BF007681CA /* DiskCacheMonitor.mm */; };
                516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */ = {isa = PBXBuildFile; fileRef = 516A4A5B120A2CCD00C05B7F /* WebError.h */; };
                51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; };
                51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */; };
                51B3005112529D0E000B5CA0 /* WebPageProxyCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */; };
+               51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA24431858EE3000EA2811 /* AsyncTask.h */; };
+               51BA24461858F55D00EA2811 /* WebCrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */; };
                51C96118183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C96116183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp */; };
                51C96119183D294700D2002E /* WebIDBServerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C96117183D294700D2002E /* WebIDBServerConnectionMessages.h */; };
                51CBBA0F165219B6005BE8FD /* NetworkResourceLoadParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CBBA0D165219B6005BE8FD /* NetworkResourceLoadParameters.cpp */; };
                515E773118402D510007203F /* UniqueIDBDatabaseIdentifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueIDBDatabaseIdentifier.cpp; sourceTree = "<group>"; };
                515E773218402D510007203F /* UniqueIDBDatabaseIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueIDBDatabaseIdentifier.h; sourceTree = "<group>"; };
                5160BFE013381DF900918999 /* Logging.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Logging.mac.mm; sourceTree = "<group>"; };
+               516311861858446600534647 /* WebCrossThreadCopier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCrossThreadCopier.h; sourceTree = "<group>"; };
                516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessProxyMac.mm; path = mac/NetworkProcessProxyMac.mm; sourceTree = "<group>"; };
+               51654EFB184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueIDBDatabaseBackingStoreSQLite.cpp; sourceTree = "<group>"; };
+               51654EFC184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueIDBDatabaseBackingStoreSQLite.h; sourceTree = "<group>"; };
+               51654EFF184EF34A007DC837 /* UniqueIDBDatabaseBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueIDBDatabaseBackingStore.h; sourceTree = "<group>"; };
                5167EE9E170377BF007681CA /* DiskCacheMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiskCacheMonitor.h; sourceTree = "<group>"; };
                5167EE9F170377BF007681CA /* DiskCacheMonitor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiskCacheMonitor.mm; sourceTree = "<group>"; };
                516A4A5B120A2CCD00C05B7F /* WebError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebError.h; sourceTree = "<group>"; };
                51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EnvironmentUtilities.h; path = unix/EnvironmentUtilities.h; sourceTree = "<group>"; };
                51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebBackForwardListCF.cpp; path = cf/WebBackForwardListCF.cpp; sourceTree = "<group>"; };
                51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPageProxyCF.cpp; path = cf/WebPageProxyCF.cpp; sourceTree = "<group>"; };
+               51BA24431858EE3000EA2811 /* AsyncTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncTask.h; sourceTree = "<group>"; };
+               51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCrossThreadCopier.cpp; sourceTree = "<group>"; };
                51C96115183C95FF00D2002E /* WebIDBServerConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebIDBServerConnection.messages.in; sourceTree = "<group>"; };
                51C96116183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIDBServerConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
                51C96117183D294700D2002E /* WebIDBServerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIDBServerConnectionMessages.h; sourceTree = "<group>"; };
                                A7D792D41767CB0900881CBE /* ActivityAssertion.h */,
                                515E7725183DD6F60007203F /* AsyncRequest.cpp */,
                                515E7726183DD6F60007203F /* AsyncRequest.h */,
+                               51BA24431858EE3000EA2811 /* AsyncTask.h */,
                                4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */,
                                BCF18637167D071E00A1A85A /* CacheModel.cpp */,
                                BC3065F91259344E00E71278 /* CacheModel.h */,
                                510FBB991288C95E00AFFDF4 /* WebContextMenuItemData.h */,
                                939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */,
                                BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */,
+                               51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */,
+                               516311861858446600534647 /* WebCrossThreadCopier.h */,
                                51578B821209ECEF00A37C4A /* WebData.h */,
                                BC575612126E0138006F0F12 /* WebError.cpp */,
                                516A4A5B120A2CCD00C05B7F /* WebError.h */,
                        name = mac;
                        sourceTree = "<group>";
                };
+               51654EF0184EF241007DC837 /* sqlite */ = {
+                       isa = PBXGroup;
+                       children = (
+                               51654EFB184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp */,
+                               51654EFC184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.h */,
+                       );
+                       path = sqlite;
+                       sourceTree = "<group>";
+               };
                517DD5BB180DA7C40081660B /* Databases */ = {
                        isa = PBXGroup;
                        children = (
                51E351F9180F5CF600E53BE9 /* IndexedDB */ = {
                        isa = PBXGroup;
                        children = (
+                               51654EF0184EF241007DC837 /* sqlite */,
                                51D0D42E183B34130097041D /* DatabaseProcessIDBConnection.cpp */,
                                51D0D42F183B34130097041D /* DatabaseProcessIDBConnection.h */,
                                51D0D430183B34130097041D /* DatabaseProcessIDBConnection.messages.in */,
                                515E772D184015800007203F /* UniqueIDBDatabase.cpp */,
                                515E772E184015800007203F /* UniqueIDBDatabase.h */,
+                               51654EFF184EF34A007DC837 /* UniqueIDBDatabaseBackingStore.h */,
                                515E773118402D510007203F /* UniqueIDBDatabaseIdentifier.cpp */,
                                515E773218402D510007203F /* UniqueIDBDatabaseIdentifier.h */,
                        );
                                BC032DA910F437D10058C15A /* Arguments.h in Headers */,
                                BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */,
                                E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
+                               51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */,
                                512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */,
                                1A445B9F184D5FB5004B3414 /* WKContextInjectedBundleClient.h in Headers */,
                                512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */,
                                BC8147A912F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h in Headers */,
                                BCA8C6B011E3C08700812FB7 /* InjectedBundlePageUIClient.h in Headers */,
                                1A9E32891821636900F5D04C /* WKRemoteObjectRegistry.h in Headers */,
+                               51654EFE184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.h in Headers */,
                                BC33E0D112408E8600360F3F /* InjectedBundleRangeHandle.h in Headers */,
                                BC14DF77120B5B7900826C0C /* InjectedBundleScriptWorld.h in Headers */,
                                BCB0B0DE12305A8C00B1341E /* InjectedBundleUserMessageCoders.h in Headers */,
                                1AB474E0184D446A0051B622 /* WKBundlePageEditorClient.h in Headers */,
                                1A2D848B127F6A49001EB962 /* NPIdentifierData.h in Headers */,
                                1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */,
+                               516311871858446600534647 /* WebCrossThreadCopier.h in Headers */,
                                1AB474E2184D44800051B622 /* WKBundlePageFormClient.h in Headers */,
                                1A2D82A5127F4EAB001EB962 /* NPObjectMessageReceiver.h in Headers */,
                                1A2D843A127F65D5001EB962 /* NPObjectMessageReceiverMessages.h in Headers */,
                                BCAC111F12C92C1F00B08EEE /* WebDatabaseManagerProxyClient.h in Headers */,
                                F62A76B912B1B25F0005F1B6 /* WebDatabaseManagerProxyMessages.h in Headers */,
                                1AB7D72C1288CAAD00CFD08C /* WebDownloadClient.h in Headers */,
+                               51654F00184EF34A007DC837 /* UniqueIDBDatabaseBackingStore.h in Headers */,
                                BC032D7B10F4378D0058C15A /* WebDragClient.h in Headers */,
                                BCA0EF9F12332642007D3CFB /* WebEditCommandProxy.h in Headers */,
                                BC032D7D10F4378D0058C15A /* WebEditorClient.h in Headers */,
                                1A44B95716B737AA00B7BBD8 /* StorageNamespaceImpl.cpp in Sources */,
                                1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */,
                                517DD5BE180DA7D30081660B /* DatabaseProcessProxy.cpp in Sources */,
+                               51654EFD184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp in Sources */,
                                296BD85E15019BC30071F424 /* StringUtilities.mm in Sources */,
                                1ZZ417EF12C00D87002BE67B /* TextCheckerCompletion.cpp in Sources */,
                                51E351FF180F5D0F00E53BE9 /* DatabaseProcess.cpp in Sources */,
                                1AC7537B183A9FDB0072CB15 /* PageLoadState.cpp in Sources */,
                                BC407607124FF0270068F20A /* WKType.cpp in Sources */,
                                7CD5EBBE1746B04C000C1C45 /* WKTypeRefWrapper.mm in Sources */,
+                               51BA24461858F55D00EA2811 /* WebCrossThreadCopier.cpp in Sources */,
                                BC407609124FF0270068F20A /* WKURL.cpp in Sources */,
                                BC40761B124FF0370068F20A /* WKURLCF.mm in Sources */,
                                BC40760B124FF0270068F20A /* WKURLRequest.cpp in Sources */,