⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 274482 in webkit


Ignore:
Timestamp:
Mar 16, 2021, 9:21:02 AM (6 years ago)
Author:
youenn@apple.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r274480 r274482  
     12021-03-16  Youenn Fablet  <youenn@apple.com>
     2
     3        Protect DOMFileSystem when hopping to a background thread
     4        https://bugs.webkit.org/show_bug.cgi?id=223246
     5
     6        Reviewed by Chris Dumez.
     7
     8        Make sure to ref when hopping to background thread and hop back to main thread to unref.
     9
     10        * Modules/entriesapi/DOMFileSystem.cpp:
     11        (WebCore::DOMFileSystem::getParent):
     12        (WebCore::DOMFileSystem::getEntry):
     13
    1142021-03-16  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp

    r266168 r274482  
    271271    ASSERT(virtualPath[0] == '/');
    272272    auto fullPath = evaluatePath(virtualPath);
    273     m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
     273    m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
    274274        auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::Directory);
    275         callOnMainThread([this, context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
     275        callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
    276276            if (validatedVirtualPath.hasException())
    277277                completionCallback(validatedVirtualPath.releaseException());
    278278            else
    279                 completionCallback(FileSystemDirectoryEntry::create(context, *this, validatedVirtualPath.releaseReturnValue()));
     279                completionCallback(FileSystemDirectoryEntry::create(context, protectedThis.get(), validatedVirtualPath.releaseReturnValue()));
    280280        });
    281281    });
    … …  
    312312    }
    313313
    314     m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
     314    m_workQueue->dispatch([protectedThis = makeRef(*this), context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
    315315        auto entryType = fileType(fullPath);
    316         callOnMainThread([this, context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
     316        callOnMainThread([protectedThis = WTFMove(protectedThis), context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
    317317            if (!entryType) {
    318318                completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
    … …  
    321321            switch (entryType.value()) {
    322322            case FileMetadata::Type::Directory:
    323                 completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, *this, resolvedVirtualPath) });
     323                completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
    324324                break;
    325325            case FileMetadata::Type::File:
    326                 completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, *this, resolvedVirtualPath) });
     326                completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, protectedThis.get(), resolvedVirtualPath) });
    327327                break;
    328328            default:
Note: See TracChangeset for help on using the changeset viewer.