Diff
Modified: trunk/Source/WebCore/ChangeLog (199249 => 199250)
--- trunk/Source/WebCore/ChangeLog 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/ChangeLog 2016-04-08 22:01:10 UTC (rev 199250)
@@ -1,5 +1,41 @@
2016-04-08 Brady Eidson <beid...@apple.com>
+ Modern IDB: Use more IDBValue and IDBGetResult in IDBBackingStore.
+ https://bugs.webkit.org/show_bug.cgi?id=156418
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Refactor, no change in behavior).
+
+ * Modules/indexeddb/IDBValue.cpp:
+ (WebCore::IDBValue::IDBValue):
+ * Modules/indexeddb/IDBValue.h:
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
+ (WebCore::IDBServer::MemoryIDBBackingStore::getRecord):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryObjectStore.cpp:
+ (WebCore::IDBServer::MemoryObjectStore::addRecord):
+ * Modules/indexeddb/server/MemoryObjectStore.h:
+
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetRecord):
+
+2016-04-08 Brady Eidson <beid...@apple.com>
+
Modern IDB: Make IDBGetResult contain an IDBValue instead of a buffer, and remove unused methods.
https://bugs.webkit.org/show_bug.cgi?id=156416
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -54,6 +54,13 @@
{
}
+IDBValue::IDBValue(const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
+ : m_data(value)
+ , m_blobURLs(blobURLs)
+ , m_blobFilePaths(blobFilePaths)
+{
+}
+
IDBValue IDBValue::isolatedCopy() const
{
IDBValue result;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBValue.h (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.h 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.h 2016-04-08 22:01:10 UTC (rev 199250)
@@ -39,6 +39,7 @@
IDBValue(const SerializedScriptValue&);
IDBValue(const ThreadSafeDataBuffer&);
IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
+ IDBValue(const ThreadSafeDataBuffer&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
IDBValue isolatedCopy() const;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2016-04-08 22:01:10 UTC (rev 199250)
@@ -40,6 +40,7 @@
class IDBObjectStoreInfo;
class IDBResourceIdentifier;
class IDBTransactionInfo;
+class IDBValue;
class ThreadSafeDataBuffer;
struct IDBKeyRangeData;
@@ -74,8 +75,8 @@
virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;
virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
- virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) = 0;
- virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) = 0;
+ virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -29,6 +29,7 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBKeyRangeData.h"
+#include "IDBValue.h"
#include "IndexedDB.h"
#include "Logging.h"
#include "MemoryIDBBackingStore.h"
@@ -230,7 +231,7 @@
for (auto entry : *keyValueMap) {
objectStore->deleteRecord(entry.key);
- objectStore->addRecord(*this, entry.key, entry.value);
+ objectStore->addRecord(*this, entry.key, { entry.value });
}
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -267,7 +267,7 @@
return IDBError();
}
-IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>&, const Vector<String>&)
+IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
{
LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
@@ -284,7 +284,7 @@
return objectStore->addRecord(*transaction, keyData, value);
}
-IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, ThreadSafeDataBuffer& outValue)
+IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IDBGetResult& outValue)
{
LOG(IndexedDB, "MemoryIDBBackingStore::getRecord");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2016-04-08 22:01:10 UTC (rev 199250)
@@ -59,8 +59,8 @@
IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
- IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) final;
- IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) final;
+ IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
+ IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetResult& outValue) final;
IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -32,6 +32,7 @@
#include "IDBDatabaseException.h"
#include "IDBError.h"
#include "IDBKeyRangeData.h"
+#include "IDBValue.h"
#include "IndexKey.h"
#include "Logging.h"
#include "MemoryBackingStoreTransaction.h"
@@ -247,7 +248,7 @@
}
}
-IDBError MemoryObjectStore::addRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+IDBError MemoryObjectStore::addRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const IDBValue& value)
{
LOG(IndexedDB, "MemoryObjectStore::addRecord");
@@ -262,13 +263,13 @@
m_orderedKeys = std::make_unique<std::set<IDBKeyData>>();
}
- auto mapResult = m_keyValueStore->set(keyData, value);
+ auto mapResult = m_keyValueStore->set(keyData, value.data());
ASSERT(mapResult.isNewEntry);
auto listResult = m_orderedKeys->insert(keyData);
ASSERT(listResult.second);
// If there was an error indexing this addition, then revert it.
- auto error = updateIndexesForPutRecord(keyData, value);
+ auto error = updateIndexesForPutRecord(keyData, value.data());
if (!error.isNull()) {
m_keyValueStore->remove(mapResult.iterator);
m_orderedKeys->erase(listResult.first);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2016-04-08 22:01:10 UTC (rev 199250)
@@ -73,7 +73,7 @@
bool containsRecord(const IDBKeyData&);
void deleteRecord(const IDBKeyData&);
void deleteRange(const IDBKeyRangeData&);
- IDBError addRecord(MemoryBackingStoreTransaction&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
+ IDBError addRecord(MemoryBackingStoreTransaction&, const IDBKeyData&, const IDBValue&);
uint64_t currentKeyGeneratorValue() const { return m_keyGeneratorValue; }
void setKeyGeneratorValue(uint64_t value) { m_keyGeneratorValue = value; }
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -36,6 +36,7 @@
#include "IDBObjectStoreInfo.h"
#include "IDBSerialization.h"
#include "IDBTransactionInfo.h"
+#include "IDBValue.h"
#include "IndexKey.h"
#include "Logging.h"
#include "SQLiteDatabase.h"
@@ -1412,14 +1413,14 @@
return error;
}
-IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFiles)
+IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
ASSERT(m_sqliteDB);
ASSERT(m_sqliteDB->isOpen());
- ASSERT(value.data());
- ASSERT(blobURLs.size() == blobFiles.size());
+ ASSERT(value.data().data());
+ ASSERT(value.blobURLs().size() == value.blobFilePaths().size());
auto* transaction = m_transactions.get(transactionIdentifier);
if (!transaction || !transaction->inProgress()) {
@@ -1443,7 +1444,7 @@
if (sql.prepare() != SQLITE_OK
|| sql.bindInt64(1, objectStoreInfo.identifier()) != SQLITE_OK
|| sql.bindBlob(2, keyBuffer->data(), keyBuffer->size()) != SQLITE_OK
- || sql.bindBlob(3, value.data()->data(), value.data()->size()) != SQLITE_OK
+ || sql.bindBlob(3, value.data().data()->data(), value.data().data()->size()) != SQLITE_OK
|| sql.step() != SQLITE_DONE) {
LOG_ERROR("Could not put record for object store %" PRIi64 " in Records table (%i) - %s", objectStoreInfo.identifier(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to store record in object store") };
@@ -1452,7 +1453,7 @@
recordID = m_sqliteDB->lastInsertRowID();
}
- auto error = updateAllIndexesForAddRecord(objectStoreInfo, keyData, value);
+ auto error = updateAllIndexesForAddRecord(objectStoreInfo, keyData, value.data());
if (!error.isNull()) {
SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);"));
@@ -1465,6 +1466,8 @@
}
}
+ const Vector<String>& blobURLs = value.blobURLs();
+ const Vector<String>& blobFiles = value.blobFilePaths();
for (size_t i = 0; i < blobURLs.size(); ++i) {
auto& url = ""
{
@@ -1519,7 +1522,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, ThreadSafeDataBuffer& resultValue)
+IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, IDBGetResult& resultValue)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::getRecord - key range %s, object store %" PRIu64, keyRange.loggingString().utf8().data(), objectStoreID);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-08 22:01:10 UTC (rev 199250)
@@ -63,8 +63,8 @@
IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
- IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) final;
- IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) final;
+ IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
+ IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetResult& outValue) final;
IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (199249 => 199250)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-08 21:21:25 UTC (rev 199249)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-08 22:01:10 UTC (rev 199250)
@@ -795,7 +795,11 @@
return;
}
- error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue.data(), originalRecordValue.blobURLs(), originalRecordValue.blobFilePaths());
+ if (injectedRecordValue.data())
+ error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, { injectedRecordValue, originalRecordValue.blobURLs(), originalRecordValue.blobFilePaths() });
+ else
+ error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue);
+
if (!error.isNull()) {
m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
return;
@@ -836,10 +840,10 @@
ASSERT(m_backingStore);
- ThreadSafeDataBuffer valueData;
- IDBError error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, valueData);
+ IDBGetResult result;
+ IDBError error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, result);
- m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, valueData));
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, result));
}
void UniqueIDBDatabase::performGetIndexRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType recordType, const IDBKeyRangeData& range)