Title: [206913] trunk/Source/WebKit2
Revision
206913
Author
carlo...@webkit.org
Date
2016-10-07 09:32:42 -0700 (Fri, 07 Oct 2016)

Log Message

Network Session: Allow NetworkDataTask decide what to do when override is allowed for a download
https://bugs.webkit.org/show_bug.cgi?id=163010

Reviewed by Alex Christensen.

Current code always deletes the file before starting a download when allow override is True. In soup backend we
use glib API that takes care of it and tries to ensure that the original file is not deleted if the new file
creation fails for whatever reason.

* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::continueDecidePendingDownloadDestination): Pass allowOverride to setPendingDownloadLocation().
* NetworkProcess/NetworkDataTask.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTask::setPendingDownloadLocation): Delete the destination file if exists and allowOverride
is True.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (206912 => 206913)


--- trunk/Source/WebKit2/ChangeLog	2016-10-07 15:10:46 UTC (rev 206912)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-07 16:32:42 UTC (rev 206913)
@@ -1,3 +1,21 @@
+2016-10-07  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Network Session: Allow NetworkDataTask decide what to do when override is allowed for a download
+        https://bugs.webkit.org/show_bug.cgi?id=163010
+
+        Reviewed by Alex Christensen.
+
+        Current code always deletes the file before starting a download when allow override is True. In soup backend we
+        use glib API that takes care of it and tries to ensure that the original file is not deleted if the new file
+        creation fails for whatever reason.
+
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::continueDecidePendingDownloadDestination): Pass allowOverride to setPendingDownloadLocation().
+        * NetworkProcess/NetworkDataTask.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTask::setPendingDownloadLocation): Delete the destination file if exists and allowOverride
+        is True.
+
 2016-10-07  Tomas Popela  <tpop...@redhat.com>
 
         [GTK] UIProcess crashes when using Japanese IM

Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp (206912 => 206913)


--- trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp	2016-10-07 15:10:46 UTC (rev 206912)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp	2016-10-07 16:32:42 UTC (rev 206913)
@@ -128,11 +128,7 @@
         if (!networkDataTask || !completionHandler)
             return;
 
-        networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle);
-
-        if (allowOverwrite && fileExists(destination))
-            deleteFile(destination);
-
+        networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle, allowOverwrite);
         completionHandler(PolicyDownload);
 
         ASSERT(!m_downloadsAfterDestinationDecided.contains(downloadID));

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h (206912 => 206913)


--- trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h	2016-10-07 15:10:46 UTC (rev 206912)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h	2016-10-07 16:32:42 UTC (rev 206913)
@@ -121,7 +121,7 @@
         ASSERT(!m_pendingDownload);
         m_pendingDownload = &pendingDownload;
     }
-    void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&);
+    void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&, bool allowOverwrite);
     const String& pendingDownloadLocation() { return m_pendingDownloadLocation; }
 
     const WebCore::ResourceRequest& firstRequest() const { return m_firstRequest; }

Modified: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (206912 => 206913)


--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2016-10-07 15:10:46 UTC (rev 206912)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2016-10-07 16:32:42 UTC (rev 206913)
@@ -36,6 +36,7 @@
 #import "WebCoreArgumentCoders.h"
 #import <WebCore/AuthenticationChallenge.h>
 #import <WebCore/CFNetworkSPI.h>
+#import <WebCore/FileSystem.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/ResourceRequest.h>
 #import <wtf/MainThread.h>
@@ -268,7 +269,7 @@
     ASSERT_NOT_REACHED();
 }
 
-void NetworkDataTask::setPendingDownloadLocation(const WTF::String& filename, const SandboxExtension::Handle& sandboxExtensionHandle)
+void NetworkDataTask::setPendingDownloadLocation(const WTF::String& filename, const SandboxExtension::Handle& sandboxExtensionHandle, bool allowOverwrite)
 {
     ASSERT(!m_sandboxExtension);
     m_sandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
@@ -277,6 +278,9 @@
 
     m_pendingDownloadLocation = filename;
     m_task.get()._pathToDownloadTaskFile = filename;
+
+    if (allowOverwrite && WebCore::fileExists(filename))
+        WebCore::deleteFile(filename);
 }
 
 bool NetworkDataTask::tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge& challenge, const ChallengeCompletionHandler& completionHandler)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to