Progress towards implementing downloads with NetworkSession
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jan 2016 21:28:42 +0000 (21:28 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jan 2016 21:28:42 +0000 (21:28 +0000)
commit8da5281252b81a98743a80912b94c324f9d821a6
tree64b10411f11e0d8bc431a7ca2df297e2f04e44b3
parent630c3e6cbdda17a8ac945c5ac3e10475c399b824
Progress towards implementing downloads with NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=152760

Reviewed by Brady Eidson.

* NetworkProcess/Downloads/Download.cpp:
(WebKit::Download::Download):
There's no need to store the unused NetworkSession&.
(WebKit::Download::didStart):
(WebKit::Download::didReceiveAuthenticationChallenge):
Downloads with NetworkSession are NetworkLoads until the response is received, which is after authentication
challenges are handled by NetworkLoad's code.
(WebKit::Download::didReceiveResponse):
* NetworkProcess/Downloads/Download.h:
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
Create a PendingDownload, which is basically a NetworkLoad that knows that it will become a Download
when the response is received, regardless of whether or not there is a Content-Disposition header.
(WebKit::DownloadManager::dataTaskBecameDownloadTask):
* NetworkProcess/Downloads/DownloadManager.h:
* NetworkProcess/Downloads/PendingDownload.h: Added.
(WebKit::PendingDownload::PendingDownload):
Added a new NetworkLoadClient for requests that will become downloads.
A PendingDownload contains a NetworkLoad so we can always keep them together
and so it can handle setting its pending download id.
* WebKit2.xcodeproj/project.pbxproj:
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::NetworkLoad):
Avoid dereferencing a pointer if the NetworkSession hadn't been created when a NetworkLoad starts.
This shouldn't be possible, but it's good to not assume that all pointers are non-null.
(WebKit::NetworkLoad::cancel):
Add a null check in case the constructor doesn't make m_task.
(WebKit::NetworkLoad::convertTaskToDownload):
(WebKit::NetworkLoad::setPendingDownloadID):
Added for downloads that start with startDownload.  The pending DownloadID is used to indicate that
this request should always become a download, regardless of whether or not the response has a
Content-Disposition header.
(WebKit::NetworkLoad::willPerformHTTPRedirection):
(WebKit::NetworkLoad::didReceiveResponse):
* NetworkProcess/NetworkLoad.h:
There's no need to store a DownloadID here.  It's stored in the NetworkDataTask (m_task).
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkDataTask::client):
(WebKit::NetworkDataTask::pendingDownloadID):
(WebKit::NetworkDataTask::setPendingDownloadID):
(WebKit::NetworkDataTask::downloadID): Deleted.
(WebKit::NetworkDataTask::setDownloadID): Deleted.
Renamed downloadID and setDownloadID to pendingDownloadID and setPendingDownloadID, respectively,
to indicate their use.  They are not the current downloadID, but they are the downloadID of the download
that will happen once the response is received and PolicyDownload will be returned in the completion handler.
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):
Call dataTaskBecameDownloadTask after didBecomeDownload because the networkDataTask is deleted by removing it
from m_pendingDownloads in dataTaskBecameDownloadTask.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/Downloads/Download.cpp
Source/WebKit2/NetworkProcess/Downloads/Download.h
Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h
Source/WebKit2/NetworkProcess/Downloads/PendingDownload.h [new file with mode: 0644]
Source/WebKit2/NetworkProcess/NetworkLoad.cpp
Source/WebKit2/NetworkProcess/NetworkLoad.h
Source/WebKit2/NetworkProcess/NetworkSession.h
Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj