Changeset 206913 in webkit


Ignore:
Timestamp:
Oct 7, 2016 9:32:42 AM (7 years ago)
Author:
Carlos Garcia Campos
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.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r206909 r206913  
     12016-10-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Network Session: Allow NetworkDataTask decide what to do when override is allowed for a download
     4        https://bugs.webkit.org/show_bug.cgi?id=163010
     5
     6        Reviewed by Alex Christensen.
     7
     8        Current code always deletes the file before starting a download when allow override is True. In soup backend we
     9        use glib API that takes care of it and tries to ensure that the original file is not deleted if the new file
     10        creation fails for whatever reason.
     11
     12        * NetworkProcess/Downloads/DownloadManager.cpp:
     13        (WebKit::DownloadManager::continueDecidePendingDownloadDestination): Pass allowOverride to setPendingDownloadLocation().
     14        * NetworkProcess/NetworkDataTask.h:
     15        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
     16        (WebKit::NetworkDataTask::setPendingDownloadLocation): Delete the destination file if exists and allowOverride
     17        is True.
     18
    1192016-10-07  Tomas Popela  <tpopela@redhat.com>
    220
  • trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp

    r206583 r206913  
    129129            return;
    130130
    131         networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle);
    132 
    133         if (allowOverwrite && fileExists(destination))
    134             deleteFile(destination);
    135 
     131        networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle, allowOverwrite);
    136132        completionHandler(PolicyDownload);
    137133
  • trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h

    r206355 r206913  
    122122        m_pendingDownload = &pendingDownload;
    123123    }
    124     void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&);
     124    void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&, bool allowOverwrite);
    125125    const String& pendingDownloadLocation() { return m_pendingDownloadLocation; }
    126126
  • trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r206355 r206913  
    3737#import <WebCore/AuthenticationChallenge.h>
    3838#import <WebCore/CFNetworkSPI.h>
     39#import <WebCore/FileSystem.h>
    3940#import <WebCore/NetworkStorageSession.h>
    4041#import <WebCore/ResourceRequest.h>
     
    269270}
    270271
    271 void NetworkDataTask::setPendingDownloadLocation(const WTF::String& filename, const SandboxExtension::Handle& sandboxExtensionHandle)
     272void NetworkDataTask::setPendingDownloadLocation(const WTF::String& filename, const SandboxExtension::Handle& sandboxExtensionHandle, bool allowOverwrite)
    272273{
    273274    ASSERT(!m_sandboxExtension);
     
    278279    m_pendingDownloadLocation = filename;
    279280    m_task.get()._pathToDownloadTaskFile = filename;
     281
     282    if (allowOverwrite && WebCore::fileExists(filename))
     283        WebCore::deleteFile(filename);
    280284}
    281285
Note: See TracChangeset for help on using the changeset viewer.