Changeset 196984 in webkit
- Timestamp:
- Feb 23, 2016, 11:13:18 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 15 edited
-
ChangeLog (modified) (1 diff)
-
NetworkProcess/Downloads/Download.cpp (modified) (3 diffs)
-
NetworkProcess/Downloads/Download.h (modified) (3 diffs)
-
NetworkProcess/Downloads/DownloadManager.cpp (modified) (2 diffs)
-
NetworkProcess/Downloads/DownloadManager.h (modified) (3 diffs)
-
NetworkProcess/NetworkDataTask.h (modified) (6 diffs)
-
NetworkProcess/NetworkLoad.cpp (modified) (3 diffs)
-
NetworkProcess/NetworkProcess.cpp (modified) (3 diffs)
-
NetworkProcess/NetworkProcess.h (modified) (3 diffs)
-
NetworkProcess/NetworkProcess.messages.in (modified) (1 diff)
-
NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (modified) (8 diffs)
-
NetworkProcess/cocoa/NetworkSessionCocoa.mm (modified) (8 diffs)
-
UIProcess/Downloads/DownloadProxy.cpp (modified) (2 diffs)
-
UIProcess/Downloads/DownloadProxy.h (modified) (3 diffs)
-
UIProcess/Downloads/DownloadProxy.messages.in (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r196980 r196984 1 2016-02-23 Alex Christensen <achristensen@webkit.org> 2 3 Implement downloads with NetworkSession 4 https://bugs.webkit.org/show_bug.cgi?id=154473 5 6 Reviewed by Brady Eidson. 7 8 * NetworkProcess/Downloads/Download.cpp: 9 (WebKit::Download::~Download): 10 (WebKit::Download::didStart): 11 (WebKit::Download::shouldDecodeSourceDataOfMIMEType): 12 (WebKit::Download::decideDestinationWithSuggestedFilename): 13 (WebKit::Download::didCreateDestination): 14 * NetworkProcess/Downloads/Download.h: 15 (WebKit::Download::downloadID): 16 (WebKit::Download::setSandboxExtension): 17 * NetworkProcess/Downloads/DownloadManager.cpp: 18 (WebKit::DownloadManager::startDownload): 19 (WebKit::DownloadManager::dataTaskBecameDownloadTask): 20 (WebKit::DownloadManager::continueCanAuthenticateAgainstProtectionSpace): 21 (WebKit::DownloadManager::continueWillSendRequest): 22 (WebKit::DownloadManager::willDecidePendingDownloadDestination): 23 (WebKit::DownloadManager::continueDecidePendingDownloadDestination): 24 (WebKit::DownloadManager::convertHandleToDownload): 25 * NetworkProcess/Downloads/DownloadManager.h: 26 * NetworkProcess/NetworkDataTask.h: 27 (WebKit::NetworkDataTask::clearClient): 28 29 NetworkDataTasks can now outlive their client, so we need to make client a pointer 30 with the ability to be nulled from the client's destructor. 31 32 (WebKit::NetworkDataTask::pendingDownloadID): 33 (WebKit::NetworkDataTask::pendingDownload): 34 (WebKit::NetworkDataTask::setPendingDownload): 35 (WebKit::NetworkDataTask::pendingDownloadLocation): 36 (WebKit::NetworkDataTask::client): Deleted. 37 * NetworkProcess/NetworkLoad.cpp: 38 (WebKit::NetworkLoad::~NetworkLoad): 39 (WebKit::NetworkLoad::convertTaskToDownload): 40 (WebKit::NetworkLoad::setPendingDownloadID): 41 (WebKit::NetworkLoad::didReceiveResponseNetworkSession): 42 43 Don't call the didReceiveResponse completion handler immediately when we know we are 44 going to turn the load into a download. Instead, save the completion handler until 45 after we have determined the download destination and set it in the NetworkDataTask. 46 47 * NetworkProcess/NetworkProcess.cpp: 48 (WebKit::NetworkProcess::continueWillSendRequest): 49 (WebKit::NetworkProcess::findPendingDownloadLocation): 50 (WebKit::NetworkProcess::continueDecidePendingDownloadDestination): 51 (WebKit::NetworkProcess::setCacheModel): 52 * NetworkProcess/NetworkProcess.h: 53 * NetworkProcess/NetworkProcess.messages.in: 54 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 55 (WebKit::NetworkDataTask::NetworkDataTask): 56 (WebKit::NetworkDataTask::~NetworkDataTask): 57 (WebKit::NetworkDataTask::didSendData): 58 (WebKit::NetworkDataTask::didReceiveChallenge): 59 (WebKit::NetworkDataTask::didCompleteWithError): 60 (WebKit::NetworkDataTask::didReceiveResponse): 61 (WebKit::NetworkDataTask::didReceiveData): 62 (WebKit::NetworkDataTask::didBecomeDownload): 63 (WebKit::NetworkDataTask::willPerformHTTPRedirection): 64 (WebKit::NetworkDataTask::scheduleFailure): 65 (WebKit::NetworkDataTask::failureTimerFired): 66 (WebKit::NetworkDataTask::findPendingDownloadLocation): 67 (WebKit::NetworkDataTask::setPendingDownloadLocation): 68 (WebKit::NetworkDataTask::tryPasswordBasedAuthentication): 69 (WebKit::NetworkDataTask::transferSandboxExtensionToDownload): 70 (WebKit::NetworkDataTask::currentRequest): 71 (WebKit::NetworkDataTask::cancel): 72 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 73 (-[WKNetworkSessionDelegate URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]): 74 (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]): 75 (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]): 76 (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]): 77 78 This delegate callback is used for downloads, too. 79 80 (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): 81 (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveData:]): 82 (-[WKNetworkSessionDelegate URLSession:downloadTask:didFinishDownloadingToURL:]): 83 (-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]): 84 85 Call didCreateDestination now, which is after the file has been opened on the disk. 86 A DownloadProxy::DidStart message is now sent from NetworkProcess::findPendingDownloadLocation before 87 we ask the UIProcess where the download should end up on disk. 88 Null check the NetworkDataTask's client before using it because it is now a pointer that could be null. 89 90 * UIProcess/Downloads/DownloadProxy.cpp: 91 (WebKit::DownloadProxy::shouldDecodeSourceDataOfMIMEType): 92 (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync): 93 (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename): 94 (WebKit::DownloadProxy::didCreateDestination): 95 * UIProcess/Downloads/DownloadProxy.h: 96 * UIProcess/Downloads/DownloadProxy.messages.in: 97 1 98 2016-02-23 Brian Burg <bburg@apple.com> 2 99 -
trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp
r194718 r196984 67 67 } 68 68 69 #if USE(NETWORK_SESSION) 70 void Download::didStart(const ResourceRequest& request) 71 { 72 send(Messages::DownloadProxy::DidStart(request)); 73 } 74 #else 69 #if !USE(NETWORK_SESSION) 75 70 void Download::didStart() 76 71 { … … 105 100 } 106 101 102 #if !USE(NETWORK_SESSION) 107 103 String Download::decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite) 108 104 { … … 118 114 return destination; 119 115 } 116 #endif 120 117 121 118 void Download::didCreateDestination(const String& path) -
trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h
r196600 r196984 83 83 ~Download(); 84 84 85 #if USE(NETWORK_SESSION) && PLATFORM(COCOA) 86 void dataTaskDidBecomeDownloadTask(const NetworkSession&, RetainPtr<NSURLSessionDownloadTask>&&); 87 #else 85 #if !USE(NETWORK_SESSION) 88 86 void start(); 89 87 void startWithHandle(WebCore::ResourceHandle*, const WebCore::ResourceResponse&); … … 95 93 96 94 #if USE(NETWORK_SESSION) 97 void didStart(const WebCore::ResourceRequest&);95 void setSandboxExtension(RefPtr<SandboxExtension>&& sandboxExtension) { m_sandboxExtension = WTFMove(sandboxExtension); } 98 96 #else 99 97 void didStart(); … … 103 101 void didReceiveData(uint64_t length); 104 102 bool shouldDecodeSourceDataOfMIMEType(const String& mimeType); 103 #if !USE(NETWORK_SESSION) 105 104 String decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite); 105 #endif 106 106 void didCreateDestination(const String& path); 107 107 void didFinish(); -
trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp
r195357 r196984 66 66 67 67 #if USE(NETWORK_SESSION) 68 std:: unique_ptr<PendingDownload> DownloadManager::dataTaskBecameDownloadTask(DownloadID downloadID, std::unique_ptr<Download>&& download)68 std::pair<RefPtr<NetworkDataTask>, std::unique_ptr<PendingDownload>> DownloadManager::dataTaskBecameDownloadTask(DownloadID downloadID, std::unique_ptr<Download>&& download) 69 69 { 70 70 // This is needed for downloads started with startDownload, otherwise it will return nullptr. 71 71 auto pendingDownload = m_pendingDownloads.take(downloadID); 72 72 73 // This is needed for downloads started with convertTaskToDownload, otherwise it will return nullptr. 74 auto downloadAfterLocationDecided = m_downloadsAfterDestinationDecided.take(downloadID); 75 76 ASSERT(!!pendingDownload != !!downloadAfterLocationDecided); 77 73 78 m_downloads.add(downloadID, WTFMove(download)); 74 return pendingDownload;79 return std::make_pair(WTFMove(downloadAfterLocationDecided), WTFMove(pendingDownload)); 75 80 } 76 81 … … 89 94 if (pendingDownload) 90 95 pendingDownload->continueWillSendRequest(request); 96 } 97 98 void DownloadManager::willDecidePendingDownloadDestination(NetworkDataTask& networkDataTask, ResponseCompletionHandler completionHandler) 99 { 100 auto addResult = m_downloadsWaitingForDestination.set(networkDataTask.pendingDownloadID(), std::make_pair<RefPtr<NetworkDataTask>, ResponseCompletionHandler>(&networkDataTask, WTFMove(completionHandler))); 101 ASSERT_UNUSED(addResult, addResult.isNewEntry); 102 } 103 104 void DownloadManager::continueDecidePendingDownloadDestination(DownloadID downloadID, String destination, const SandboxExtension::Handle& sandboxExtensionHandle) 105 { 106 auto pair = m_downloadsWaitingForDestination.take(downloadID); 107 auto networkDataTask = pair.first; 108 auto completionHandler = pair.second; 109 if (!networkDataTask || !completionHandler) { 110 ASSERT_NOT_REACHED(); 111 return; 112 } 113 networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle); 114 completionHandler(PolicyDownload); 115 116 ASSERT(!m_downloadsAfterDestinationDecided.contains(downloadID)); 117 m_downloadsAfterDestinationDecided.set(downloadID, networkDataTask); 91 118 } 92 119 #else -
trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h
r195357 r196984 28 28 29 29 #include "DownloadID.h" 30 #include "NetworkDataTask.h" 30 31 #include "PendingDownload.h" 31 32 #include "SandboxExtension.h" … … 73 74 void startDownload(WebCore::SessionID, DownloadID, const WebCore::ResourceRequest&); 74 75 #if USE(NETWORK_SESSION) 75 std:: unique_ptr<PendingDownload> dataTaskBecameDownloadTask(DownloadID, std::unique_ptr<Download>&&);76 std::pair<RefPtr<NetworkDataTask>, std::unique_ptr<PendingDownload>> dataTaskBecameDownloadTask(DownloadID, std::unique_ptr<Download>&&); 76 77 void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate); 77 78 void continueWillSendRequest(DownloadID, const WebCore::ResourceRequest&); 79 void willDecidePendingDownloadDestination(NetworkDataTask&, ResponseCompletionHandler); 80 void continueDecidePendingDownloadDestination(DownloadID, String destination, const SandboxExtension::Handle&); 78 81 #else 79 82 void convertHandleToDownload(DownloadID, WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); … … 100 103 #if USE(NETWORK_SESSION) 101 104 HashMap<DownloadID, std::unique_ptr<PendingDownload>> m_pendingDownloads; 105 HashMap<DownloadID, std::pair<RefPtr<NetworkDataTask>, ResponseCompletionHandler>> m_downloadsWaitingForDestination; 106 HashMap<DownloadID, RefPtr<NetworkDataTask>> m_downloadsAfterDestinationDecided; 102 107 #endif 103 108 HashMap<DownloadID, std::unique_ptr<Download>> m_downloads; -
trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h
r196671 r196984 27 27 #define NetworkDataTask_h 28 28 29 #include "SandboxExtension.h" 29 30 #include <WebCore/FrameLoaderTypes.h> 30 31 #include <WebCore/ResourceHandleTypes.h> … … 50 51 namespace WebKit { 51 52 53 class Download; 52 54 class NetworkSession; 53 55 class PendingDownload; … … 96 98 ~NetworkDataTask(); 97 99 98 NetworkDataTaskClient& client() { return m_client; } 100 void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend); 101 void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler); 102 void didCompleteWithError(const WebCore::ResourceError&); 103 void didReceiveResponse(const WebCore::ResourceResponse&, ResponseCompletionHandler); 104 void didReceiveData(RefPtr<WebCore::SharedBuffer>&&); 105 void didBecomeDownload(); 106 107 void clearClient() { m_client = nullptr; } 99 108 100 109 DownloadID pendingDownloadID() { return m_pendingDownloadID; } … … 111 120 m_pendingDownload = &pendingDownload; 112 121 } 122 void findPendingDownloadLocation(ResponseCompletionHandler); 123 void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&); 124 const String& pendingDownloadLocation() { return m_pendingDownloadLocation; } 125 WebCore::ResourceRequest currentRequest(); 113 126 bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler); 114 127 void willPerformHTTPRedirection(const WebCore::ResourceResponse&, WebCore::ResourceRequest&&, RedirectCompletionHandler); 128 void transferSandboxExtensionToDownload(Download&); 115 129 116 130 private: … … 128 142 129 143 NetworkSession& m_session; 130 NetworkDataTaskClient &m_client;144 NetworkDataTaskClient* m_client; 131 145 PendingDownload* m_pendingDownload { nullptr }; 132 146 DownloadID m_pendingDownloadID; … … 134 148 String m_password; 135 149 String m_lastHTTPMethod; 150 String m_pendingDownloadLocation; 136 151 WebCore::ResourceRequest m_firstRequest; 137 152 bool m_shouldClearReferrerOnHTTPSToHTTPRedirect; 153 RefPtr<SandboxExtension> m_sandboxExtension; 138 154 #if PLATFORM(COCOA) 139 155 RetainPtr<NSURLSessionDataTask> m_task; -
trunk/Source/WebKit2/NetworkProcess/NetworkLoad.cpp
r196671 r196984 72 72 if (m_responseCompletionHandler) 73 73 m_responseCompletionHandler(PolicyIgnore); 74 if (m_task) 75 m_task->clearClient(); 74 76 #endif 75 77 if (m_handle) … … 164 166 void NetworkLoad::convertTaskToDownload(DownloadID downloadID) 165 167 { 168 if (!m_task) 169 return; 170 166 171 m_task->setPendingDownloadID(downloadID); 167 172 168 173 ASSERT(m_responseCompletionHandler); 169 if (m_responseCompletionHandler) { 170 m_responseCompletionHandler(PolicyDownload); 171 m_responseCompletionHandler = nullptr; 172 } 174 if (m_responseCompletionHandler) 175 m_task->findPendingDownloadLocation(WTFMove(m_responseCompletionHandler)); 173 176 } 174 177 … … 219 222 ASSERT(isMainThread()); 220 223 if (m_task && m_task->pendingDownloadID().downloadID()) 221 completionHandler(PolicyDownload);224 m_task->findPendingDownloadLocation(completionHandler); 222 225 else if (sharedDidReceiveResponse(response) == NetworkLoadClient::ShouldContinueDidReceiveResponse::Yes) 223 226 completionHandler(PolicyUse); -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
r196943 r196984 32 32 #include "ChildProcessMessages.h" 33 33 #include "CustomProtocolManager.h" 34 #include "DownloadProxyMessages.h" 34 35 #include "Logging.h" 35 36 #include "NetworkConnectionToWebProcess.h" … … 42 43 #include "StatisticsData.h" 43 44 #include "WebCookieManager.h" 45 #include "WebCoreArgumentCoders.h" 44 46 #include "WebProcessPoolMessages.h" 45 47 #include "WebsiteData.h" … … 469 471 downloadManager().continueWillSendRequest(downloadID, request); 470 472 } 473 474 void NetworkProcess::findPendingDownloadLocation(NetworkDataTask& networkDataTask, String suggestedFilename, ResponseCompletionHandler completionHandler) 475 { 476 uint64_t destinationID = networkDataTask.pendingDownloadID().downloadID(); 477 downloadProxyConnection()->send(Messages::DownloadProxy::DidStart(networkDataTask.currentRequest()), destinationID); 478 479 downloadManager().willDecidePendingDownloadDestination(networkDataTask, completionHandler); 480 downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID); 481 } 482 483 void NetworkProcess::continueDecidePendingDownloadDestination(DownloadID downloadID, String destination, const SandboxExtension::Handle& sandboxExtensionHandle) 484 { 485 downloadManager().continueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle); 486 } 471 487 #endif 472 488 -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h
r196943 r196984 43 43 44 44 namespace WebCore { 45 class DownloadID; 45 46 class CertificateInfo; 46 47 class NetworkStorageSession; … … 100 101 #endif 101 102 103 #if USE(NETWORK_SESSION) 104 void findPendingDownloadLocation(NetworkDataTask&, String suggestedFilename, ResponseCompletionHandler); 105 #endif 106 102 107 void prefetchDNS(const String&); 103 108 … … 158 163 void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate); 159 164 void continueWillSendRequest(DownloadID, const WebCore::ResourceRequest&); 165 void continueDecidePendingDownloadDestination(DownloadID, String destination, const SandboxExtension::Handle& sandboxExtensionHandle); 160 166 #endif 161 167 void setCacheModel(uint32_t); -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
r195589 r196984 48 48 ContinueCanAuthenticateAgainstProtectionSpace(WebKit::DownloadID downloadID, bool canAuthenticate) 49 49 ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request) 50 ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle) 50 51 #endif 51 52 -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r196707 r196984 29 29 #if USE(NETWORK_SESSION) 30 30 31 #import "Download.h" 32 #import "DownloadProxyMessages.h" 33 #import "NetworkProcess.h" 34 #import "WebCoreArgumentCoders.h" 31 35 #import <WebCore/AuthenticationChallenge.h> 32 36 #import <WebCore/CFNetworkSPI.h> … … 34 38 #import <wtf/MainThread.h> 35 39 40 @interface NSURLSessionTask () 41 @property (readwrite, copy) NSString *_pathToDownloadTaskFile; 42 @end 43 36 44 namespace WebKit { 37 45 … … 39 47 : m_failureTimer(*this, &NetworkDataTask::failureTimerFired) 40 48 , m_session(session) 41 , m_client( client)49 , m_client(&client) 42 50 , m_lastHTTPMethod(requestWithCredentials.httpMethod()) 43 51 , m_firstRequest(requestWithCredentials) … … 85 93 m_session.m_dataTaskMap.remove(taskIdentifier()); 86 94 } 95 } 96 97 void NetworkDataTask::didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) 98 { 99 if (m_client) 100 m_client->didSendData(totalBytesSent, totalBytesExpectedToSend); 101 } 102 103 void NetworkDataTask::didReceiveChallenge(const WebCore::AuthenticationChallenge& challenge, ChallengeCompletionHandler completionHandler) 104 { 105 if (m_client) 106 m_client->didReceiveChallenge(challenge, completionHandler); 107 } 108 109 void NetworkDataTask::didCompleteWithError(const WebCore::ResourceError& error) 110 { 111 if (m_client) 112 m_client->didCompleteWithError(error); 113 } 114 115 void NetworkDataTask::didReceiveResponse(const WebCore::ResourceResponse& response, ResponseCompletionHandler completionHandler) 116 { 117 if (m_client) 118 m_client->didReceiveResponseNetworkSession(response, completionHandler); 119 } 120 121 void NetworkDataTask::didReceiveData(RefPtr<WebCore::SharedBuffer>&& data) 122 { 123 if (m_client) 124 m_client->didReceiveData(WTFMove(data)); 125 } 126 127 void NetworkDataTask::didBecomeDownload() 128 { 129 if (m_client) 130 m_client->didBecomeDownload(); 87 131 } 88 132 … … 117 161 } 118 162 119 client().willPerformHTTPRedirection(redirectResponse, request, completionHandler); 163 if (m_client) 164 m_client->willPerformHTTPRedirection(redirectResponse, request, completionHandler); 120 165 } 121 166 … … 134 179 case BlockedFailure: 135 180 m_scheduledFailureType = NoFailure; 136 client().wasBlocked(); 181 if (m_client) 182 m_client->wasBlocked(); 137 183 return; 138 184 case InvalidURLFailure: 139 185 m_scheduledFailureType = NoFailure; 140 client().cannotShowURL(); 186 if (m_client) 187 m_client->cannotShowURL(); 141 188 return; 142 189 case NoFailure: … … 145 192 } 146 193 ASSERT_NOT_REACHED(); 194 } 195 196 void NetworkDataTask::findPendingDownloadLocation(ResponseCompletionHandler completionHandler) 197 { 198 NetworkProcess::singleton().findPendingDownloadLocation(*this, m_task.get().response.suggestedFilename, completionHandler); 199 } 200 201 void NetworkDataTask::setPendingDownloadLocation(const WTF::String& filename, const SandboxExtension::Handle& sandboxExtensionHandle) 202 { 203 ASSERT(!m_sandboxExtension); 204 m_sandboxExtension = SandboxExtension::create(sandboxExtensionHandle); 205 if (m_sandboxExtension) 206 m_sandboxExtension->consume(); 207 208 m_pendingDownloadLocation = filename; 209 m_task.get()._pathToDownloadTaskFile = filename; 147 210 } 148 211 … … 167 230 } 168 231 232 void NetworkDataTask::transferSandboxExtensionToDownload(Download& download) 233 { 234 download.setSandboxExtension(WTFMove(m_sandboxExtension)); 235 } 236 237 WebCore::ResourceRequest NetworkDataTask::currentRequest() 238 { 239 return [m_task currentRequest]; 240 } 241 169 242 void NetworkDataTask::cancel() 170 243 { -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r196656 r196984 30 30 31 31 #import "CustomProtocolManager.h" 32 #import "DataReference.h" 32 33 #import "Download.h" 33 34 #import "NetworkLoad.h" … … 99 100 { 100 101 if (auto* networkDataTask = _session->dataTaskForIdentifier(task.taskIdentifier)) 101 networkDataTask-> client().didSendData(totalBytesSent, totalBytesExpectedToSend);102 networkDataTask->didSendData(totalBytesSent, totalBytesExpectedToSend); 102 103 } 103 104 … … 126 127 return; 127 128 128 networkDataTask-> client().didReceiveChallenge(challenge, challengeCompletionHandler);129 networkDataTask->didReceiveChallenge(challenge, challengeCompletionHandler); 129 130 } 130 131 } … … 133 134 { 134 135 if (auto* networkDataTask = _session->dataTaskForIdentifier(task.taskIdentifier)) 135 networkDataTask->client().didCompleteWithError(error); 136 networkDataTask->didCompleteWithError(error); 137 else if (auto* download = WebKit::NetworkProcess::singleton().downloadManager().download(_session->downloadID(task.taskIdentifier))) { 138 if (error) 139 download->didFail(error, { }); // FIXME: Give some actual data here for resuming. 140 } 136 141 } 137 142 … … 143 148 copyTimingData([dataTask _timingData], resourceResponse.resourceLoadTiming()); 144 149 auto completionHandlerCopy = Block_copy(completionHandler); 145 networkDataTask-> client().didReceiveResponseNetworkSession(resourceResponse, [completionHandlerCopy](WebCore::PolicyAction policyAction) {150 networkDataTask->didReceiveResponse(resourceResponse, [completionHandlerCopy, resourceResponse](WebCore::PolicyAction policyAction) { 146 151 completionHandlerCopy(toNSURLSessionResponseDisposition(policyAction)); 147 152 Block_release(completionHandlerCopy); … … 153 158 { 154 159 if (auto* networkDataTask = _session->dataTaskForIdentifier(dataTask.taskIdentifier)) 155 networkDataTask-> client().didReceiveData(WebCore::SharedBuffer::wrapNSData(data));160 networkDataTask->didReceiveData(WebCore::SharedBuffer::wrapNSData(data)); 156 161 } 157 162 … … 159 164 { 160 165 auto downloadID = _session->takeDownloadID([downloadTask taskIdentifier]); 161 notImplemented();162 166 if (auto* download = WebKit::NetworkProcess::singleton().downloadManager().download(downloadID)) 163 167 download->didFinish(); … … 184 188 auto& downloadManager = WebKit::NetworkProcess::singleton().downloadManager(); 185 189 auto download = std::make_unique<WebKit::Download>(downloadManager, downloadID); 186 download->didStart([downloadTask currentRequest]); 190 networkDataTask->transferSandboxExtensionToDownload(*download); 191 ASSERT(WebCore::fileExists(networkDataTask->pendingDownloadLocation())); 192 download->didCreateDestination(networkDataTask->pendingDownloadLocation()); 187 193 download->didReceiveResponse([downloadTask response]); 188 194 auto pendingDownload = downloadManager.dataTaskBecameDownloadTask(downloadID, WTFMove(download)); 189 195 190 networkDataTask-> client().didBecomeDownload();196 networkDataTask->didBecomeDownload(); 191 197 192 198 _session->addDownloadID([downloadTask taskIdentifier], downloadID); -
trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
r195357 r196984 37 37 #include "WebProcessPool.h" 38 38 #include "WebProtectionSpace.h" 39 #include <WebCore/FileSystem.h> 39 40 #include <wtf/text/CString.h> 40 41 #include <wtf/text/WTFString.h> … … 171 172 } 172 173 173 void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle) 174 { 175 allowOverwrite = false; 176 177 if (!m_processPool) 178 return; 179 180 destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, filename, allowOverwrite); 181 174 #if USE(NETWORK_SESSION) 175 void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downloadID, const String& suggestedFilename) 176 { 177 bool allowOverwrite = false; 178 179 if (!m_processPool) 180 return; 181 182 String destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite); 183 184 SandboxExtension::Handle sandboxExtensionHandle; 182 185 if (!destination.isNull()) 183 186 SandboxExtension::createHandle(destination, SandboxExtension::ReadWrite, sandboxExtensionHandle); 184 } 187 188 if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess()) 189 networkProcess->connection()->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle), 0); 190 } 191 #else 192 void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle) 193 { 194 allowOverwrite = false; 195 196 if (!m_processPool) 197 return; 198 199 destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, filename, allowOverwrite); 200 201 if (!destination.isNull()) 202 SandboxExtension::createHandle(destination, SandboxExtension::ReadWrite, sandboxExtensionHandle); 203 } 204 #endif 185 205 186 206 void DownloadProxy::didCreateDestination(const String& path) -
trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
r195357 r196984 48 48 namespace WebKit { 49 49 50 class DownloadID; 50 51 class DownloadProxyMap; 51 52 class WebPageProxy; … … 82 83 void didReceiveData(uint64_t length); 83 84 void shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result); 85 #if !USE(NETWORK_SESSION) 84 86 void decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle); 87 #endif 85 88 void didCreateDestination(const String& path); 86 89 void didFinish(); … … 90 93 void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&); 91 94 void willSendRequest(const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse& redirectResponse); 95 void decideDestinationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename); 92 96 #endif 93 97 -
trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in
r195357 r196984 27 27 WillSendRequest(WebCore::ResourceRequest redirectRequest, WebCore::ResourceResponse redirectResponse)); 28 28 CanAuthenticateAgainstProtectionSpace(WebCore::ProtectionSpace protectionSpace) 29 DecideDestinationWithSuggestedFilenameAsync(WebKit::DownloadID downloadID, String suggestedFilename) 29 30 #endif 30 31 … … 32 33 DidReceiveData(uint64_t length) 33 34 ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result) 35 #if !USE(NETWORK_SESSION) 34 36 DecideDestinationWithSuggestedFilename(String filename) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle) 37 #endif 35 38 DidCreateDestination(String path) 36 39 DidFinish()
Note:
See TracChangeset
for help on using the changeset viewer.