Diff
Modified: trunk/Source/WebCore/ChangeLog (199077 => 199078)
--- trunk/Source/WebCore/ChangeLog 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/ChangeLog 2016-04-05 22:55:33 UTC (rev 199078)
@@ -1,3 +1,40 @@
+2016-04-05 Brady Eidson <[email protected]>
+
+ Modern IDB: Get blob URLs/files all the way to the IDB backing store.
+ https://bugs.webkit.org/show_bug.cgi?id=156248
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No change in behavior).
+
+ * Modules/indexeddb/IDBTransaction.cpp:
+ (WebCore::IDBTransaction::putOrAddOnServer):
+
+ * Modules/indexeddb/IDBValue.cpp:
+ (WebCore::IDBValue::IDBValue):
+ (WebCore::IDBValue::isolatedCopy):
+ * Modules/indexeddb/IDBValue.h:
+ (WebCore::IDBValue::blobURLs):
+ (WebCore::IDBValue::blobFilePaths):
+ (WebCore::IDBValue::encode):
+ (WebCore::IDBValue::decode):
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
+
2016-03-19 Filip Pizlo <[email protected]>
JSC should use a shadow stack version of CHICKEN so that debuggers have the option of retrieving tail-deleted frames
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -877,9 +877,8 @@
RefPtr<IDBTransaction> protector(this);
RefPtr<IDBClient::TransactionOperation> operationRef(&operation);
- value->writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue&) {
- // FIXME: Send the passed in IDBValue to the IDB server instead of the SerializedScriptValue.
- serverConnection().putOrAdd(*operationRef, key.get(), *value, overwriteMode);
+ value->writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue& idbValue) {
+ serverConnection().putOrAdd(*operationRef, key.get(), idbValue, overwriteMode);
});
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -41,10 +41,26 @@
{
}
+IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
+ : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data()))
+ , m_blobURLs(blobURLs)
+ , m_blobFilePaths(blobFilePaths)
+{
+}
+
IDBValue IDBValue::isolatedCopy() const
{
IDBValue result;
result.m_data = m_data;
+
+ result.m_blobURLs.reserveInitialCapacity(m_blobURLs.size());
+ for (auto& url : m_blobURLs)
+ result.m_blobURLs.uncheckedAppend(url.isolatedCopy());
+
+ result.m_blobFilePaths.reserveInitialCapacity(m_blobFilePaths.size());
+ for (auto& path : m_blobFilePaths)
+ result.m_blobFilePaths.uncheckedAppend(path.isolatedCopy());
+
return result;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBValue.h (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.h 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.h 2016-04-05 22:55:33 UTC (rev 199078)
@@ -27,6 +27,7 @@
#if ENABLE(INDEXED_DATABASE)
#include "ThreadSafeDataBuffer.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -36,16 +37,21 @@
public:
WEBCORE_EXPORT IDBValue();
IDBValue(const SerializedScriptValue&);
+ IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
IDBValue isolatedCopy() const;
const ThreadSafeDataBuffer& data() const { return m_data; }
+ const Vector<String>& blobURLs() const { return m_blobURLs; }
+ const Vector<String>& blobFilePaths() const { return m_blobFilePaths; }
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static bool decode(Decoder&, IDBValue&);
private:
ThreadSafeDataBuffer m_data;
+ Vector<String> m_blobURLs;
+ Vector<String> m_blobFilePaths;
};
@@ -53,6 +59,8 @@
void IDBValue::encode(Encoder& encoder) const
{
encoder << m_data;
+ encoder << m_blobURLs;
+ encoder << m_blobFilePaths;
}
template<class Decoder>
@@ -61,6 +69,12 @@
if (!decoder.decode(result.m_data))
return false;
+ if (!decoder.decode(result.m_blobURLs))
+ return false;
+
+ if (!decoder.decode(result.m_blobFilePaths))
+ return false;
+
return true;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2016-04-05 22:55:33 UTC (rev 199078)
@@ -67,7 +67,7 @@
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) = 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 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;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -267,7 +267,7 @@
return IDBError();
}
-IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>&, const Vector<String>&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2016-04-05 22:55:33 UTC (rev 199078)
@@ -59,7 +59,7 @@
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) 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 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;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -1282,7 +1282,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>&, const Vector<String>&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-05 22:55:33 UTC (rev 199078)
@@ -63,7 +63,7 @@
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) 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 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;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (199077 => 199078)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -795,7 +795,7 @@
return;
}
- error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue.data());
+ error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue.data(), originalRecordValue.blobURLs(), originalRecordValue.blobFilePaths());
if (!error.isNull()) {
m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
return;
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (199077 => 199078)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-04-05 22:32:03 UTC (rev 199077)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-04-05 22:55:33 UTC (rev 199078)
@@ -2751,16 +2751,22 @@
void SerializedScriptValue::writeBlobsToDiskForIndexedDB(std::function<void (const IDBValue&)> completionHandler)
{
ASSERT(isMainThread());
+ ASSERT(hasBlobURLs());
- if (m_blobURLs.isEmpty()) {
- completionHandler({ });
- return;
- }
+ RefPtr<SerializedScriptValue> protector(this);
+ blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector<String>& blobFilePaths) {
+ ASSERT(isMainThread());
- RefPtr<SerializedScriptValue> protector(this);
- blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector<String>&) {
- // FIXME: Return an IDBValue that contains both the SerializedScriptValue data and all blob file data.
- completionHandler({ });
+ if (blobFilePaths.isEmpty()) {
+ // We should have successfully written blobs to temporary files.
+ // If we failed, then we can't successfully store this record.
+ completionHandler({ });
+ return;
+ }
+
+ ASSERT(m_blobURLs.size() == blobFilePaths.size());
+
+ completionHandler({ *this, m_blobURLs, blobFilePaths });
});
}
#endif