Changeset 238632 in webkit
- Timestamp:
- Nov 28, 2018, 1:11:21 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238629 r238632 1 2018-11-28 Alex Christensen <achristensen@webkit.org> 2 3 Add SessionIDs wherever BlobURLs are used in SerializedScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=192062 5 6 Reviewed by Dean Jackson. 7 8 Just adding infrastructure for fixing "the blob bug" 9 10 * Modules/indexeddb/IDBDatabaseIdentifier.cpp: 11 (WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier): 12 (WebCore::IDBDatabaseIdentifier::isolatedCopy const): 13 * Modules/indexeddb/IDBDatabaseIdentifier.h: 14 (WebCore::IDBDatabaseIdentifier::hash const): 15 (WebCore::IDBDatabaseIdentifier::sessionID const): 16 (WebCore::IDBDatabaseIdentifier::encode const): 17 (WebCore::IDBDatabaseIdentifier::decode): 18 * Modules/indexeddb/IDBFactory.cpp: 19 (WebCore::IDBFactory::openInternal): 20 (WebCore::IDBFactory::deleteDatabase): 21 * Modules/indexeddb/IDBTransaction.cpp: 22 (WebCore::IDBTransaction::putOrAddOnServer): 23 * Modules/indexeddb/IDBValue.cpp: 24 (WebCore::IDBValue::IDBValue): 25 (WebCore::IDBValue::setAsIsolatedCopy): 26 * Modules/indexeddb/IDBValue.h: 27 (WebCore::IDBValue::sessionID const): 28 (WebCore::IDBValue::encode const): 29 (WebCore::IDBValue::decode): 30 * Modules/indexeddb/server/MemoryIndexCursor.cpp: 31 (WebCore::IDBServer::MemoryIndexCursor::currentData): 32 * Modules/indexeddb/server/MemoryObjectStoreCursor.cpp: 33 (WebCore::IDBServer::MemoryObjectStoreCursor::currentData): 34 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 35 (WebCore::IDBServer::SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord): 36 (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord): 37 (WebCore::IDBServer::SQLiteIDBBackingStore::getAllObjectStoreRecords): 38 (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey): 39 * Modules/indexeddb/server/SQLiteIDBBackingStore.h: 40 * Modules/indexeddb/server/SQLiteIDBCursor.cpp: 41 (WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord): 42 * Modules/indexeddb/server/UniqueIDBDatabase.cpp: 43 (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd): 44 * bindings/js/IDBBindingUtilities.cpp: 45 (WebCore::deserializeIDBValueToJSValue): 46 * bindings/js/SerializedScriptValue.cpp: 47 (WebCore::CloneSerializer::serialize): 48 (WebCore::CloneSerializer::CloneSerializer): 49 (WebCore::CloneSerializer::dumpIfTerminal): 50 (WebCore::CloneDeserializer::deserialize): 51 (WebCore::CloneDeserializer::CloneDeserializer): 52 (WebCore::SerializedScriptValue::SerializedScriptValue): 53 (WebCore::SerializedScriptValue::create): 54 (WebCore::SerializedScriptValue::deserialize): 55 (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB): 56 (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDBSynchronously): 57 * bindings/js/SerializedScriptValue.h: 58 (WebCore::SerializedScriptValue::sessionID const): 59 1 60 2018-11-28 Justin Fan <justin_fan@apple.com> 2 61 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp
r224371 r238632 36 36 namespace WebCore { 37 37 38 IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)38 IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID& sessionID, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin) 39 39 : m_databaseName(databaseName) 40 , m_sessionID(sessionID) 40 41 , m_openingOrigin(WTFMove(openingOrigin)) 41 42 , m_mainFrameOrigin(WTFMove(mainFrameOrigin)) … … 51 52 52 53 identifier.m_databaseName = m_databaseName.isolatedCopy(); 54 identifier.m_sessionID = m_sessionID.isolatedCopy(); 53 55 identifier.m_openingOrigin = m_openingOrigin.isolatedCopy(); 54 56 identifier.m_mainFrameOrigin = m_mainFrameOrigin.isolatedCopy(); -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h
r222233 r238632 29 29 30 30 #include "SecurityOriginData.h" 31 #include <pal/SessionID.h> 31 32 #include <wtf/text/StringHash.h> 32 33 #include <wtf/text/WTFString.h> … … 44 45 } 45 46 46 WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);47 WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID&, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin); 47 48 48 49 IDBDatabaseIdentifier isolatedCopy() const; … … 56 57 { 57 58 unsigned nameHash = StringHash::hash(m_databaseName); 59 unsigned sessionIDHash = WTF::SessionIDHash::hash(m_sessionID); 58 60 unsigned openingProtocolHash = StringHash::hash(m_openingOrigin.protocol); 59 61 unsigned openingHostHash = StringHash::hash(m_openingOrigin.host); … … 61 63 unsigned mainFrameHostHash = StringHash::hash(m_mainFrameOrigin.host); 62 64 63 unsigned hashCodes[ 7] = { nameHash, openingProtocolHash, openingHostHash, m_openingOrigin.port.value_or(0), mainFrameProtocolHash, mainFrameHostHash, m_mainFrameOrigin.port.value_or(0) };65 unsigned hashCodes[8] = { nameHash, sessionIDHash, openingProtocolHash, openingHostHash, m_openingOrigin.port.value_or(0), mainFrameProtocolHash, mainFrameHostHash, m_mainFrameOrigin.port.value_or(0) }; 64 66 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 65 67 } … … 84 86 85 87 const String& databaseName() const { return m_databaseName; } 88 const PAL::SessionID& sessionID() const { return m_sessionID; } 86 89 87 90 String databaseDirectoryRelativeToRoot(const String& rootDirectory) const; … … 102 105 private: 103 106 String m_databaseName; 107 PAL::SessionID m_sessionID; 104 108 SecurityOriginData m_openingOrigin; 105 109 SecurityOriginData m_mainFrameOrigin; … … 121 125 void IDBDatabaseIdentifier::encode(Encoder& encoder) const 122 126 { 123 encoder << m_databaseName << m_ openingOrigin << m_mainFrameOrigin;127 encoder << m_databaseName << m_sessionID << m_openingOrigin << m_mainFrameOrigin; 124 128 } 125 129 … … 132 136 return std::nullopt; 133 137 138 std::optional<PAL::SessionID> sessionID; 139 decoder >> sessionID; 140 if (!sessionID) 141 return std::nullopt; 142 134 143 std::optional<SecurityOriginData> openingOrigin; 135 144 decoder >> openingOrigin; … … 144 153 IDBDatabaseIdentifier identifier; 145 154 identifier.m_databaseName = WTFMove(*databaseName); // FIXME: When decoding from IPC, databaseName can be null, and the non-empty constructor asserts that this is not the case. 155 identifier.m_sessionID = WTFMove(*sessionID); 146 156 identifier.m_openingOrigin = WTFMove(*openingOrigin); 147 157 identifier.m_mainFrameOrigin = WTFMove(*mainFrameOrigin); -
trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp
r233122 r238632 92 92 93 93 ASSERT(context.securityOrigin()); 94 IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });94 IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() }); 95 95 if (!databaseIdentifier.isValid()) 96 96 return Exception { TypeError, "IDBFactory.open() called with an invalid security origin"_s }; … … 112 112 113 113 ASSERT(context.securityOrigin()); 114 IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });114 IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() }); 115 115 if (!databaseIdentifier.isValid()) 116 116 return Exception { TypeError, "IDBFactory.deleteDatabase() called with an invalid security origin"_s }; -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r238088 r238632 55 55 #include "SerializedScriptValue.h" 56 56 #include "TransactionOperation.h" 57 57 #include <wtf/CompletionHandler.h> 58 58 59 59 namespace WebCore { … … 1224 1224 operation.setNextRequestCanGoToServer(false); 1225 1225 1226 value->writeBlobsToDiskForIndexedDB([protectedThis = makeRef(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode]( const IDBValue& idbValue) mutable {1226 value->writeBlobsToDiskForIndexedDB([protectedThis = makeRef(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode](IDBValue&& idbValue) mutable { 1227 1227 ASSERT(&originThread() == &Thread::current()); 1228 1228 ASSERT(isMainThread()); -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp
r221431 r238632 41 41 : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data())) 42 42 , m_blobURLs(scriptValue.blobURLsIsolatedCopy()) 43 , m_sessionID(scriptValue.sessionID()) 43 44 { 44 45 } … … 49 50 } 50 51 51 IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)52 IDBValue::IDBValue(const SerializedScriptValue& scriptValue, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, const Vector<String>& blobFilePaths) 52 53 : m_data(ThreadSafeDataBuffer::copyVector(scriptValue.data())) 53 54 , m_blobURLs(blobURLs) 55 , m_sessionID(sessionID) 54 56 , m_blobFilePaths(blobFilePaths) 55 57 { … … 57 59 } 58 60 59 IDBValue::IDBValue(const ThreadSafeDataBuffer& value, Vector<String>&& blobURLs, Vector<String>&& blobFilePaths)61 IDBValue::IDBValue(const ThreadSafeDataBuffer& value, Vector<String>&& blobURLs, const PAL::SessionID& sessionID, Vector<String>&& blobFilePaths) 60 62 : m_data(value) 61 63 , m_blobURLs(WTFMove(blobURLs)) 64 , m_sessionID(sessionID) 62 65 , m_blobFilePaths(WTFMove(blobFilePaths)) 63 66 { 64 67 } 65 68 66 IDBValue::IDBValue(const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths)69 IDBValue::IDBValue(const ThreadSafeDataBuffer& value, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, const Vector<String>& blobFilePaths) 67 70 : m_data(value) 68 71 , m_blobURLs(blobURLs) 72 , m_sessionID(sessionID) 69 73 , m_blobFilePaths(blobFilePaths) 70 74 { … … 77 81 m_data = other.m_data; 78 82 m_blobURLs = crossThreadCopy(other.m_blobURLs); 83 m_sessionID = other.m_sessionID; 79 84 m_blobFilePaths = crossThreadCopy(other.m_blobFilePaths); 80 85 } -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.h
r222233 r238632 25 25 26 26 #pragma once 27 27 28 #if ENABLE(INDEXED_DATABASE) 28 29 29 30 #include "ThreadSafeDataBuffer.h" 31 #include <pal/SessionID.h> 30 32 #include <wtf/text/WTFString.h> 31 33 … … 39 41 IDBValue(const SerializedScriptValue&); 40 42 IDBValue(const ThreadSafeDataBuffer&); 41 IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);42 IDBValue(const ThreadSafeDataBuffer&, Vector<String>&& blobURLs, Vector<String>&& blobFilePaths);43 IDBValue(const ThreadSafeDataBuffer&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths);43 IDBValue(const SerializedScriptValue&, const Vector<String>& blobURLs, const PAL::SessionID&, const Vector<String>& blobFilePaths); 44 IDBValue(const ThreadSafeDataBuffer&, Vector<String>&& blobURLs, const PAL::SessionID&, Vector<String>&& blobFilePaths); 45 IDBValue(const ThreadSafeDataBuffer&, const Vector<String>& blobURLs, const PAL::SessionID&, const Vector<String>& blobFilePaths); 44 46 45 47 void setAsIsolatedCopy(const IDBValue&); … … 48 50 const ThreadSafeDataBuffer& data() const { return m_data; } 49 51 const Vector<String>& blobURLs() const { return m_blobURLs; } 52 const PAL::SessionID& sessionID() const { return m_sessionID; } 50 53 const Vector<String>& blobFilePaths() const { return m_blobFilePaths; } 51 54 … … 56 59 ThreadSafeDataBuffer m_data; 57 60 Vector<String> m_blobURLs; 61 PAL::SessionID m_sessionID; 58 62 Vector<String> m_blobFilePaths; 59 63 }; … … 65 69 encoder << m_data; 66 70 encoder << m_blobURLs; 71 encoder << m_sessionID; 67 72 encoder << m_blobFilePaths; 68 73 } … … 78 83 return std::nullopt; 79 84 85 if (!decoder.decode(result.m_sessionID)) 86 return std::nullopt; 87 80 88 if (!decoder.decode(result.m_blobFilePaths)) 81 89 return std::nullopt; -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp
r223728 r238632 75 75 getResult = { m_currentKey, m_currentPrimaryKey }; 76 76 else { 77 IDBValue value = { m_index.objectStore().valueForKey(m_currentPrimaryKey), { }, { } };77 IDBValue value = { m_index.objectStore().valueForKey(m_currentPrimaryKey), { }, { }, { } }; 78 78 getResult = { m_currentKey, m_currentPrimaryKey, WTFMove(value) }; 79 79 } -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp
r219383 r238632 194 194 data = { m_currentPositionKey, m_currentPositionKey }; 195 195 else { 196 IDBValue value = { m_objectStore.valueForKeyRange(m_currentPositionKey), { }, { } };196 IDBValue value = { m_objectStore.valueForKeyRange(m_currentPositionKey), { }, { }, { } }; 197 197 data = { m_currentPositionKey, m_currentPositionKey, WTFMove(value) }; 198 198 } -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r238112 r238632 1867 1867 } 1868 1868 1869 IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths)1869 IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID& sessionID, Vector<String>& blobFilePaths) 1870 1870 { 1871 1871 ASSERT(objectStoreRecord); … … 1917 1917 blobFilePaths.append(FileSystem::pathByAppendingComponent(databaseDirectory, fileName)); 1918 1918 } 1919 sessionID = m_identifier.sessionID(); 1919 1920 1920 1921 return IDBError { }; … … 2042 2043 ASSERT(recordID); 2043 2044 Vector<String> blobURLs, blobFilePaths; 2044 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths); 2045 PAL::SessionID sessionID; 2046 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths); 2045 2047 ASSERT(blobURLs.size() == blobFilePaths.size()); 2046 2048 … … 2048 2050 return error; 2049 2051 2050 resultValue = { { resultBuffer, WTFMove(blobURLs), WTFMove(blobFilePaths) } };2052 resultValue = { { resultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) } }; 2051 2053 return IDBError { }; 2052 2054 } … … 2152 2154 ASSERT(recordID); 2153 2155 Vector<String> blobURLs, blobFilePaths; 2154 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths); 2156 PAL::SessionID sessionID; 2157 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths); 2155 2158 ASSERT(blobURLs.size() == blobFilePaths.size()); 2156 2159 … … 2158 2161 return error; 2159 2162 2160 result.addValue({ resultBuffer, WTFMove(blobURLs), WTFMove(blobFilePaths) });2163 result.addValue({ resultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }); 2161 2164 } else { 2162 2165 Vector<uint8_t> keyData; … … 2322 2325 int64_t recordID = sql->getColumnInt64(2); 2323 2326 Vector<String> blobURLs, blobFilePaths; 2324 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths); 2327 PAL::SessionID sessionID; 2328 auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths); 2325 2329 ASSERT(blobURLs.size() == blobFilePaths.size()); 2326 2330 … … 2328 2332 return error; 2329 2333 2330 getResult = { { ThreadSafeDataBuffer::create(WTFMove(keyVector)), WTFMove(blobURLs), WTFMove(blobFilePaths) }, objectStoreKey };2334 getResult = { { ThreadSafeDataBuffer::create(WTFMove(keyVector)), WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreKey }; 2331 2335 return IDBError { }; 2332 2336 } -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
r237700 r238632 92 92 IDBBackingStoreTemporaryFileHandler& temporaryFileHandler() const { return m_temporaryFileHandler; } 93 93 94 IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);94 IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID&, Vector<String>& blobFilePaths); 95 95 96 96 static String databaseNameFromEncodedFilename(const String&); -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
r237590 r238632 457 457 458 458 Vector<String> blobURLs, blobFilePaths; 459 auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, blobFilePaths); 459 PAL::SessionID sessionID; 460 auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, sessionID, blobFilePaths); 460 461 if (!error.isNull()) { 461 462 LOG_ERROR("Unable to fetch blob records from database while advancing cursor"); … … 465 466 466 467 if (m_cursorType == IndexedDB::CursorType::KeyAndValue) 467 record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, blobFilePaths);468 record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, sessionID, blobFilePaths); 468 469 } else { 469 470 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), record.record.primaryKey)) { -
trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
r237969 r238632 1040 1040 1041 1041 if (injectedRecordValue.data()) 1042 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, { injectedRecordValue, originalRecordValue.blobURLs(), originalRecordValue. blobFilePaths() });1042 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, { injectedRecordValue, originalRecordValue.blobURLs(), originalRecordValue.sessionID(), originalRecordValue.blobFilePaths() }); 1043 1043 else 1044 1044 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue); -
trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp
r236007 r238632 344 344 state.vm().apiLock().lock(); 345 345 Vector<RefPtr<MessagePort>> messagePorts; 346 JSValue result = serializedValue->deserialize(state, &globalObject, messagePorts, value.blobURLs(), value. blobFilePaths(), SerializationErrorMode::NonThrowing);346 JSValue result = serializedValue->deserialize(state, &globalObject, messagePorts, value.blobURLs(), value.sessionID(), value.blobFilePaths(), SerializationErrorMode::NonThrowing); 347 347 state.vm().apiLock().unlock(); 348 348 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r237779 r238632 548 548 WasmModuleArray& wasmModules, 549 549 #endif 550 Vector<String>& blobURLs, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)550 Vector<String>& blobURLs, const PAL::SessionID& sessionID, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers) 551 551 { 552 552 CloneSerializer serializer(exec, messagePorts, arrayBuffers, imageBitmaps, … … 554 554 wasmModules, 555 555 #endif 556 blobURLs, out, context, sharedBuffers);556 blobURLs, sessionID, out, context, sharedBuffers); 557 557 return serializer.serialize(value); 558 558 } … … 581 581 WasmModuleArray& wasmModules, 582 582 #endif 583 Vector<String>& blobURLs, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)583 Vector<String>& blobURLs, const PAL::SessionID& sessionID, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers) 584 584 : CloneBase(exec) 585 585 , m_buffer(out) 586 586 , m_blobURLs(blobURLs) 587 , m_sessionID(sessionID) 587 588 , m_emptyIdentifier(Identifier::fromString(exec, emptyString())) 588 589 , m_context(context) … … 1044 1045 Vector<uint8_t> serializedKey; 1045 1046 Vector<String> dummyBlobURLs; 1047 PAL::SessionID dummySessionID; 1046 1048 Vector<RefPtr<MessagePort>> dummyMessagePorts; 1047 1049 Vector<RefPtr<JSC::ArrayBuffer>> dummyArrayBuffers; … … 1054 1056 dummyModules, 1055 1057 #endif 1056 dummyBlobURLs, serializedKey, SerializationContext::Default, dummySharedBuffers);1058 dummyBlobURLs, dummySessionID, serializedKey, SerializationContext::Default, dummySharedBuffers); 1057 1059 rawKeySerializer.write(key); 1058 1060 Vector<uint8_t> wrappedKey; … … 1453 1455 Vector<uint8_t>& m_buffer; 1454 1456 Vector<String>& m_blobURLs; 1457 PAL::SessionID m_sessionID; 1455 1458 ObjectPool m_objectPool; 1456 1459 ObjectPool m_transferredMessagePorts; … … 1736 1739 } 1737 1740 1738 static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers1741 static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers 1739 1742 #if ENABLE(WEBASSEMBLY) 1740 1743 , WasmModuleArray* wasmModules … … 1744 1747 if (!buffer.size()) 1745 1748 return std::make_pair(jsNull(), SerializationReturnCode::UnspecifiedError); 1746 CloneDeserializer deserializer(exec, globalObject, messagePorts, arrayBufferContentsArray, buffer, blobURLs, blobFilePaths, sharedBuffers, WTFMove(imageBuffers)1749 CloneDeserializer deserializer(exec, globalObject, messagePorts, arrayBufferContentsArray, buffer, blobURLs, sessionID, blobFilePaths, sharedBuffers, WTFMove(imageBuffers) 1747 1750 #if ENABLE(WEBASSEMBLY) 1748 1751 , wasmModules … … 1818 1821 } 1819 1822 1820 CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers1823 CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers 1821 1824 #if ENABLE(WEBASSEMBLY) 1822 1825 , WasmModuleArray* wasmModules … … 1833 1836 , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) 1834 1837 , m_blobURLs(blobURLs) 1838 , m_sessionID(sessionID) 1835 1839 , m_blobFilePaths(blobFilePaths) 1836 1840 , m_sharedBuffers(sharedBuffers) … … 3039 3043 Vector<RefPtr<JSC::ArrayBuffer>> m_arrayBuffers; 3040 3044 Vector<String> m_blobURLs; 3045 PAL::SessionID m_sessionID; 3041 3046 Vector<String> m_blobFilePaths; 3042 3047 ArrayBufferContentsArray* m_sharedBuffers; … … 3259 3264 } 3260 3265 3261 SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<String>& blobURLs, std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray, std::unique_ptr<ArrayBufferContentsArray> sharedBufferContentsArray, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers3266 SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray, std::unique_ptr<ArrayBufferContentsArray> sharedBufferContentsArray, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers 3262 3267 #if ENABLE(WEBASSEMBLY) 3263 3268 , std::unique_ptr<WasmModuleArray> wasmModulesArray … … 3271 3276 , m_wasmModulesArray(WTFMove(wasmModulesArray)) 3272 3277 #endif 3278 , m_sessionID(sessionID) 3273 3279 { 3274 3280 // Since this SerializedScriptValue is meant to be passed between threads, its String data members … … 3353 3359 Vector<uint8_t> buffer; 3354 3360 Vector<String> blobURLs; 3361 PAL::SessionID sessionID; 3355 3362 Vector<RefPtr<MessagePort>> dummyMessagePorts; 3356 3363 Vector<RefPtr<ImageBitmap>> dummyImageBitmaps; … … 3364 3371 dummyModules, 3365 3372 #endif 3366 blobURLs, buffer, SerializationContext::Default, dummySharedBuffers);3373 blobURLs, sessionID, buffer, SerializationContext::Default, dummySharedBuffers); 3367 3374 3368 3375 #if ENABLE(WEBASSEMBLY) … … 3376 3383 return nullptr; 3377 3384 3378 return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, nullptr, nullptr, { }3385 return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, sessionID, nullptr, nullptr, { } 3379 3386 #if ENABLE(WEBASSEMBLY) 3380 3387 , nullptr … … 3432 3439 Vector<uint8_t> buffer; 3433 3440 Vector<String> blobURLs; 3441 PAL::SessionID sessionID; 3434 3442 #if ENABLE(WEBASSEMBLY) 3435 3443 WasmModuleArray wasmModules; … … 3440 3448 wasmModules, 3441 3449 #endif 3442 blobURLs, buffer, context, *sharedBuffers);3450 blobURLs, sessionID, buffer, context, *sharedBuffers); 3443 3451 3444 3452 if (code != SerializationReturnCode::SuccessfullyCompleted) … … 3451 3459 auto imageBuffers = ImageBitmap::detachBitmaps(WTFMove(imageBitmaps)); 3452 3460 3453 return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, arrayBufferContentsArray.releaseReturnValue(), context == SerializationContext::WorkerPostMessage ? WTFMove(sharedBuffers) : nullptr, WTFMove(imageBuffers)3461 return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, sessionID, arrayBufferContentsArray.releaseReturnValue(), context == SerializationContext::WorkerPostMessage ? WTFMove(sharedBuffers) : nullptr, WTFMove(imageBuffers) 3454 3462 #if ENABLE(WEBASSEMBLY) 3455 3463 , std::make_unique<WasmModuleArray>(wasmModules) … … 3499 3507 Vector<String> dummyBlobs; 3500 3508 Vector<String> dummyPaths; 3501 return deserialize(exec, globalObject, messagePorts, dummyBlobs, dummyPaths, throwExceptions); 3509 PAL::SessionID dummySessionID; 3510 return deserialize(exec, globalObject, messagePorts, dummyBlobs, dummySessionID, dummyPaths, throwExceptions); 3502 3511 } 3503 3512 3504 JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions)3513 JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const PAL::SessionID& sessionID, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions) 3505 3514 { 3506 DeserializationResult result = CloneDeserializer::deserialize(&exec, globalObject, messagePorts, WTFMove(m_imageBuffers), m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths, m_sharedBufferContentsArray.get()3515 DeserializationResult result = CloneDeserializer::deserialize(&exec, globalObject, messagePorts, WTFMove(m_imageBuffers), m_arrayBufferContentsArray.get(), m_data, blobURLs, sessionID, blobFilePaths, m_sharedBufferContentsArray.get() 3507 3516 #if ENABLE(WEBASSEMBLY) 3508 3517 , m_wasmModulesArray.get() … … 3553 3562 } 3554 3563 3555 void SerializedScriptValue::writeBlobsToDiskForIndexedDB( WTF::Function<void (const IDBValue&)>&& completionHandler)3564 void SerializedScriptValue::writeBlobsToDiskForIndexedDB(CompletionHandler<void(IDBValue&&)>&& completionHandler) 3556 3565 { 3557 3566 ASSERT(isMainThread()); … … 3559 3568 3560 3569 RefPtr<SerializedScriptValue> protectedThis(this); 3561 blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler = WTFMove(completionHandler), this, protectedThis = WTFMove(protectedThis)](auto& blobFilePaths) { 3570 // FIXME: Add m_sessionID as a parameter here. 3571 blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler = WTFMove(completionHandler), this, protectedThis = WTFMove(protectedThis)] (auto& blobFilePaths) mutable { 3562 3572 ASSERT(isMainThread()); 3563 3573 … … 3571 3581 ASSERT(m_blobURLs.size() == blobFilePaths.size()); 3572 3582 3573 completionHandler({ *this, m_blobURLs, blobFilePaths });3583 completionHandler({ *this, m_blobURLs, m_sessionID, blobFilePaths }); 3574 3584 }); 3575 3585 } … … 3585 3595 3586 3596 RunLoop::main().dispatch([this, conditionPtr = &condition, valuePtr = &value] { 3587 writeBlobsToDiskForIndexedDB([conditionPtr, valuePtr]( const IDBValue& result) {3597 writeBlobsToDiskForIndexedDB([conditionPtr, valuePtr](IDBValue&& result) { 3588 3598 ASSERT(isMainThread()); 3589 3599 valuePtr->setAsIsolatedCopy(result); -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.h
r230828 r238632 32 32 #include <JavaScriptCore/JSCJSValue.h> 33 33 #include <JavaScriptCore/Strong.h> 34 #include <pal/SessionID.h> 34 35 #include <wtf/Forward.h> 35 36 #include <wtf/Function.h> … … 78 79 WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, SerializationErrorMode = SerializationErrorMode::Throwing); 79 80 WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, const Vector<RefPtr<MessagePort>>&, SerializationErrorMode = SerializationErrorMode::Throwing); 80 JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, const Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode = SerializationErrorMode::Throwing);81 JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, const Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const PAL::SessionID&, const Vector<String>& blobFilePaths, SerializationErrorMode = SerializationErrorMode::Throwing); 81 82 82 83 static uint32_t wireFormatVersion(); … … 93 94 #if ENABLE(INDEXED_DATABASE) 94 95 Vector<String> blobURLsIsolatedCopy() const; 95 void writeBlobsToDiskForIndexedDB(WTF::Function<void (const IDBValue&)>&& completionHandler); 96 const PAL::SessionID& sessionID() const { return m_sessionID; } 97 void writeBlobsToDiskForIndexedDB(CompletionHandler<void(IDBValue&&)>&&); 96 98 IDBValue writeBlobsToDiskForIndexedDBSynchronously(); 97 99 #endif // ENABLE(INDEXED_DATABASE) … … 111 113 WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&); 112 114 WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&, std::unique_ptr<ArrayBufferContentsArray>); 113 SerializedScriptValue(Vector<unsigned char>&&, const Vector<String>& blobURLs, std::unique_ptr<ArrayBufferContentsArray>, std::unique_ptr<ArrayBufferContentsArray> sharedBuffers, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers115 SerializedScriptValue(Vector<unsigned char>&&, const Vector<String>& blobURLs, const PAL::SessionID&, std::unique_ptr<ArrayBufferContentsArray>, std::unique_ptr<ArrayBufferContentsArray> sharedBuffers, Vector<std::pair<std::unique_ptr<ImageBuffer>, bool>>&& imageBuffers 114 116 #if ENABLE(WEBASSEMBLY) 115 117 , std::unique_ptr<WasmModuleArray> … … 125 127 #endif 126 128 Vector<String> m_blobURLs; 129 PAL::SessionID m_sessionID; 127 130 }; 128 131
Note:
See TracChangeset
for help on using the changeset viewer.