Use lambda capture with initializer instead of StringCapture
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2016 19:03:42 +0000 (19:03 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2016 19:03:42 +0000 (19:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158010

Reviewed by Antti Koivisto.

Source/WebCore:

Use lambda capture with initializer instead of StringCapture now that
we support C++14.

* fileapi/AsyncFileStream.cpp:
(WebCore::AsyncFileStream::getSize):
(WebCore::AsyncFileStream::openForRead):
(WebCore::AsyncFileStream::openForWrite):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::installContentFilterUnblockHandler):
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::setExternalPlayback):
* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownload::didReceiveHeader):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
(WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):

Source/WebKit2:

Use lambda capture with initializer instead of StringCapture now that
we support C++14.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::deleteDumpFile):
* NetworkProcess/cache/NetworkCacheStatistics.cpp:
(WebKit::NetworkCache::Statistics::initialize):
(WebKit::NetworkCache::Statistics::shrinkIfNeeded):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::updateFileModificationTime):
(WebKit::NetworkCache::Storage::clear):
* UIProcess/API/APIUserContentExtensionStore.cpp:
(API::UserContentExtensionStore::lookupContentExtension):
(API::UserContentExtensionStore::compileContentExtension):
(API::UserContentExtensionStore::removeContentExtension):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchData):
(WebKit::WebsiteDataStore::removeData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201341 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/fileapi/AsyncFileStream.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
Source/WebCore/platform/network/curl/CurlDownload.cpp
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp

index 21e994e..b376de6 100644 (file)
@@ -1,3 +1,29 @@
+2016-05-24  Chris Dumez  <cdumez@apple.com>
+
+        Use lambda capture with initializer instead of StringCapture
+        https://bugs.webkit.org/show_bug.cgi?id=158010
+
+        Reviewed by Antti Koivisto.
+
+        Use lambda capture with initializer instead of StringCapture now that
+        we support C++14.
+
+        * fileapi/AsyncFileStream.cpp:
+        (WebCore::AsyncFileStream::getSize):
+        (WebCore::AsyncFileStream::openForRead):
+        (WebCore::AsyncFileStream::openForWrite):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::installContentFilterUnblockHandler):
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::setExternalPlayback):
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownload::didReceiveHeader):
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
+        (WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
+
 2016-05-24  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         In accelerated drawing mode, ImageBuffer::putByteArray() should copy the bytes directly to the IOSurface backing store
index 0fb9124..c1c5778 100644 (file)
@@ -138,11 +138,10 @@ void AsyncFileStream::perform(std::function<std::function<void(FileStreamClient&
 
 void AsyncFileStream::getSize(const String& path, double expectedModificationTime)
 {
-    StringCapture capturedPath(path);
     // FIXME: Explicit return type here and in all the other cases like this below is a workaround for a deficiency
     // in the Windows compiler at the time of this writing. Could remove it if that is resolved.
-    perform([capturedPath, expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        long long size = stream.getSize(capturedPath.string(), expectedModificationTime);
+    perform([path = path.isolatedCopy(), expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        long long size = stream.getSize(path, expectedModificationTime);
         return [size](FileStreamClient& client) {
             client.didGetSize(size);
         };
@@ -151,10 +150,9 @@ void AsyncFileStream::getSize(const String& path, double expectedModificationTim
 
 void AsyncFileStream::openForRead(const String& path, long long offset, long long length)
 {
-    StringCapture capturedPath(path);
     // FIXME: Explicit return type here is a workaround for a deficiency in the Windows compiler at the time of this writing.
-    perform([capturedPath, offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        bool success = stream.openForRead(capturedPath.string(), offset, length);
+    perform([path = path.isolatedCopy(), offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        bool success = stream.openForRead(path, offset, length);
         return [success](FileStreamClient& client) {
             client.didOpen(success);
         };
@@ -163,9 +161,8 @@ void AsyncFileStream::openForRead(const String& path, long long offset, long lon
 
 void AsyncFileStream::openForWrite(const String& path)
 {
-    StringCapture capturedPath(path);
-    perform([capturedPath](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        bool success = stream.openForWrite(capturedPath.string());
+    perform([path = path.isolatedCopy()](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        bool success = stream.openForWrite(path);
         return [success](FileStreamClient& client) {
             client.didOpen(success);
         };
index 97cbf63..39ce83b 100644 (file)
@@ -1703,10 +1703,9 @@ void DocumentLoader::installContentFilterUnblockHandler(ContentFilter& contentFi
     String unblockRequestDeniedScript { contentFilter.unblockRequestDeniedScript() };
     if (!unblockRequestDeniedScript.isEmpty() && frame) {
         static_assert(std::is_base_of<ThreadSafeRefCounted<Frame>, Frame>::value, "Frame must be ThreadSafeRefCounted.");
-        StringCapture capturedScript { unblockRequestDeniedScript };
-        unblockHandler.wrapWithDecisionHandler([frame, capturedScript](bool unblocked) {
+        unblockHandler.wrapWithDecisionHandler([frame, unblockRequestDeniedScript = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
             if (!unblocked)
-                frame->script().executeScript(capturedScript.string());
+                frame->script().executeScript(unblockRequestDeniedScript);
         });
     }
     frameLoader()->client().contentFilterDidBlockLoad(WTFMove(unblockHandler));
index ebd60ff..869b52c 100644 (file)
@@ -98,13 +98,12 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClien
     auto* contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin).release();
     contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
 
-    StringCapture capturedOutgoingReferrer(outgoingReferrer);
-    m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, contentSecurityPolicyCopy, capturedOutgoingReferrer](ScriptExecutionContext& context) {
+    m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, contentSecurityPolicyCopy, outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) {
         ASSERT(isMainThread());
         Document& document = downcast<Document>(context);
 
         auto request = ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData));
-        request->setHTTPReferrer(capturedOutgoingReferrer.string());
+        request->setHTTPReferrer(outgoingReferrer);
 
         auto options = std::unique_ptr<ThreadableLoaderOptions>(optionsCopy);
 
index e5ca472..cb4116f 100644 (file)
@@ -430,10 +430,9 @@ void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, Exte
 {
     ASSERT(WebThreadIsCurrent());
     RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
-    StringCapture capturedLocalizedDeviceName(localizedDeviceName);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, enabled, type, capturedLocalizedDeviceName] {
+    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
         if (m_interface)
-            m_interface->setExternalPlayback(enabled, type, capturedLocalizedDeviceName.string());
+            m_interface->setExternalPlayback(enabled, type, localizedDeviceName);
     });
 }
 
index c6c8797..9f2c4f2 100644 (file)
@@ -414,14 +414,12 @@ void CurlDownload::didReceiveHeader(const String& header)
             });
         }
     } else {
-        StringCapture capturedHeader(header);
-
         RefPtr<CurlDownload> protectedThis(this);
 
-        callOnMainThread([this, capturedHeader, protectedThis] {
-            int splitPos = capturedHeader.string().find(":");
+        callOnMainThread([this, header = header.isolatedCopy(), protectedThis] {
+            int splitPos = header.find(":");
             if (splitPos != -1)
-                m_response.setHTTPHeaderField(capturedHeader.string().left(splitPos), capturedHeader.string().substring(splitPos + 1).stripWhiteSpace());
+                m_response.setHTTPHeaderField(header.left(splitPos), header.substring(splitPos + 1).stripWhiteSpace());
         });
     }
 }
index e9a9091..2ec4cc9 100644 (file)
@@ -141,9 +141,7 @@ bool WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionCon
 
 void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
 {
-    StringCapture capturedErrorMessage(errorMessage);
-    StringCapture capturedSourceURL(sourceURL);
-    m_scriptExecutionContext->postTask([this, capturedErrorMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
+    m_scriptExecutionContext->postTask([this, errorMessage = errorMessage.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
         Worker* workerObject = this->workerObject();
         if (!workerObject)
             return;
@@ -151,20 +149,18 @@ void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessag
         // We don't bother checking the askedToTerminate() flag here, because exceptions should *always* be reported even if the thread is terminated.
         // This is intentionally different than the behavior in MessageWorkerTask, because terminated workers no longer deliver messages (section 4.6 of the WebWorker spec), but they do report exceptions.
 
-        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(capturedErrorMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber));
+        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber));
         if (!errorHandled)
-            context.reportException(capturedErrorMessage.string(), lineNumber, columnNumber, capturedSourceURL.string(), 0);
+            context.reportException(errorMessage, lineNumber, columnNumber, sourceURL, 0);
     });
 }
 
 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageLevel level, const String& message, int lineNumber, int columnNumber, const String& sourceURL)
 {
-    StringCapture capturedMessage(message);
-    StringCapture capturedSourceURL(sourceURL);
-    m_scriptExecutionContext->postTask([this, source, level, capturedMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
+    m_scriptExecutionContext->postTask([this, source, level, message = message.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
         if (askedToTerminate())
             return;
-        context.addConsoleMessage(source, level, capturedMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber);
+        context.addConsoleMessage(source, level, message, sourceURL, lineNumber, columnNumber);
     });
 }
 
index 7b39c17..d23333b 100644 (file)
@@ -1,5 +1,31 @@
 2016-05-24  Chris Dumez  <cdumez@apple.com>
 
+        Use lambda capture with initializer instead of StringCapture
+        https://bugs.webkit.org/show_bug.cgi?id=158010
+
+        Reviewed by Antti Koivisto.
+
+        Use lambda capture with initializer instead of StringCapture now that 
+        we support C++14.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::deleteDumpFile):
+        * NetworkProcess/cache/NetworkCacheStatistics.cpp:
+        (WebKit::NetworkCache::Statistics::initialize):
+        (WebKit::NetworkCache::Statistics::shrinkIfNeeded):
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::updateFileModificationTime):
+        (WebKit::NetworkCache::Storage::clear):
+        * UIProcess/API/APIUserContentExtensionStore.cpp:
+        (API::UserContentExtensionStore::lookupContentExtension):
+        (API::UserContentExtensionStore::compileContentExtension):
+        (API::UserContentExtensionStore::removeContentExtension):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchData):
+        (WebKit::WebsiteDataStore::removeData):
+
+2016-05-24  Chris Dumez  <cdumez@apple.com>
+
         Use auto for some of our lambda function parameters
         https://bugs.webkit.org/show_bug.cgi?id=158001
 
index 34a6d6f..0b615c4 100644 (file)
@@ -618,9 +618,8 @@ void Cache::dumpContentsToFile()
 void Cache::deleteDumpFile()
 {
     auto queue = WorkQueue::create("com.apple.WebKit.Cache.delete");
-    StringCapture dumpFilePathCapture(dumpFilePath());
-    queue->dispatch([dumpFilePathCapture] {
-        WebCore::deleteFile(dumpFilePathCapture.string());
+    queue->dispatch([filePath = dumpFilePath().isolatedCopy()] {
+        WebCore::deleteFile(filePath);
     });
 }
 
index cbf356a..b8a2658 100644 (file)
@@ -93,13 +93,9 @@ void Statistics::initialize(const String& databasePath)
     ASSERT(RunLoop::isMain());
 
     auto startTime = std::chrono::system_clock::now();
-
-    StringCapture databasePathCapture(databasePath);
-    StringCapture networkCachePathCapture(singleton().recordsPath());
-    serialBackgroundIOQueue().dispatch([this, databasePathCapture, networkCachePathCapture, startTime] {
+    serialBackgroundIOQueue().dispatch([this, databasePath = databasePath.isolatedCopy(), networkCachePath = singleton().recordsPath().isolatedCopy(), startTime] {
         WebCore::SQLiteTransactionInProgressAutoCounter transactionCounter;
 
-        String databasePath = databasePathCapture.string();
         if (!WebCore::makeAllDirectories(WebCore::directoryName(databasePath)))
             return;
 
@@ -128,7 +124,7 @@ void Statistics::initialize(const String& databasePath)
         LOG(NetworkCache, "(NetworkProcess) Network cache statistics database load complete, entries=%lu time=%" PRIi64 "ms", static_cast<size_t>(m_approximateEntryCount), elapsedMS);
 
         if (!m_approximateEntryCount) {
-            bootstrapFromNetworkCache(networkCachePathCapture.string());
+            bootstrapFromNetworkCache(networkCachePath);
 #if !LOG_DISABLED
             elapsedMS = static_cast<int64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - startTime).count());
 #endif
@@ -176,9 +172,8 @@ void Statistics::shrinkIfNeeded()
 
     clear();
 
-    StringCapture networkCachePathCapture(singleton().recordsPath());
-    serialBackgroundIOQueue().dispatch([this, networkCachePathCapture] {
-        bootstrapFromNetworkCache(networkCachePathCapture.string());
+    serialBackgroundIOQueue().dispatch([this, networkCachePath = singleton().recordsPath().isolatedCopy()] {
+        bootstrapFromNetworkCache(networkCachePath);
         LOG(NetworkCache, "(NetworkProcess) statistics cache shrink completed m_approximateEntryCount=%lu", static_cast<size_t>(m_approximateEntryCount));
     });
 }
index ea6e094..ed888ba 100644 (file)
@@ -558,9 +558,8 @@ void Storage::remove(const Key& key)
 
 void Storage::updateFileModificationTime(const String& path)
 {
-    StringCapture filePathCapture(path);
-    serialBackgroundIOQueue().dispatch([filePathCapture] {
-        updateFileModificationTimeIfNeeded(filePathCapture.string());
+    serialBackgroundIOQueue().dispatch([path = path.isolatedCopy()] {
+        updateFileModificationTimeIfNeeded(path);
     });
 }
 
@@ -897,13 +896,9 @@ void Storage::clear(const String& type, std::chrono::system_clock::time_point mo
     if (m_blobFilter)
         m_blobFilter->clear();
     m_approximateRecordsSize = 0;
-
-    // Avoid non-thread safe std::function copies.
-    auto* completionHandlerPtr = completionHandler ? new std::function<void ()>(WTFMove(completionHandler)) : nullptr;
-    StringCapture typeCapture(type);
-    ioQueue().dispatch([this, modifiedSinceTime, completionHandlerPtr, typeCapture] {
+    ioQueue().dispatch([this, modifiedSinceTime, completionHandler = WTFMove(completionHandler), type = type.isolatedCopy()] () mutable {
         auto recordsPath = this->recordsPath();
-        traverseRecordsFiles(recordsPath, typeCapture.string(), [modifiedSinceTime](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) {
+        traverseRecordsFiles(recordsPath, type, [modifiedSinceTime](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) {
             auto filePath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName);
             if (modifiedSinceTime > std::chrono::system_clock::time_point::min()) {
                 auto times = fileTimes(filePath);
@@ -918,10 +913,9 @@ void Storage::clear(const String& type, std::chrono::system_clock::time_point mo
         // This cleans unreferenced blobs.
         m_blobStorage.synchronize();
 
-        if (completionHandlerPtr) {
-            RunLoop::main().dispatch([completionHandlerPtr] {
-                (*completionHandlerPtr)();
-                delete completionHandlerPtr;
+        if (completionHandler) {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler();
             });
         }
     });
index 5fcb5fb..3eb7c22 100644 (file)
@@ -307,11 +307,8 @@ static RefPtr<API::UserContentExtension> createExtension(const String& identifie
 void UserContentExtensionStore::lookupContentExtension(const WTF::String& identifier, std::function<void(RefPtr<API::UserContentExtension>, std::error_code)> completionHandler)
 {
     RefPtr<UserContentExtensionStore> self(this);
-    StringCapture identifierCapture(identifier);
-    StringCapture pathCapture(m_storePath);
-
-    m_readQueue->dispatch([self, identifierCapture, pathCapture, completionHandler] {
-        auto path = constructedPath(pathCapture.string(), identifierCapture.string());
+    m_readQueue->dispatch([self, identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler] {
+        auto path = constructedPath(storePath, identifier);
         
         ContentExtensionMetaData metaData;
         Data fileData;
@@ -329,8 +326,8 @@ void UserContentExtensionStore::lookupContentExtension(const WTF::String& identi
             return;
         }
         
-        RunLoop::main().dispatch([self, identifierCapture, fileData, metaData, completionHandler] {
-            RefPtr<API::UserContentExtension> userContentExtension = createExtension(identifierCapture.string(), metaData, fileData);
+        RunLoop::main().dispatch([self, identifier = identifier.isolatedCopy(), fileData, metaData, completionHandler] {
+            RefPtr<API::UserContentExtension> userContentExtension = createExtension(identifier, metaData, fileData);
             completionHandler(userContentExtension, { });
         });
     });
@@ -339,16 +336,12 @@ void UserContentExtensionStore::lookupContentExtension(const WTF::String& identi
 void UserContentExtensionStore::compileContentExtension(const WTF::String& identifier, WTF::String&& json, std::function<void(RefPtr<API::UserContentExtension>, std::error_code)> completionHandler)
 {
     RefPtr<UserContentExtensionStore> self(this);
-    StringCapture identifierCapture(identifier);
-    StringCapture jsonCapture(WTFMove(json));
-    StringCapture pathCapture(m_storePath);
-
-    m_compileQueue->dispatch([self, identifierCapture, jsonCapture, pathCapture, completionHandler] () mutable {
-        auto path = constructedPath(pathCapture.string(), identifierCapture.string());
+    m_compileQueue->dispatch([self, identifier = identifier.isolatedCopy(), json = json.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler] () mutable {
+        auto path = constructedPath(storePath, identifier);
 
         ContentExtensionMetaData metaData;
         Data fileData;
-        auto error = compiledToFile(jsonCapture.releaseString(), path, metaData, fileData);
+        auto error = compiledToFile(WTFMove(json), path, metaData, fileData);
         if (error) {
             RunLoop::main().dispatch([self, error, completionHandler] {
                 completionHandler(nullptr, error);
@@ -356,8 +349,8 @@ void UserContentExtensionStore::compileContentExtension(const WTF::String& ident
             return;
         }
 
-        RunLoop::main().dispatch([self, identifierCapture, fileData, metaData, completionHandler] {
-            RefPtr<API::UserContentExtension> userContentExtension = createExtension(identifierCapture.string(), metaData, fileData);
+        RunLoop::main().dispatch([self, identifier = identifier.isolatedCopy(), fileData, metaData, completionHandler] {
+            RefPtr<API::UserContentExtension> userContentExtension = createExtension(identifier, metaData, fileData);
             completionHandler(userContentExtension, { });
         });
     });
@@ -366,11 +359,8 @@ void UserContentExtensionStore::compileContentExtension(const WTF::String& ident
 void UserContentExtensionStore::removeContentExtension(const WTF::String& identifier, std::function<void(std::error_code)> completionHandler)
 {
     RefPtr<UserContentExtensionStore> self(this);
-    StringCapture identifierCapture(identifier);
-    StringCapture pathCapture(m_storePath);
-
-    m_removeQueue->dispatch([self, identifierCapture, pathCapture, completionHandler] {
-        auto path = constructedPath(pathCapture.string(), identifierCapture.string());
+    m_removeQueue->dispatch([self, identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler] {
+        auto path = constructedPath(storePath, identifier);
 
         if (!WebCore::deleteFile(path)) {
             RunLoop::main().dispatch([self, completionHandler] {
index 674877a..a658787 100644 (file)
@@ -258,13 +258,11 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
 
     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(fetchOptions, WTFMove(completionHandler)));
 
-    if (dataTypes.contains(WebsiteDataType::DiskCache)) {
-        StringCapture mediaCacheDirectory { m_mediaCacheDirectory };
-        
 #if ENABLE(VIDEO)
+    if (dataTypes.contains(WebsiteDataType::DiskCache)) {
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([fetchOptions, mediaCacheDirectory, callbackAggregator] {
-            HashSet<RefPtr<WebCore::SecurityOrigin>> origins = WebCore::HTMLMediaElement::originsInMediaCache(mediaCacheDirectory.string());
+        m_queue->dispatch([fetchOptions, mediaCacheDirectory = m_mediaCacheDirectory.isolatedCopy(), callbackAggregator] {
+            HashSet<RefPtr<WebCore::SecurityOrigin>> origins = WebCore::HTMLMediaElement::originsInMediaCache(mediaCacheDirectory);
             WebsiteData* websiteData = new WebsiteData;
             
             for (auto& origin : origins) {
@@ -278,8 +276,8 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
                 delete websiteData;
             });
         });
-#endif
     }
+#endif
 
     auto networkProcessAccessType = computeNetworkProcessAccessTypeForDataFetch(dataTypes, !isPersistent());
     if (networkProcessAccessType != ProcessAccessType::None) {
@@ -357,13 +355,10 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
     }
 
     if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
-        StringCapture applicationCacheDirectory { m_applicationCacheDirectory };
-        StringCapture applicationCacheFlatFileSubdirectoryName { m_applicationCacheFlatFileSubdirectoryName };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([fetchOptions, applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName, callbackAggregator] {
-            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory.string(), applicationCacheFlatFileSubdirectoryName.string());
+        m_queue->dispatch([fetchOptions, applicationCacheDirectory = m_applicationCacheDirectory.isolatedCopy(), applicationCacheFlatFileSubdirectoryName = m_applicationCacheFlatFileSubdirectoryName.isolatedCopy(), callbackAggregator] {
+            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName);
 
             WebsiteData* websiteData = new WebsiteData;
 
@@ -386,13 +381,11 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
     }
 
     if (dataTypes.contains(WebsiteDataType::WebSQLDatabases) && isPersistent()) {
-        StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([webSQLDatabaseDirectory, callbackAggregator] {
+        m_queue->dispatch([webSQLDatabaseDirectory = m_webSQLDatabaseDirectory.isolatedCopy(), callbackAggregator] {
             Vector<RefPtr<WebCore::SecurityOrigin>> origins;
-            WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string())->origins(origins);
+            WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory)->origins(origins);
 
             RunLoop::main().dispatch([callbackAggregator, origins]() mutable {
                 WebsiteData websiteData;
@@ -418,12 +411,10 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
 #endif
 
     if (dataTypes.contains(WebsiteDataType::MediaKeys) && isPersistent()) {
-        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([mediaKeysStorageDirectory, callbackAggregator] {
-            auto origins = mediaKeyOrigins(mediaKeysStorageDirectory.string());
+        m_queue->dispatch([mediaKeysStorageDirectory = m_mediaKeysStorageDirectory.isolatedCopy(), callbackAggregator] {
+            auto origins = mediaKeyOrigins(mediaKeysStorageDirectory);
 
             RunLoop::main().dispatch([callbackAggregator, origins]() mutable {
                 WebsiteData websiteData;
@@ -556,20 +547,18 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chr
 
     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
 
-    if (dataTypes.contains(WebsiteDataType::DiskCache)) {
-        StringCapture mediaCacheDirectory { m_mediaCacheDirectory };
-
 #if ENABLE(VIDEO)
+    if (dataTypes.contains(WebsiteDataType::DiskCache)) {
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([modifiedSince, mediaCacheDirectory, callbackAggregator] {
-            WebCore::HTMLMediaElement::clearMediaCache(mediaCacheDirectory.string(), modifiedSince);
+        m_queue->dispatch([modifiedSince, mediaCacheDirectory = m_mediaCacheDirectory.isolatedCopy(), callbackAggregator] {
+            WebCore::HTMLMediaElement::clearMediaCache(mediaCacheDirectory, modifiedSince);
             
             WTF::RunLoop::main().dispatch([callbackAggregator] {
                 callbackAggregator->removePendingCallback();
             });
         });
-#endif
     }
+#endif
 
     auto networkProcessAccessType = computeNetworkProcessAccessTypeForDataRemoval(dataTypes, !isPersistent());
     if (networkProcessAccessType != ProcessAccessType::None) {
@@ -637,13 +626,10 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chr
     }
 
     if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
-        StringCapture applicationCacheDirectory { m_applicationCacheDirectory };
-        StringCapture applicationCacheFlatFileSubdirectoryName { m_applicationCacheFlatFileSubdirectoryName };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName, callbackAggregator] {
-            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory.string(), applicationCacheFlatFileSubdirectoryName.string());
+        m_queue->dispatch([applicationCacheDirectory = m_applicationCacheDirectory.isolatedCopy(), applicationCacheFlatFileSubdirectoryName = m_applicationCacheFlatFileSubdirectoryName.isolatedCopy(), callbackAggregator] {
+            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName);
 
             storage->deleteAllCaches();
 
@@ -654,12 +640,10 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chr
     }
 
     if (dataTypes.contains(WebsiteDataType::WebSQLDatabases) && isPersistent()) {
-        StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([webSQLDatabaseDirectory, callbackAggregator, modifiedSince] {
-            WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string())->deleteDatabasesModifiedSince(modifiedSince);
+        m_queue->dispatch([webSQLDatabaseDirectory = m_webSQLDatabaseDirectory.isolatedCopy(), callbackAggregator, modifiedSince] {
+            WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory)->deleteDatabasesModifiedSince(modifiedSince);
 
             RunLoop::main().dispatch([callbackAggregator] {
                 callbackAggregator->removePendingCallback();
@@ -681,12 +665,10 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chr
 #endif
 
     if (dataTypes.contains(WebsiteDataType::MediaKeys) && isPersistent()) {
-        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
-
         callbackAggregator->addPendingCallback();
 
-        m_queue->dispatch([mediaKeysStorageDirectory, callbackAggregator, modifiedSince] {
-            removeMediaKeys(mediaKeysStorageDirectory.string(), modifiedSince);
+        m_queue->dispatch([mediaKeysStorageDirectory = m_mediaKeysStorageDirectory.isolatedCopy(), callbackAggregator, modifiedSince] {
+            removeMediaKeys(mediaKeysStorageDirectory, modifiedSince);
 
             RunLoop::main().dispatch([callbackAggregator] {
                 callbackAggregator->removePendingCallback();
@@ -799,25 +781,24 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
 
     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
     
+#if ENABLE(VIDEO)
     if (dataTypes.contains(WebsiteDataType::DiskCache)) {
-        StringCapture mediaCacheDirectory { m_mediaCacheDirectory };
         HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
         for (const auto& dataRecord : dataRecords) {
             for (const auto& origin : dataRecord.origins)
                 origins.add(origin);
         }
         
-#if ENABLE(VIDEO)
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([origins, mediaCacheDirectory, callbackAggregator] {
-            WebCore::HTMLMediaElement::clearMediaCacheForOrigins(mediaCacheDirectory.string(), origins);
+        m_queue->dispatch([origins, mediaCacheDirectory = m_mediaCacheDirectory.isolatedCopy(), callbackAggregator] {
+            WebCore::HTMLMediaElement::clearMediaCacheForOrigins(mediaCacheDirectory, origins);
             
             WTF::RunLoop::main().dispatch([callbackAggregator] {
                 callbackAggregator->removePendingCallback();
             });
         });
-#endif
     }
+#endif
     
     auto networkProcessAccessType = computeNetworkProcessAccessTypeForDataRemoval(dataTypes, !isPersistent());
     if (networkProcessAccessType != ProcessAccessType::None) {
@@ -892,9 +873,6 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
     }
 
     if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
-        StringCapture applicationCacheDirectory { m_applicationCacheDirectory };
-        StringCapture applicationCacheFlatFileSubdirectoryName { m_applicationCacheFlatFileSubdirectoryName };
-
         HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
         for (const auto& dataRecord : dataRecords) {
             for (const auto& origin : dataRecord.origins)
@@ -902,8 +880,8 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
         }
 
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([origins, applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName, callbackAggregator] {
-            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory.string(), applicationCacheFlatFileSubdirectoryName.string());
+        m_queue->dispatch([origins, applicationCacheDirectory = m_applicationCacheDirectory.isolatedCopy(), applicationCacheFlatFileSubdirectoryName = m_applicationCacheFlatFileSubdirectoryName.isolatedCopy(), callbackAggregator] {
+            auto storage = WebCore::ApplicationCacheStorage::create(applicationCacheDirectory, applicationCacheFlatFileSubdirectoryName);
 
             for (const auto& origin : origins)
                 storage->deleteCacheForOrigin(*origin);
@@ -915,8 +893,6 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
     }
 
     if (dataTypes.contains(WebsiteDataType::WebSQLDatabases) && isPersistent()) {
-        StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory };
-
         HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
         for (const auto& dataRecord : dataRecords) {
             for (const auto& origin : dataRecord.origins)
@@ -924,8 +900,8 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
         }
 
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([origins, callbackAggregator, webSQLDatabaseDirectory] {
-            auto databaseTracker = WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string());
+        m_queue->dispatch([origins, callbackAggregator, webSQLDatabaseDirectory = m_webSQLDatabaseDirectory.isolatedCopy()] {
+            auto databaseTracker = WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory);
 
             for (const auto& origin : origins)
                 databaseTracker->deleteOrigin(origin.get());
@@ -950,7 +926,6 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
 #endif
 
     if (dataTypes.contains(WebsiteDataType::MediaKeys) && isPersistent()) {
-        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
         HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
         for (const auto& dataRecord : dataRecords) {
             for (const auto& origin : dataRecord.origins)
@@ -958,9 +933,9 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
         }
 
         callbackAggregator->addPendingCallback();
-        m_queue->dispatch([mediaKeysStorageDirectory, callbackAggregator, origins] {
+        m_queue->dispatch([mediaKeysStorageDirectory = m_mediaKeysStorageDirectory.isolatedCopy(), callbackAggregator, origins] {
 
-            removeMediaKeys(mediaKeysStorageDirectory.string(), origins);
+            removeMediaKeys(mediaKeysStorageDirectory, origins);
 
             RunLoop::main().dispatch([callbackAggregator] {
                 callbackAggregator->removePendingCallback();