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

Changeset 277881 in webkit


Ignore:
Timestamp:
May 21, 2021, 1:20:07 PM (5 years ago)
Author:
Chris Dumez
Message:

[Cocoa] Unable to upload files that are stored in the cloud (without a local copy)
https://bugs.webkit.org/show_bug.cgi?id=226090
<rdar://77775887>

Reviewed by Darin Adler.

Source/WebKit:

Allow the network process to load / read dataless files stored in the cloud by allowing
the process to materialize such files. I initially only allowed the AsyncFileStream
thread to materialize the dataless files and this was enough to make the file upload
use cases work. However, I noticed that drag and dropping such file in the Safari URL
bar would fail loading, which I think is bad user experience. As a result, I have
decided to allow the materializing at network process level.

I have verified manually that I can now upload such dataless files via either file
picker or drag and drop (used https://blueimp.github.io/jQuery-File-Upload/). I have
also verified that drag and dropping such a file in the Safari URL bar successfuly
loads that file.

  • NetworkProcess/cocoa/NetworkProcessCocoa.mm:

(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):

Source/WTF:

Add FileSystem API to allow/disallow the materializing of dataless files stored
in the cloud, at process or thread level.

  • wtf/FileSystem.h:
  • wtf/cocoa/FileSystemCocoa.mm:

(WTF::FileSystemImpl::toIOPolicyScope):
(WTF::FileSystemImpl::setAllowsMaterializingDatalessFiles):
(WTF::FileSystemImpl::allowsMaterializingDatalessFiles):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r277880 r277881  
     12021-05-21  Chris Dumez  <cdumez@apple.com>
     2
     3        [Cocoa] Unable to upload files that are stored in the cloud (without a local copy)
     4        https://bugs.webkit.org/show_bug.cgi?id=226090
     5        <rdar://77775887>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add FileSystem API to allow/disallow the materializing of dataless files stored
     10        in the cloud, at process or thread level.
     11
     12        * wtf/FileSystem.h:
     13        * wtf/cocoa/FileSystemCocoa.mm:
     14        (WTF::FileSystemImpl::toIOPolicyScope):
     15        (WTF::FileSystemImpl::setAllowsMaterializingDatalessFiles):
     16        (WTF::FileSystemImpl::allowsMaterializingDatalessFiles):
     17
    1182021-05-21  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WTF/wtf/FileSystem.h

    r277535 r277881  
    197197#if PLATFORM(COCOA)
    198198WTF_EXPORT_PRIVATE NSString *createTemporaryDirectory(NSString *directoryPrefix);
     199
     200// Allow reading cloud files with no local copy.
     201enum class PolicyScope : uint8_t { Process, Thread };
     202WTF_EXPORT_PRIVATE bool setAllowsMaterializingDatalessFiles(bool, PolicyScope);
     203WTF_EXPORT_PRIVATE Optional<bool> allowsMaterializingDatalessFiles(PolicyScope);
    199204#endif
    200205
  • trunk/Source/WTF/wtf/cocoa/FileSystemCocoa.mm

    r277498 r277881  
    151151}
    152152
     153static int toIOPolicyScope(PolicyScope scope)
     154{
     155    switch (scope) {
     156    case PolicyScope::Process:
     157        return IOPOL_SCOPE_PROCESS;
     158    case PolicyScope::Thread:
     159        return IOPOL_SCOPE_THREAD;
     160    }
     161}
     162
     163bool setAllowsMaterializingDatalessFiles(bool allow, PolicyScope scope)
     164{
     165    if (setiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, toIOPolicyScope(scope), allow ? IOPOL_MATERIALIZE_DATALESS_FILES_ON : IOPOL_MATERIALIZE_DATALESS_FILES_OFF) == -1) {
     166        LOG_ERROR("FileSystem::setAllowsMaterializingDatalessFiles(%d): setiopolicy_np call failed, errno: %d", allow, errno);
     167        return false;
     168    }
     169    return true;
     170}
     171
     172Optional<bool> allowsMaterializingDatalessFiles(PolicyScope scope)
     173{
     174    int ret = getiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, toIOPolicyScope(scope));
     175    if (ret == IOPOL_MATERIALIZE_DATALESS_FILES_ON)
     176        return true;
     177    if (ret == IOPOL_MATERIALIZE_DATALESS_FILES_OFF)
     178        return false;
     179    LOG_ERROR("FileSystem::allowsMaterializingDatalessFiles(): getiopolicy_np call failed, errno: %d", errno);
     180    return WTF::nullopt;
     181}
     182
    153183#if PLATFORM(IOS_FAMILY)
    154184bool isSafeToUseMemoryMapForPath(const String& path)
  • trunk/Source/WebKit/ChangeLog

    r277879 r277881  
     12021-05-21  Chris Dumez  <cdumez@apple.com>
     2
     3        [Cocoa] Unable to upload files that are stored in the cloud (without a local copy)
     4        https://bugs.webkit.org/show_bug.cgi?id=226090
     5        <rdar://77775887>
     6
     7        Reviewed by Darin Adler.
     8
     9        Allow the network process to load / read dataless files stored in the cloud by allowing
     10        the process to materialize such files. I initially only allowed the AsyncFileStream
     11        thread to materialize the dataless files and this was enough to make the file upload
     12        use cases work. However, I noticed that drag and dropping such file in the Safari URL
     13        bar would fail loading, which I think is bad user experience. As a result, I have
     14        decided to allow the materializing at network process level.
     15
     16        I have verified manually that I can now upload such dataless files via either file
     17        picker or drag and drop (used https://blueimp.github.io/jQuery-File-Upload/). I have
     18        also verified that drag and dropping such a file in the Safari URL bar successfuly
     19        loads that file.
     20
     21        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     22        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
     23
    1242021-05-21  Brent Fulgham  <bfulgham@apple.com>
    225
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r275013 r277881  
    4646#import <wtf/BlockPtr.h>
    4747#import <wtf/CallbackAggregator.h>
     48#import <wtf/FileSystem.h>
    4849#import <wtf/ProcessPrivilege.h>
    4950#import <wtf/RetainPtr.h>
     
    9091    setSharedHTTPCookieStorage(parameters.uiProcessCookieStorageIdentifier);
    9192#endif
     93
     94    // Allow the network process to materialize files stored in the cloud so that loading/reading such files actually succeeds.
     95    FileSystem::setAllowsMaterializingDatalessFiles(true, FileSystem::PolicyScope::Process);
    9296
    9397    // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
Note: See TracChangeset for help on using the changeset viewer.