Changeset 201232 in webkit
- Timestamp:
- May 20, 2016, 4:15:15 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201228 r201232 1 2016-05-20 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Properly handle blobs in Workers. 4 https://bugs.webkit.org/show_bug.cgi?id=157947 5 6 Reviewed by Alex Christensen. 7 8 * storage/indexeddb/modern/blob-simple-workers-expected.txt: Added. 9 * storage/indexeddb/modern/blob-simple-workers.html: Added. 10 * storage/indexeddb/modern/resources/blob-simple-workers.js: Added. 11 1 12 2016-05-20 Myles C. Maxfield <mmaxfield@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r201229 r201232 1 2016-05-20 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Properly handle blobs in Workers. 4 https://bugs.webkit.org/show_bug.cgi?id=157947 5 6 Reviewed by Alex Christensen. 7 8 Test: storage/indexeddb/modern/blob-simple-workers.html 9 10 * Modules/indexeddb/IDBTransaction.cpp: 11 (WebCore::IDBTransaction::putOrAddOnServer): Use writeBlobsToDiskForIndexedDBSynchronously from 12 background threads instead of the asynchronous form. 13 14 Add ability to set an existing empty IDBValue to be an isolated copy of a different IDBValue: 15 * Modules/indexeddb/IDBValue.cpp: 16 (WebCore::IDBValue::setAsIsolatedCopy): 17 (WebCore::IDBValue::isolatedCopy): 18 * Modules/indexeddb/IDBValue.h: 19 20 Add a method - only to be called from a non-main thread - that synchronously writes blobs to disk: 21 * bindings/js/SerializedScriptValue.cpp: 22 (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDBSynchronously): 23 * bindings/js/SerializedScriptValue.h: 24 1 25 2016-05-20 Anders Carlsson <andersca@apple.com> 2 26 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r201098 r201232 939 939 { 940 940 LOG(IndexedDB, "IDBTransaction::putOrAddOnServer"); 941 ASSERT(currentThread() == m_database->originThreadID());941 ASSERT(currentThread() == originThreadID()); 942 942 ASSERT(!isReadOnly()); 943 943 ASSERT(value); … … 945 945 if (!value->hasBlobURLs()) { 946 946 m_database->connectionProxy().putOrAdd(operation, key.get(), *value, overwriteMode); 947 return; 948 } 949 950 // Due to current limitations on our ability to post tasks back to a worker thread, 951 // workers currently write blobs to disk synchronously. 952 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=157958 - Make this asynchronous after refactoring allows it. 953 if (!isMainThread()) { 954 auto idbValue = value->writeBlobsToDiskForIndexedDBSynchronously(); 955 if (idbValue.data().data()) 956 m_database->connectionProxy().putOrAdd(operation, key.get(), idbValue, overwriteMode); 957 else { 958 // If the IDBValue doesn't have any data, then something went wrong writing the blobs to disk. 959 // In that case, we cannot successfully store this record, so we callback with an error. 960 RefPtr<IDBClient::TransactionOperation> protectedOperation(&operation); 961 auto result = IDBResultData::error(operation.identifier(), { IDBDatabaseException::UnknownError, ASCIILiteral("Error preparing Blob/File data to be stored in object store") }); 962 scriptExecutionContext()->postTask([protectedOperation, result](ScriptExecutionContext&) { 963 protectedOperation->completed(result); 964 }); 965 } 947 966 return; 948 967 } … … 951 970 RefPtr<IDBClient::TransactionOperation> protectedOperation(&operation); 952 971 value->writeBlobsToDiskForIndexedDB([protectedThis, this, protectedOperation, key, value, overwriteMode](const IDBValue& idbValue) { 972 ASSERT(currentThread() == originThreadID()); 973 ASSERT(isMainThread()); 953 974 if (idbValue.data().data()) { 954 975 m_database->connectionProxy().putOrAdd(*protectedOperation, key.get(), idbValue, overwriteMode); -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp
r199730 r201232 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include "CrossThreadCopier.h" 31 32 #include "SerializedScriptValue.h" 32 33 … … 70 71 } 71 72 73 void IDBValue::setAsIsolatedCopy(const IDBValue& other) 74 { 75 ASSERT(m_blobURLs.isEmpty() && m_blobFilePaths.isEmpty()); 76 77 m_data = other.m_data; 78 m_blobURLs = CrossThreadCopier<Vector<String>>::copy(other.m_blobURLs); 79 m_blobFilePaths = CrossThreadCopier<Vector<String>>::copy(other.m_blobFilePaths); 80 } 81 72 82 IDBValue IDBValue::isolatedCopy() const 73 83 { 74 84 IDBValue result; 75 result.m_data = m_data; 76 77 result.m_blobURLs.reserveInitialCapacity(m_blobURLs.size()); 78 for (auto& url : m_blobURLs) 79 result.m_blobURLs.uncheckedAppend(url.isolatedCopy()); 80 81 result.m_blobFilePaths.reserveInitialCapacity(m_blobFilePaths.size()); 82 for (auto& path : m_blobFilePaths) 83 result.m_blobFilePaths.uncheckedAppend(path.isolatedCopy()); 84 85 result.setAsIsolatedCopy(*this); 85 86 return result; 86 87 } -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.h
r199524 r201232 43 43 IDBValue(const ThreadSafeDataBuffer&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths); 44 44 45 void setAsIsolatedCopy(const IDBValue&); 45 46 IDBValue isolatedCopy() const; 46 47 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r200895 r201232 80 80 #include <wtf/HashTraits.h> 81 81 #include <wtf/MainThread.h> 82 #include <wtf/RunLoop.h> 82 83 #include <wtf/Vector.h> 83 84 … … 2817 2818 }); 2818 2819 } 2820 2821 IDBValue SerializedScriptValue::writeBlobsToDiskForIndexedDBSynchronously() 2822 { 2823 ASSERT(!isMainThread()); 2824 2825 IDBValue value; 2826 IDBValue* valuePtr = &value; 2827 2828 Lock lock; 2829 Condition condition; 2830 Condition* conditionPtr = &condition; 2831 lock.lock(); 2832 2833 RunLoop::main().dispatch([this, conditionPtr, valuePtr] { 2834 writeBlobsToDiskForIndexedDB([conditionPtr, valuePtr](const IDBValue& result) { 2835 ASSERT(isMainThread()); 2836 valuePtr->setAsIsolatedCopy(result); 2837 2838 conditionPtr->notifyAll(); 2839 }); 2840 }); 2841 2842 condition.wait(lock); 2843 2844 return value; 2845 } 2846 2819 2847 #endif // ENABLE(INDEXED_DATABASE) 2820 2848 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.h
r200558 r201232 88 88 Vector<String> blobURLsIsolatedCopy() const; 89 89 void writeBlobsToDiskForIndexedDB(std::function<void (const IDBValue&)> completionHandler); 90 IDBValue writeBlobsToDiskForIndexedDBSynchronously(); 90 91 #endif // ENABLE(INDEXED_DATABASE) 91 92
Note:
See TracChangeset
for help on using the changeset viewer.