Title: [278503] branches/safari-611-branch/Source

Diff

Modified: branches/safari-611-branch/Source/WTF/ChangeLog (278502 => 278503)


--- branches/safari-611-branch/Source/WTF/ChangeLog	2021-06-04 22:45:31 UTC (rev 278502)
+++ branches/safari-611-branch/Source/WTF/ChangeLog	2021-06-04 22:45:35 UTC (rev 278503)
@@ -1,3 +1,60 @@
+2021-05-25  Alan Coon  <[email protected]>
+
+Cherry-pick r277881. rdar://78467158 
+
+    [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):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-21  Chris Dumez  <[email protected]>
+
+            [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.
+
+            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):
+
 2021-05-20  Alan Coon  <[email protected]>
 
         Cherry-pick r276788. rdar://problem/78264378

Modified: branches/safari-611-branch/Source/WTF/wtf/FileSystem.h (278502 => 278503)


--- branches/safari-611-branch/Source/WTF/wtf/FileSystem.h	2021-06-04 22:45:31 UTC (rev 278502)
+++ branches/safari-611-branch/Source/WTF/wtf/FileSystem.h	2021-06-04 22:45:35 UTC (rev 278503)
@@ -195,6 +195,12 @@
 
 #if PLATFORM(COCOA)
 WTF_EXPORT_PRIVATE NSString *createTemporaryDirectory(NSString *directoryPrefix);
+
+// Allow reading cloud files with no local copy.
+enum class PolicyScope : uint8_t { Process, Thread };
+WTF_EXPORT_PRIVATE bool setAllowsMaterializingDatalessFiles(bool, PolicyScope);
+WTF_EXPORT_PRIVATE Optional<bool> allowsMaterializingDatalessFiles(PolicyScope);
+
 WTF_EXPORT_PRIVATE bool deleteNonEmptyDirectory(const String&);
 #endif
 

Modified: branches/safari-611-branch/Source/WTF/wtf/cocoa/FileSystemCocoa.mm (278502 => 278503)


--- branches/safari-611-branch/Source/WTF/wtf/cocoa/FileSystemCocoa.mm	2021-06-04 22:45:31 UTC (rev 278502)
+++ branches/safari-611-branch/Source/WTF/wtf/cocoa/FileSystemCocoa.mm	2021-06-04 22:45:35 UTC (rev 278503)
@@ -181,8 +181,37 @@
 bool deleteNonEmptyDirectory(const String& path)
 {
     return [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
+
+static int toIOPolicyScope(PolicyScope scope)
+{
+    switch (scope) {
+    case PolicyScope::Process:
+        return IOPOL_SCOPE_PROCESS;
+    case PolicyScope::Thread:
+        return IOPOL_SCOPE_THREAD;
+    }
 }
 
+bool setAllowsMaterializingDatalessFiles(bool allow, PolicyScope scope)
+{
+    if (setiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, toIOPolicyScope(scope), allow ? IOPOL_MATERIALIZE_DATALESS_FILES_ON : IOPOL_MATERIALIZE_DATALESS_FILES_OFF) == -1) {
+        LOG_ERROR("FileSystem::setAllowsMaterializingDatalessFiles(%d): setiopolicy_np call failed, errno: %d", allow, errno);
+        return false;
+    }
+    return true;
+}
+
+Optional<bool> allowsMaterializingDatalessFiles(PolicyScope scope)
+{
+    int ret = getiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, toIOPolicyScope(scope));
+    if (ret == IOPOL_MATERIALIZE_DATALESS_FILES_ON)
+        return true;
+    if (ret == IOPOL_MATERIALIZE_DATALESS_FILES_OFF)
+        return false;
+    LOG_ERROR("FileSystem::allowsMaterializingDatalessFiles(): getiopolicy_np call failed, errno: %d", errno);
+    return WTF::nullopt;
+}
+
 #if PLATFORM(IOS_FAMILY)
 bool isSafeToUseMemoryMapForPath(const String& path)
 {

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (278502 => 278503)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-06-04 22:45:31 UTC (rev 278502)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-06-04 22:45:35 UTC (rev 278503)
@@ -1,3 +1,66 @@
+2021-05-25  Alan Coon  <[email protected]>
+
+Cherry-pick r277881. rdar://problem/78467158
+
+    [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):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-21  Chris Dumez  <[email protected]>
+
+            [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.
+
+            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):
+
 2021-03-22  Russell Epstein  <[email protected]>
 
 Cherry-pick r274746. rdar://problem/76366123

Modified: branches/safari-611-branch/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (278502 => 278503)


--- branches/safari-611-branch/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2021-06-04 22:45:31 UTC (rev 278502)
+++ branches/safari-611-branch/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2021-06-04 22:45:35 UTC (rev 278503)
@@ -45,6 +45,7 @@
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/CallbackAggregator.h>
+#import <wtf/FileSystem.h>
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
@@ -93,6 +94,9 @@
     setSharedHTTPCookieStorage(parameters.uiProcessCookieStorageIdentifier);
 #endif
 
+    // Allow the network process to materialize files stored in the cloud so that loading/reading such files actually succeeds.
+    FileSystem::setAllowsMaterializingDatalessFiles(true, FileSystem::PolicyScope::Process);
+
     // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
     // - memory cache size passed from UI process is always ignored;
     // - disk cache size passed from UI process is effectively a minimum size.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to