Title: [274482] trunk/Source/WebCore
Revision
274482
Author
[email protected]
Date
2021-03-16 09:21:02 -0700 (Tue, 16 Mar 2021)

Log Message

Protect DOMFileSystem when hopping to a background thread
https://bugs.webkit.org/show_bug.cgi?id=223246

Reviewed by Chris Dumez.

Make sure to ref when hopping to background thread and hop back to main thread to unref.

* Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::DOMFileSystem::getParent):
(WebCore::DOMFileSystem::getEntry):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274481 => 274482)


--- trunk/Source/WebCore/ChangeLog	2021-03-16 16:05:55 UTC (rev 274481)
+++ trunk/Source/WebCore/ChangeLog	2021-03-16 16:21:02 UTC (rev 274482)
@@ -1,3 +1,16 @@
+2021-03-16  Youenn Fablet  <[email protected]>
+
+        Protect DOMFileSystem when hopping to a background thread
+        https://bugs.webkit.org/show_bug.cgi?id=223246
+
+        Reviewed by Chris Dumez.
+
+        Make sure to ref when hopping to background thread and hop back to main thread to unref.
+
+        * Modules/entriesapi/DOMFileSystem.cpp:
+        (WebCore::DOMFileSystem::getParent):
+        (WebCore::DOMFileSystem::getEntry):
+
 2021-03-16  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK build with TREE_DEBUGGING enabled after r274216

Modified: trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (274481 => 274482)


--- trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2021-03-16 16:05:55 UTC (rev 274481)
+++ trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2021-03-16 16:21:02 UTC (rev 274482)
@@ -270,13 +270,13 @@
     auto virtualPath = resolveRelativeVirtualPath(entry.virtualPath(), "..");
     ASSERT(virtualPath[0] == '/');
     auto fullPath = evaluatePath(virtualPath);
-    m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
+    m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
         auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::Directory);
-        callOnMainThread([this, context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
+        callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
             if (validatedVirtualPath.hasException())
                 completionCallback(validatedVirtualPath.releaseException());
             else
-                completionCallback(FileSystemDirectoryEntry::create(context, *this, validatedVirtualPath.releaseReturnValue()));
+                completionCallback(FileSystemDirectoryEntry::create(context, protectedThis.get(), validatedVirtualPath.releaseReturnValue()));
         });
     });
 }
@@ -311,9 +311,9 @@
         return;
     }
 
-    m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
+    m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
         auto entryType = fileType(fullPath);
-        callOnMainThread([this, context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
+        callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
             if (!entryType) {
                 completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
                 return;
@@ -320,10 +320,10 @@
             }
             switch (entryType.value()) {
             case FileMetadata::Type::Directory:
-                completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, *this, resolvedVirtualPath) });
+                completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
                 break;
             case FileMetadata::Type::File:
-                completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, *this, resolvedVirtualPath) });
+                completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
                 break;
             default:
                 completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to