Progress towards implementing downloads with NetworkSession
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 00:06:02 +0000 (00:06 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 00:06:02 +0000 (00:06 +0000)
commit70c797bf4ffd12f03aa1770b31c998bf177bd327
tree8b931ff793cef6ae54299f9777cb595255511533
parentb02dbf2d8197cd4ef8b94612ad132fee9de8097b
Progress towards implementing downloads with NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=152716

Reviewed by Brady Eidson.

* NetworkProcess/Downloads/Download.h:
* NetworkProcess/Downloads/DownloadID.h:
(WebKit::DownloadID::DownloadID):
(WebKit::DownloadID::operator==):
(WebKit::DownloadID::operator!=):
(WebKit::DownloadID::downloadID):
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
* NetworkProcess/Downloads/DownloadManager.h:
(WebKit::DownloadManager::download):
(WebKit::DownloadManager::isDownloading):
* NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
(WebKit::Download::resume):
(WebKit::Download::platformInvalidate):
(WebKit::Download::platformDidFinish):
(WebKit::Download::start): Deleted.
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
(-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveData:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didFinishDownloadingToURL:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:]):
(-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):

When using NSURLSession, a data task is converted to a download task after the connection has already
been established, the headers have been received, and WebCore looks at the response and decides that
this connection should become a download.  We call the didReceiveResponse to match the behavior of
NSURLDownload, but this could be cleaned up later to match what is actually happening.  We also do not
need to tell the download to start because it has already started.

(WebKit::NetworkSession::dataTaskForIdentifier):
(WebKit::NetworkSession::addDownloadID):
(WebKit::NetworkSession::downloadID):
(WebKit::NetworkSession::takeDownloadID):
(WebKit::NetworkDataTask::NetworkDataTask):

NSURLSessionDownloadTask taskIdentifiers are unique to that NSURLSession, but we have one global DownloadManager
in the NetworkProcess.  We need to have each NetworkSession keep a map of taskIdentifiers to global DownloadID.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/Downloads/Download.h
Source/WebKit2/NetworkProcess/Downloads/DownloadID.h
Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h
Source/WebKit2/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm
Source/WebKit2/NetworkProcess/NetworkSession.h
Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm