Changeset 199078 in webkit


Ignore:
Timestamp:
Apr 5, 2016 3:55:33 PM (8 years ago)
Author:
beidson@apple.com
Message:

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

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199076 r199078  
     12016-04-05  Brady Eidson  <beidson@apple.com>
     2
     3        Modern IDB: Get blob URLs/files all the way to the IDB backing store.
     4        https://bugs.webkit.org/show_bug.cgi?id=156248
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (No change in behavior).
     9
     10        * Modules/indexeddb/IDBTransaction.cpp:
     11        (WebCore::IDBTransaction::putOrAddOnServer):
     12
     13        * Modules/indexeddb/IDBValue.cpp:
     14        (WebCore::IDBValue::IDBValue):
     15        (WebCore::IDBValue::isolatedCopy):
     16        * Modules/indexeddb/IDBValue.h:
     17        (WebCore::IDBValue::blobURLs):
     18        (WebCore::IDBValue::blobFilePaths):
     19        (WebCore::IDBValue::encode):
     20        (WebCore::IDBValue::decode):
     21
     22        * Modules/indexeddb/server/IDBBackingStore.h:
     23
     24        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
     25        (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
     26        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
     27
     28        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     29        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
     30        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
     31
     32        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     33        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
     34
     35        * bindings/js/SerializedScriptValue.cpp:
     36        (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
     37
    1382016-03-19  Filip Pizlo  <fpizlo@apple.com>
    239
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r199072 r199078  
    878878    RefPtr<IDBTransaction> protector(this);
    879879    RefPtr<IDBClient::TransactionOperation> operationRef(&operation);
    880     value->writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue&) {
    881         // FIXME: Send the passed in IDBValue to the IDB server instead of the SerializedScriptValue.
    882         serverConnection().putOrAdd(*operationRef, key.get(), *value, overwriteMode);
     880    value->writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue& idbValue) {
     881        serverConnection().putOrAdd(*operationRef, key.get(), idbValue, overwriteMode);
    883882    });
    884883}
  • trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp

    r199072 r199078  
    4242}
    4343
     44IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)
     45    : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data()))
     46    , m_blobURLs(blobURLs)
     47    , m_blobFilePaths(blobFilePaths)
     48{
     49}
     50
    4451IDBValue IDBValue::isolatedCopy() const
    4552{
    4653    IDBValue result;
    4754    result.m_data = m_data;
     55
     56    result.m_blobURLs.reserveInitialCapacity(m_blobURLs.size());
     57    for (auto& url : m_blobURLs)
     58        result.m_blobURLs.uncheckedAppend(url.isolatedCopy());
     59
     60    result.m_blobFilePaths.reserveInitialCapacity(m_blobFilePaths.size());
     61    for (auto& path : m_blobFilePaths)
     62        result.m_blobFilePaths.uncheckedAppend(path.isolatedCopy());
     63
    4864    return result;
    4965}
  • trunk/Source/WebCore/Modules/indexeddb/IDBValue.h

    r199072 r199078  
    2828
    2929#include "ThreadSafeDataBuffer.h"
     30#include <wtf/text/WTFString.h>
    3031
    3132namespace WebCore {
     
    3738    WEBCORE_EXPORT IDBValue();
    3839    IDBValue(const SerializedScriptValue&);
     40    IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);
    3941
    4042    IDBValue isolatedCopy() const;
    4143
    4244    const ThreadSafeDataBuffer& data() const { return m_data; }
     45    const Vector<String>& blobURLs() const { return m_blobURLs; }
     46    const Vector<String>& blobFilePaths() const { return m_blobFilePaths; }
    4347
    4448    template<class Encoder> void encode(Encoder&) const;
     
    4751private:
    4852    ThreadSafeDataBuffer m_data;
     53    Vector<String> m_blobURLs;
     54    Vector<String> m_blobFilePaths;
    4955};
    5056
     
    5460{
    5561    encoder << m_data;
     62    encoder << m_blobURLs;
     63    encoder << m_blobFilePaths;
    5664}
    5765
     
    6270        return false;
    6371
     72    if (!decoder.decode(result.m_blobURLs))
     73        return false;
     74
     75    if (!decoder.decode(result.m_blobFilePaths))
     76        return false;
     77
    6478    return true;
    6579}
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h

    r197474 r199078  
    6868    virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
    6969    virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
    70     virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
     70    virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) = 0;
    7171    virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
    7272    virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

    r197474 r199078  
    268268}
    269269
    270 IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
     270IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>&, const Vector<String>&)
    271271{
    272272    LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h

    r197566 r199078  
    6060    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    6161    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
    62     IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) final;
     62    IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) final;
    6363    IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) final;
    6464    IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r198177 r199078  
    12831283}
    12841284
    1285 IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
     1285IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value, const Vector<String>&, const Vector<String>&)
    12861286{
    12871287    LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h

    r197566 r199078  
    6464    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    6565    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
    66     IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value) final;
     66    IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths) final;
    6767    IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) final;
    6868    IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r199072 r199078  
    796796    }
    797797
    798     error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue.data());
     798    error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue.data(), originalRecordValue.blobURLs(), originalRecordValue.blobFilePaths());
    799799    if (!error.isNull()) {
    800800        m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r199059 r199078  
    27522752{
    27532753    ASSERT(isMainThread());
    2754 
    2755     if (m_blobURLs.isEmpty()) {
    2756         completionHandler({ });
    2757         return;
    2758     }
     2754    ASSERT(hasBlobURLs());
    27592755
    27602756    RefPtr<SerializedScriptValue> protector(this);
    2761     blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector<String>&) {
    2762         // FIXME: Return an IDBValue that contains both the SerializedScriptValue data and all blob file data.
    2763         completionHandler({ });
     2757    blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector<String>& blobFilePaths) {
     2758        ASSERT(isMainThread());
     2759
     2760        if (blobFilePaths.isEmpty()) {
     2761            // We should have successfully written blobs to temporary files.
     2762            // If we failed, then we can't successfully store this record.
     2763            completionHandler({ });
     2764            return;
     2765        }
     2766
     2767        ASSERT(m_blobURLs.size() == blobFilePaths.size());
     2768       
     2769        completionHandler({ *this, m_blobURLs, blobFilePaths });
    27642770    });
    27652771}
Note: See TracChangeset for help on using the changeset viewer.