Changeset 199043 in webkit
- Timestamp:
- Apr 4, 2016, 10:47:32 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 26 edited
- 2 copied
-
WebCore/CMakeLists.txt (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/indexeddb/IDBTransaction.cpp (modified) (1 diff)
-
WebCore/Modules/indexeddb/IDBValue.cpp (copied) (copied from trunk/Source/WebCore/platform/ScopeGuard.h ) (1 diff)
-
WebCore/Modules/indexeddb/IDBValue.h (copied) (copied from trunk/Source/WebCore/platform/ScopeGuard.h ) (1 diff)
-
WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (modified) (1 diff)
-
WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (modified) (1 diff)
-
WebCore/Modules/indexeddb/client/TransactionOperation.h (modified) (3 diffs)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WebCore/bindings/js/SerializedScriptValue.cpp (modified) (7 diffs)
-
WebCore/bindings/js/SerializedScriptValue.h (modified) (4 diffs)
-
WebCore/platform/FileSystem.cpp (modified) (2 diffs)
-
WebCore/platform/FileSystem.h (modified) (1 diff)
-
WebCore/platform/ScopeGuard.h (modified) (1 diff)
-
WebCore/platform/network/BlobRegistry.h (modified) (2 diffs)
-
WebCore/platform/network/BlobRegistryImpl.cpp (modified) (2 diffs)
-
WebCore/platform/network/BlobRegistryImpl.h (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp (modified) (1 diff)
-
WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h (modified) (2 diffs)
-
WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (modified) (3 diffs)
-
WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (modified) (1 diff)
-
WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (modified) (1 diff)
-
WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp (modified) (1 diff)
-
WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h (modified) (1 diff)
-
WebKit2/WebProcess/Network/NetworkProcessConnection.cpp (modified) (1 diff)
-
WebKit2/WebProcess/Network/NetworkProcessConnection.h (modified) (3 diffs)
-
WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r199030 r199043 851 851 Modules/indexeddb/IDBRequestCompletionEvent.cpp 852 852 Modules/indexeddb/IDBTransaction.cpp 853 Modules/indexeddb/IDBValue.cpp 853 854 Modules/indexeddb/IDBVersionChangeEvent.cpp 854 855 Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp -
trunk/Source/WebCore/ChangeLog
r199042 r199043 1 2016-04-04 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Dump blobs to disk before storing them in an object store. 4 https://bugs.webkit.org/show_bug.cgi?id=156068 5 6 Reviewed by Alex Christensen. 7 8 No new tests (Under development, no observable change in behavior yet). 9 10 * WebCore.xcodeproj/project.pbxproj: 11 * CMakeLists.txt: 12 13 * Modules/indexeddb/IDBTransaction.cpp: 14 (WebCore::IDBTransaction::putOrAddOnServer): 15 16 * Modules/indexeddb/IDBValue.cpp: Copied from Source/WebCore/platform/ScopeGuard.h. 17 (WebCore::IDBValue::IDBValue): 18 * Modules/indexeddb/IDBValue.h: Copied from Source/WebCore/platform/ScopeGuard.h. 19 20 * Modules/indexeddb/client/IDBConnectionToServer.cpp: 21 (WebCore::IDBClient::IDBConnectionToServer::putOrAdd): 22 * Modules/indexeddb/client/IDBConnectionToServer.h: 23 24 * Modules/indexeddb/client/TransactionOperation.h: 25 26 * bindings/js/SerializedScriptValue.cpp: 27 (WebCore::SerializedScriptValue::SerializedScriptValue): 28 (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB): 29 (WebCore::SerializedScriptValue::addBlobURL): Deleted. 30 * bindings/js/SerializedScriptValue.h: 31 32 * platform/FileSystem.cpp: 33 (WebCore::appendFileContentsToFileHandle): 34 * platform/FileSystem.h: 35 36 * platform/ScopeGuard.h: 37 38 * platform/network/BlobRegistry.h: 39 * platform/network/BlobRegistryImpl.cpp: 40 (WebCore::blobUtilityQueue): 41 (WebCore::BlobRegistryImpl::writeBlobsToTemporaryFiles): 42 * platform/network/BlobRegistryImpl.h: 43 1 44 2016-04-04 Jer Noble <jer.noble@apple.com> 2 45 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r198762 r199043 868 868 869 869 ASSERT(!isReadOnly()); 870 871 serverConnection().putOrAdd(operation, key, value, overwriteMode); 870 ASSERT(value); 871 872 RefPtr<IDBTransaction> protector(this); 873 RefPtr<IDBClient::TransactionOperation> operationRef(&operation); 874 value->writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue&) { 875 // FIXME: Send the passed in IDBValue to the IDB server instead of the SerializedScriptValue. 876 serverConnection().putOrAdd(*operationRef, key.get(), *value, overwriteMode); 877 }); 872 878 } 873 879 -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp
r199042 r199043 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 #ifndef ScopeGuard_h 26 #define ScopeGuard_h 25 26 #include "config.h" 27 #include "IDBValue.h" 28 29 #if ENABLE(INDEXED_DATABASE) 27 30 28 31 namespace WebCore { 29 32 30 class ScopeGuard { 31 public: 32 ScopeGuard() 33 { 34 } 35 36 ScopeGuard(std::function<void()> function) 37 : m_function(WTFMove(function)) 38 { 39 } 40 41 ~ScopeGuard() 42 { 43 if (m_function) 44 m_function(); 45 } 46 47 void enable(std::function<void()> function) 48 { 49 m_function = WTFMove(function); 50 } 51 52 void disable() 53 { 54 m_function = nullptr; 55 } 56 57 private: 58 std::function<void()> m_function { nullptr }; 59 }; 33 IDBValue::IDBValue() 34 { 35 } 60 36 61 37 } // namespace WebCore 62 38 63 #endif // ScopeGuard_h39 #endif // ENABLE(INDEXED_DATABASE) -
trunk/Source/WebCore/Modules/indexeddb/IDBValue.h
r199042 r199043 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 #ifndef ScopeGuard_h 26 #define ScopeGuard_h 25 26 #pragma once 27 #if ENABLE(INDEXED_DATABASE) 27 28 28 29 namespace WebCore { 29 30 30 class ScopeGuard{31 class IDBValue { 31 32 public: 32 ScopeGuard() 33 { 34 } 35 36 ScopeGuard(std::function<void()> function) 37 : m_function(WTFMove(function)) 38 { 39 } 40 41 ~ScopeGuard() 42 { 43 if (m_function) 44 m_function(); 45 } 46 47 void enable(std::function<void()> function) 48 { 49 m_function = WTFMove(function); 50 } 51 52 void disable() 53 { 54 m_function = nullptr; 55 } 56 57 private: 58 std::function<void()> m_function { nullptr }; 33 IDBValue(); 59 34 }; 60 35 61 36 } // namespace WebCore 62 37 63 #endif // ScopeGuard_h38 #endif // ENABLE(INDEXED_DATABASE) -
trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp
r198762 r199043 172 172 } 173 173 174 void IDBConnectionToServer::putOrAdd(TransactionOperation& operation, RefPtr<IDBKey>& key, RefPtr<SerializedScriptValue>& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)174 void IDBConnectionToServer::putOrAdd(TransactionOperation& operation, IDBKey* key, SerializedScriptValue& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode) 175 175 { 176 176 LOG(IndexedDB, "IDBConnectionToServer::putOrAdd"); 177 177 178 178 saveOperation(operation); 179 m_delegate->putOrAdd(IDBRequestData(operation), key .get(), *value, overwriteMode);179 m_delegate->putOrAdd(IDBRequestData(operation), key, value, overwriteMode); 180 180 } 181 181 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h
r198762 r199043 78 78 WEBCORE_EXPORT void didDeleteIndex(const IDBResultData&); 79 79 80 void putOrAdd(TransactionOperation&, RefPtr<IDBKey>&, RefPtr<SerializedScriptValue>&, const IndexedDB::ObjectStoreOverwriteMode);80 void putOrAdd(TransactionOperation&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode); 81 81 WEBCORE_EXPORT void didPutOrAdd(const IDBResultData&); 82 82 -
trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h
r198762 r199043 43 43 namespace IDBClient { 44 44 45 class TransactionOperation : public RefCounted<TransactionOperation> {45 class TransactionOperation : public ThreadSafeRefCounted<TransactionOperation> { 46 46 public: 47 47 void perform() … … 93 93 : TransactionOperation(transaction) 94 94 { 95 relaxAdoptionRequirement();96 95 RefPtr<TransactionOperation> self(this); 97 96 … … 112 111 : TransactionOperation(transaction, request) 113 112 { 114 relaxAdoptionRequirement();115 113 RefPtr<TransactionOperation> self(this); 116 114 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r199030 r199043 2046 2046 516071321BD8308B00DBC4F2 /* TransactionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160712B1BD8305300DBC4F2 /* TransactionOperation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2047 2047 5160F4980B0AA75F00C1D2AF /* HistoryItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */; }; 2048 516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 516103AE1CADB9A30016B4C7 /* IDBValue.h */; }; 2049 516103B01CADBA7A0016B4C7 /* IDBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516103AD1CADB9A30016B4C7 /* IDBValue.cpp */; }; 2048 2050 5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */; }; 2049 2051 5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9596 9598 5160712D1BD8307200DBC4F2 /* IDBObjectStoreInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBObjectStoreInfo.h; sourceTree = "<group>"; }; 9597 9599 5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HistoryItemMac.mm; sourceTree = "<group>"; }; 9600 516103AD1CADB9A30016B4C7 /* IDBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBValue.cpp; sourceTree = "<group>"; }; 9601 516103AE1CADB9A30016B4C7 /* IDBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBValue.h; sourceTree = "<group>"; }; 9598 9602 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchemeRegistry.cpp; sourceTree = "<group>"; }; 9599 9603 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchemeRegistry.h; sourceTree = "<group>"; }; … … 19587 19591 51645B511B9F889B00F789CE /* IDBTransaction.h */, 19588 19592 51D719A6181106E00016DC51 /* IDBTransaction.idl */, 19593 516103AD1CADB9A30016B4C7 /* IDBValue.cpp */, 19594 516103AE1CADB9A30016B4C7 /* IDBValue.h */, 19589 19595 51645B521B9F889B00F789CE /* IDBVersionChangeEvent.cpp */, 19590 19596 51645B531B9F889B00F789CE /* IDBVersionChangeEvent.h */, … … 25993 25999 2E75841E12779ADA0062628B /* FileReaderLoader.h in Headers */, 25994 26000 2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */, 26001 516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */, 25995 26002 2EDF369D122C94B4002F7D4E /* FileReaderSync.h in Headers */, 25996 26003 2EF1BFEB121C9F4200C27627 /* FileStream.h in Headers */, … … 31787 31794 B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */, 31788 31795 9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */, 31796 516103B01CADBA7A0016B4C7 /* IDBValue.cpp in Sources */, 31789 31797 9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */, 31790 31798 071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r198852 r199043 1 1 /* 2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 30 30 #include "Blob.h" 31 #include "BlobRegistry.h" 31 32 #include "CryptoKeyAES.h" 32 33 #include "CryptoKeyDataOctetSequence.h" … … 37 38 #include "File.h" 38 39 #include "FileList.h" 40 #include "IDBValue.h" 39 41 #include "ImageData.h" 40 42 #include "JSBlob.h" … … 76 78 #include <runtime/TypedArrays.h> 77 79 #include <wtf/HashTraits.h> 80 #include <wtf/MainThread.h> 78 81 #include <wtf/Vector.h> 79 82 … … 2583 2586 } 2584 2587 2585 void SerializedScriptValue::addBlobURL(const String& string)2586 {2587 m_blobURLs.append(Vector<uint16_t>());2588 m_blobURLs.last().reserveCapacity(string.length());2589 for (size_t i = 0; i < string.length(); i++)2590 m_blobURLs.last().append(string.characterAt(i));2591 m_blobURLs.last().resize(m_blobURLs.last().size());2592 }2593 2594 2588 SerializedScriptValue::~SerializedScriptValue() 2595 2589 { … … 2601 2595 } 2602 2596 2603 SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<String>& blobURLs)2604 : m_data(WTFMove(buffer))2605 {2606 for (auto& string : blobURLs)2607 addBlobURL(string);2608 }2609 2610 2597 SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<String>& blobURLs, std::unique_ptr<ArrayBufferContentsArray>&& arrayBufferContentsArray) 2611 2598 : m_data(WTFMove(buffer)) 2612 2599 , m_arrayBufferContentsArray(WTFMove(arrayBufferContentsArray)) 2613 2600 { 2614 for (auto& string : blobURLs) 2615 addBlobURL(string); 2601 // Since this SerializedScriptValue is meant to be passed between threads, its String data members 2602 // need to be isolatedCopies so we don't run into thread safety issues for the StringImpls. 2603 m_blobURLs.reserveInitialCapacity(blobURLs.size()); 2604 for (auto& url : blobURLs) 2605 m_blobURLs.append(url.isolatedCopy()); 2616 2606 } 2617 2607 … … 2758 2748 } 2759 2749 2750 void SerializedScriptValue::writeBlobsToDiskForIndexedDB(std::function<void (const IDBValue&)> completionHandler) 2751 { 2752 ASSERT(isMainThread()); 2753 2754 if (m_blobURLs.isEmpty()) { 2755 completionHandler({ }); 2756 return; 2757 } 2758 2759 RefPtr<SerializedScriptValue> protector(this); 2760 blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector<String>&) { 2761 // FIXME: Return an IDBValue that contains both the SerializedScriptValue data and all blob file data. 2762 completionHandler({ }); 2763 }); 2760 2764 } 2765 2766 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.h
r198852 r199043 1 1 /* 2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 42 42 namespace WebCore { 43 43 44 class IDBValue; 44 45 class MessagePort; 45 46 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; … … 84 85 const Vector<uint8_t>& data() const { return m_data; } 85 86 bool hasBlobURLs() const { return !m_blobURLs.isEmpty(); } 86 void blobURLs(Vector<String>&) const;87 void writeBlobsToDiskForIndexedDB(std::function<void (const IDBValue&)> completionHandler); 87 88 88 89 static Ref<SerializedScriptValue> createFromWireBytes(Vector<uint8_t>&& data) … … 99 100 static bool serializationDidCompleteSuccessfully(SerializationReturnCode); 100 101 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBuffers(JSC::ExecState*, ArrayBufferArray&, SerializationReturnCode&); 101 void addBlobURL(const String&);102 102 103 103 WEBCORE_EXPORT SerializedScriptValue(Vector<unsigned char>&&); 104 SerializedScriptValue(Vector<unsigned char>&&, const Vector<String>& blobURLs);105 104 SerializedScriptValue(Vector<unsigned char>&&, const Vector<String>& blobURLs, std::unique_ptr<ArrayBufferContentsArray>&&); 106 105 107 106 Vector<unsigned char> m_data; 108 107 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; 109 Vector<Vector<uint16_t>> m_blobURLs; 108 109 Vector<String> m_blobURLs; 110 110 }; 111 111 -
trunk/Source/WebCore/platform/FileSystem.cpp
r195913 r199043 28 28 #include "FileSystem.h" 29 29 30 #include "ScopeGuard.h" 30 31 #include <wtf/HexNumber.h> 31 32 #include <wtf/text/CString.h> … … 130 131 } 131 132 133 bool appendFileContentsToFileHandle(const String& path, PlatformFileHandle& target) 134 { 135 auto source = openFile(path, OpenForRead); 136 137 if (!isHandleValid(source)) 138 return false; 139 140 static int bufferSize = 1 << 19; 141 Vector<char> buffer(bufferSize); 142 143 ScopeGuard fileCloser([source]() { 144 PlatformFileHandle handle = source; 145 closeFile(handle); 146 }); 147 148 do { 149 int readBytes = readFromFile(source, buffer.data(), bufferSize); 150 151 if (readBytes < 0) 152 return false; 153 154 if (writeToFile(target, buffer.data(), readBytes) != readBytes) 155 return false; 156 157 if (readBytes < bufferSize) 158 return true; 159 } while (true); 160 161 ASSERT_NOT_REACHED(); 162 } 163 132 164 #if !PLATFORM(MAC) 133 165 -
trunk/Source/WebCore/platform/FileSystem.h
r189749 r199043 177 177 // Returns number of bytes actually written if successful, -1 otherwise. 178 178 int readFromFile(PlatformFileHandle, char* data, int length); 179 180 // Appends the contents of the file found at 'path' to the open PlatformFileHandle. 181 // Returns true if the write was successful, false if it was not. 182 bool appendFileContentsToFileHandle(const String& path, PlatformFileHandle&); 183 179 184 #if USE(FILE_LOCK) 180 185 bool lockFile(PlatformFileHandle, FileLockMode); -
trunk/Source/WebCore/platform/ScopeGuard.h
r195997 r199043 25 25 #ifndef ScopeGuard_h 26 26 #define ScopeGuard_h 27 28 #include <functional> 27 29 28 30 namespace WebCore { -
trunk/Source/WebCore/platform/network/BlobRegistry.h
r196174 r199043 32 32 #define BlobRegistry_h 33 33 34 #include <functional> 34 35 #include <wtf/Forward.h> 35 36 #include <wtf/Vector.h> … … 64 65 virtual unsigned long long blobSize(const URL&) = 0; 65 66 67 virtual void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) = 0; 68 66 69 virtual bool isBlobRegistryImpl() const { return false; } 67 70 -
trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp
r198869 r199043 42 42 #include "ResourceRequest.h" 43 43 #include "ResourceResponse.h" 44 #include "ScopeGuard.h" 44 45 #include <wtf/MainThread.h> 46 #include <wtf/NeverDestroyed.h> 45 47 #include <wtf/StdLibExtras.h> 48 #include <wtf/WorkQueue.h> 46 49 47 50 namespace WebCore { … … 229 232 } 230 233 234 static WorkQueue& blobUtilityQueue() 235 { 236 static NeverDestroyed<Ref<WorkQueue>> queue(WorkQueue::create("org.webkit.BlobUtility", WorkQueue::Type::Serial, WorkQueue::QOS::Background)); 237 return queue.get(); 238 } 239 240 struct BlobForFileWriting { 241 String blobURL; 242 Vector<std::pair<String, ThreadSafeDataBuffer>> filePathsOrDataBuffers; 243 }; 244 245 void BlobRegistryImpl::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) 246 { 247 Vector<BlobForFileWriting> blobsForWriting; 248 for (auto& url : blobURLs) { 249 blobsForWriting.append({ }); 250 blobsForWriting.last().blobURL = url.isolatedCopy(); 251 252 auto* blobData = getBlobDataFromURL({ ParsedURLString, url }); 253 if (!blobData) { 254 Vector<String> filePaths; 255 completionHandler(filePaths); 256 } 257 258 for (auto& item : blobData->items()) { 259 switch (item.type()) { 260 case BlobDataItem::Type::Data: 261 blobsForWriting.last().filePathsOrDataBuffers.append({ { }, item.data() }); 262 break; 263 case BlobDataItem::Type::File: 264 blobsForWriting.last().filePathsOrDataBuffers.append({ item.file()->path().isolatedCopy(), { } }); 265 266 } 267 } 268 } 269 270 blobUtilityQueue().dispatch([blobsForWriting, completionHandler]() { 271 Vector<String> filePaths; 272 273 ScopeGuard completionCaller([completionHandler]() { 274 callOnMainThread([completionHandler]() { 275 Vector<String> filePaths; 276 completionHandler(filePaths); 277 }); 278 }); 279 280 for (auto& blob : blobsForWriting) { 281 PlatformFileHandle file; 282 String tempFilePath = openTemporaryFile(ASCIILiteral("Blob"), file); 283 284 ScopeGuard fileCloser([file, completionHandler]() { 285 PlatformFileHandle handle = file; 286 closeFile(handle); 287 }); 288 289 if (tempFilePath.isEmpty() || !isHandleValid(file)) { 290 LOG_ERROR("Failed to open temporary file for writing a Blob to IndexedDB"); 291 return; 292 } 293 294 for (auto& part : blob.filePathsOrDataBuffers) { 295 if (part.second.data()) { 296 int length = part.second.data()->size(); 297 if (writeToFile(file, reinterpret_cast<const char*>(part.second.data()->data()), length) != length) { 298 LOG_ERROR("Failed writing a Blob to temporary file for storage in IndexedDB"); 299 return; 300 } 301 } else { 302 ASSERT(!part.first.isEmpty()); 303 if (!appendFileContentsToFileHandle(part.first, file)) { 304 LOG_ERROR("Failed copying File contents to a Blob temporary file for storage in IndexedDB"); 305 return; 306 } 307 } 308 } 309 310 filePaths.append(tempFilePath.isolatedCopy()); 311 } 312 313 completionCaller.disable(); 314 callOnMainThread([completionHandler, filePaths]() { 315 completionHandler(filePaths); 316 }); 317 }); 318 } 319 231 320 } // namespace WebCore -
trunk/Source/WebCore/platform/network/BlobRegistryImpl.h
r197563 r199043 68 68 unsigned long long blobSize(const URL&) override; 69 69 70 void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) override; 71 70 72 HashMap<String, RefPtr<BlobData>> m_blobs; 71 73 }; -
trunk/Source/WebKit2/ChangeLog
r199040 r199043 1 2016-04-04 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Dump blobs to disk before storing them in an object store. 4 https://bugs.webkit.org/show_bug.cgi?id=156068 5 6 Reviewed by Alex Christensen. 7 8 * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp: 9 (WebKit::NetworkBlobRegistry::writeBlobsToTemporaryFiles): 10 * NetworkProcess/FileAPI/NetworkBlobRegistry.h: 11 12 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 13 (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles): 14 * NetworkProcess/NetworkConnectionToWebProcess.h: 15 * NetworkProcess/NetworkConnectionToWebProcess.messages.in: 16 17 * WebProcess/FileAPI/BlobRegistryProxy.cpp: 18 (WebKit::BlobRegistryProxy::writeBlobsToTemporaryFiles): 19 * WebProcess/FileAPI/BlobRegistryProxy.h: 20 21 * WebProcess/Network/NetworkProcessConnection.cpp: 22 (WebKit::NetworkProcessConnection::didClose): 23 (WebKit::NetworkProcessConnection::writeBlobsToTemporaryFiles): 24 (WebKit::NetworkProcessConnection::didWriteBlobsToTemporaryFiles): 25 * WebProcess/Network/NetworkProcessConnection.h: 26 * WebProcess/Network/NetworkProcessConnection.messages.in: 27 1 28 2016-04-04 Chelsea Pugh <cpugh@apple.com> 2 29 -
trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
r198869 r199043 118 118 } 119 119 120 void NetworkBlobRegistry::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void(const Vector<String>&)> completionHandler) 121 { 122 blobRegistry().writeBlobsToTemporaryFiles(blobURLs, completionHandler); 123 } 124 120 125 void NetworkBlobRegistry::connectionToWebProcessDidClose(NetworkConnectionToWebProcess* connection) 121 126 { -
trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h
r196174 r199043 28 28 29 29 #include <WebCore/URLHash.h> 30 #include <functional> 30 31 #include <wtf/HashMap.h> 31 32 #include <wtf/HashSet.h> … … 53 54 void unregisterBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&); 54 55 uint64_t blobSize(NetworkConnectionToWebProcess*, const WebCore::URL&); 56 void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void(const Vector<String>&)> completionHandler); 55 57 56 58 void connectionToWebProcessDidClose(NetworkConnectionToWebProcess*); -
trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
r198911 r199043 31 31 #include "NetworkLoad.h" 32 32 #include "NetworkProcess.h" 33 #include "NetworkProcessConnectionMessages.h" 33 34 #include "NetworkResourceLoadParameters.h" 34 35 #include "NetworkResourceLoader.h" … … 36 37 #include "RemoteNetworkingContext.h" 37 38 #include "SessionTracker.h" 39 #include "WebCoreArgumentCoders.h" 38 40 #include <WebCore/NotImplemented.h> 39 41 #include <WebCore/PingHandle.h> … … 280 282 } 281 283 284 void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, uint64_t requestIdentifier) 285 { 286 RefPtr<NetworkConnectionToWebProcess> protector(this); 287 288 Vector<RefPtr<WebCore::BlobDataFileReference>> fileReferences; 289 for (auto& url : blobURLs) 290 fileReferences.appendVector(NetworkBlobRegistry::singleton().filesInBlob(*this, { ParsedURLString, url })); 291 292 for (auto& file : fileReferences) 293 file->prepareForFileAccess(); 294 295 NetworkBlobRegistry::singleton().writeBlobsToTemporaryFiles(blobURLs, [this, protector, requestIdentifier, fileReferences](const Vector<String>& fileNames) { 296 for (auto& file : fileReferences) 297 file->revokeFileAccess(); 298 299 if (!m_connection || !m_connection->isValid()) 300 return; 301 302 m_connection->send(Messages::NetworkProcessConnection::DidWriteBlobsToTemporaryFiles(requestIdentifier, fileNames), 0); 303 }); 304 } 305 282 306 void NetworkConnectionToWebProcess::ensureLegacyPrivateBrowsingSession() 283 307 { -
trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
r198893 r199043 94 94 void blobSize(const WebCore::URL&, uint64_t& resultSize); 95 95 void unregisterBlobURL(const WebCore::URL&); 96 void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, uint64_t requestIdentifier); 97 96 98 void ensureLegacyPrivateBrowsingSession(); 97 99 -
trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in
r198893 r199043 46 46 UnregisterBlobURL(WebCore::URL url) 47 47 BlobSize(WebCore::URL url) -> (uint64_t resultSize) 48 WriteBlobsToTemporaryFiles(Vector<String> blobURLs, uint64_t requestIdentifier) 49 48 50 EnsureLegacyPrivateBrowsingSession() 49 51 } -
trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp
r196174 r199043 76 76 } 77 77 78 void BlobRegistryProxy::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) 79 { 80 WebProcess::singleton().networkConnection()->writeBlobsToTemporaryFiles(blobURLs, completionHandler); 78 81 } 82 83 } -
trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h
r197563 r199043 39 39 void registerBlobURLForSlice(const WebCore::URL&, const WebCore::URL& srcURL, long long start, long long end) override; 40 40 unsigned long long blobSize(const WebCore::URL&) override; 41 void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) override; 41 42 }; 42 43 -
trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp
r193468 r199043 73 73 // The NetworkProcess probably crashed. 74 74 WebProcess::singleton().networkProcessConnectionClosed(this); 75 76 Vector<String> dummyFilenames; 77 for (auto handler : m_writeBlobToFileCompletionHandlers.values()) 78 handler(dummyFilenames); 79 80 m_writeBlobToFileCompletionHandlers.clear(); 75 81 } 76 82 77 83 void NetworkProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) 78 84 { 85 } 86 87 void NetworkProcessConnection::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler) 88 { 89 static uint64_t writeBlobToFileIdentifier; 90 uint64_t requestIdentifier = ++writeBlobToFileIdentifier; 91 92 m_writeBlobToFileCompletionHandlers.set(requestIdentifier, completionHandler); 93 94 WebProcess::singleton().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::WriteBlobsToTemporaryFiles(blobURLs, requestIdentifier), 0); 95 } 96 97 void NetworkProcessConnection::didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector<String>& filenames) 98 { 99 auto handler = m_writeBlobToFileCompletionHandlers.take(requestIdentifier); 100 if (handler) 101 handler(filenames); 79 102 } 80 103 -
trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h
r197563 r199043 59 59 void didReceiveNetworkProcessConnectionMessage(IPC::Connection&, IPC::MessageDecoder&); 60 60 61 void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, std::function<void (const Vector<String>& filePaths)> completionHandler); 62 61 63 private: 62 64 NetworkProcessConnection(IPC::Connection::Identifier); … … 70 72 IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Network; } 71 73 74 void didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector<String>& filenames); 75 72 76 #if ENABLE(SHAREABLE_RESOURCE) 73 77 // Message handlers. … … 77 81 // The connection from the web process to the network process. 78 82 RefPtr<IPC::Connection> m_connection; 83 84 HashMap<uint64_t, std::function<void (const Vector<String>&)>> m_writeBlobToFileCompletionHandlers; 79 85 }; 80 86 -
trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in
r192697 r199043 27 27 #endif 28 28 29 DidWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, Vector<String> filenames) 29 30 }
Note:
See TracChangeset
for help on using the changeset viewer.