Changeset 207586 in webkit
- Timestamp:
- Oct 19, 2016 11:42:24 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 1 added
- 19 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/CMakeLists.txt
r206937 r207586 218 218 NetworkProcess/Downloads/Download.cpp 219 219 NetworkProcess/Downloads/DownloadManager.cpp 220 NetworkProcess/Downloads/PendingDownload.cpp 220 221 221 222 Platform/Logging.cpp -
trunk/Source/WebKit2/ChangeLog
r207585 r207586 1 2016-10-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Add NetworkSession implementation and switch to use it 4 https://bugs.webkit.org/show_bug.cgi?id=163597 5 6 Reviewed by Alex Christensen. 7 8 Basically move the ResourceHandle implementation to the network process, but modernized, cleaned up, and adapted 9 to the NetworkSession model. 10 11 * CMakeLists.txt: Add new files to compilation. 12 * NetworkProcess/Downloads/Download.cpp: 13 (WebKit::Download::Download): Use the same code for all ports using NetworkSession and add missing 14 initialization of m_sessionID. 15 * NetworkProcess/Downloads/Download.h: 16 (WebKit::Download::Download): Define PlatformDownloadTaskRef on every platform to make the constructor common to 17 all ports using NetworkSession. 18 * NetworkProcess/Downloads/soup/DownloadSoup.cpp: 19 (WebKit::Download::cancelNetworkLoad): 20 (WebKit::Download::platformDidFinish): 21 * NetworkProcess/NetworkDataTask.h: 22 (WebKit::NetworkDataTask::pendingDownloadID): Make const. 23 (WebKit::NetworkDataTask::pendingDownload): Ditto. 24 (WebKit::NetworkDataTask::pendingDownloadLocation): Ditto. 25 (WebKit::NetworkDataTask::isDownload): Helper to check if the task is a download. 26 * NetworkProcess/NetworkLoad.cpp: 27 (WebKit::NetworkLoad::didReceiveResponseNetworkSession): Use NetworkDataTask::isDownload(). 28 * NetworkProcess/NetworkProcess.cpp: 29 (WebKit::NetworkProcess::NetworkProcess): NetworkSession::setCustomProtocolManager() is Cocoa only. 30 * NetworkProcess/NetworkSession.h: 31 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 32 (WebKit::NetworkSession::networkStorageSession): Make const. 33 * NetworkProcess/soup/NetworkDataTaskSoup.cpp: Added. 34 (WebKit::NetworkDataTask::NetworkDataTask): 35 (WebKit::NetworkDataTask::~NetworkDataTask): 36 (WebKit::NetworkDataTask::scheduleFailure): 37 (WebKit::NetworkDataTask::failureTimerFired): 38 (WebKit::NetworkDataTask::suggestedFilename): 39 (WebKit::NetworkDataTask::setSuggestedFilename): 40 (WebKit::NetworkDataTask::setPendingDownloadLocation): 41 (WebKit::NetworkDataTask::allowsSpecificHTTPSCertificateForHost): 42 (WebKit::NetworkDataTask::createRequest): 43 (WebKit::NetworkDataTask::clearRequest): 44 (WebKit::NetworkDataTask::resume): 45 (WebKit::NetworkDataTask::suspend): 46 (WebKit::NetworkDataTask::cancel): 47 (WebKit::NetworkDataTask::invalidateAndCancel): 48 (WebKit::NetworkDataTask::state): 49 (WebKit::NetworkDataTask::timeoutFired): 50 (WebKit::NetworkDataTask::startTimeout): 51 (WebKit::NetworkDataTask::stopTimeout): 52 (WebKit::NetworkDataTask::sendRequestCallback): 53 (WebKit::NetworkDataTask::didSendRequest): 54 (WebKit::NetworkDataTask::didReceiveResponse): 55 (WebKit::NetworkDataTask::tlsErrorsChangedCallback): 56 (WebKit::NetworkDataTask::tlsErrorsChanged): 57 (WebKit::NetworkDataTask::applyAuthenticationToRequest): 58 (WebKit::NetworkDataTask::authenticateCallback): 59 (WebKit::isAuthenticationFailureStatusCode): 60 (WebKit::NetworkDataTask::authenticate): 61 (WebKit::NetworkDataTask::continueAuthenticate): 62 (WebKit::NetworkDataTask::skipInputStreamForRedirectionCallback): 63 (WebKit::NetworkDataTask::skipInputStreamForRedirection): 64 (WebKit::NetworkDataTask::didFinishSkipInputStreamForRedirection): 65 (WebKit::shouldRedirectAsGET): 66 (WebKit::NetworkDataTask::shouldStartHTTPRedirection): 67 (WebKit::NetworkDataTask::continueHTTPRedirection): 68 (WebKit::NetworkDataTask::readCallback): 69 (WebKit::NetworkDataTask::read): 70 (WebKit::NetworkDataTask::didRead): 71 (WebKit::NetworkDataTask::didFinishRead): 72 (WebKit::NetworkDataTask::requestNextPartCallback): 73 (WebKit::NetworkDataTask::requestNextPart): 74 (WebKit::NetworkDataTask::didRequestNextPart): 75 (WebKit::NetworkDataTask::didFinishRequestNextPart): 76 (WebKit::NetworkDataTask::gotHeadersCallback): 77 (WebKit::NetworkDataTask::didGetHeaders): 78 (WebKit::NetworkDataTask::wroteBodyDataCallback): 79 (WebKit::NetworkDataTask::didWriteBodyData): 80 (WebKit::NetworkDataTask::download): 81 (WebKit::NetworkDataTask::writeDownloadCallback): 82 (WebKit::NetworkDataTask::writeDownload): 83 (WebKit::NetworkDataTask::didWriteDownload): 84 (WebKit::NetworkDataTask::didFinishDownload): 85 (WebKit::NetworkDataTask::didFailDownload): 86 (WebKit::NetworkDataTask::cleanDownloadFiles): 87 (WebKit::NetworkDataTask::didFail): 88 (WebKit::NetworkDataTask::networkEventCallback): 89 (WebKit::NetworkDataTask::networkEvent): 90 (WebKit::NetworkDataTask::startingCallback): 91 (WebKit::NetworkDataTask::requestStartedCallback): 92 (WebKit::NetworkDataTask::didStartRequest): 93 (WebKit::NetworkDataTask::restartedCallback): 94 (WebKit::NetworkDataTask::didRestart): 95 * NetworkProcess/soup/NetworkSessionSoup.cpp: 96 (WebKit::NetworkSession::create): 97 (WebKit::NetworkSession::defaultSession): 98 (WebKit::NetworkSession::networkStorageSession): 99 (WebKit::NetworkSession::NetworkSession): 100 (WebKit::NetworkSession::~NetworkSession): 101 (WebKit::NetworkSession::soupSession): 102 (WebKit::NetworkSession::invalidateAndCancel): 103 (WebKit::NetworkSession::clearCredentials): 104 * NetworkProcess/soup/RemoteNetworkingContextSoup.cpp: 105 (WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession): Add implementation matching 106 WebFrameNetworkingContext::ensurePrivateBrowsingSession(). 107 (WebKit::RemoteNetworkingContext::storageSession): Do not always return the default session if the given one is 108 in the global map. 109 * PlatformEfl.cmake: Ad new files to compilation. 110 * PlatformGTK.cmake: Ditto. 111 * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp: 112 (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession): Also create a NetworkSession. 113 * config.h: Enable NetworkSession unconditionally for Soup based ports. 114 1 115 2016-10-19 Alex Christensen <achristensen@webkit.org> 2 116 -
trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp
r206439 r207586 34 34 #include "DownloadProxyMessages.h" 35 35 #include "Logging.h" 36 #include "NetworkDataTask.h" 36 37 #include "SandboxExtension.h" 37 38 #include "WebCoreArgumentCoders.h" … … 44 45 namespace WebKit { 45 46 46 #if USE(NETWORK_SESSION) && PLATFORM(COCOA)47 Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask*download, const WebCore::SessionID& sessionID, const String& suggestedName)47 #if USE(NETWORK_SESSION) 48 Download::Download(DownloadManager& downloadManager, DownloadID downloadID, PlatformDownloadTaskRef download, const WebCore::SessionID& sessionID, const String& suggestedName) 48 49 : m_downloadManager(downloadManager) 49 50 , m_downloadID(downloadID) 50 51 , m_download(download) 52 , m_sessionID(sessionID) 51 53 , m_suggestedName(suggestedName) 52 54 { -
trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h
r207585 r207586 36 36 #include <memory> 37 37 #include <wtf/Noncopyable.h> 38 39 #if PLATFORM(COCOA)40 38 #include <wtf/RetainPtr.h> 41 39 42 40 #if USE(NETWORK_SESSION) 41 #if PLATFORM(COCOA) 43 42 OBJC_CLASS NSURLSessionDownloadTask; 44 #else 43 typedef NSURLSessionDownloadTask* PlatformDownloadTaskRef; 44 #elif USE(SOUP) 45 namespace WebKit { 46 class NetworkDataTask; 47 } 48 typedef WebKit::NetworkDataTask* PlatformDownloadTaskRef; 49 #endif 50 #else // USE(NETWORK_SESSION) 51 #if PLATFORM(COCOA) 45 52 OBJC_CLASS NSURLDownload; 46 53 OBJC_CLASS WKDownloadAsDelegate; 47 54 #endif 48 #endif 55 #endif // USE(NETWORK_SESSION) 49 56 50 57 #if USE(CFURLCONNECTION) … … 73 80 WTF_MAKE_NONCOPYABLE(Download); WTF_MAKE_FAST_ALLOCATED; 74 81 public: 75 #if USE(NETWORK_SESSION) && PLATFORM(COCOA)76 Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, const WebCore::SessionID& sessionID, const String& suggestedFilename = { });82 #if USE(NETWORK_SESSION) 83 Download(DownloadManager&, DownloadID, PlatformDownloadTaskRef, const WebCore::SessionID& sessionID, const String& suggestedFilename = { }); 77 84 #endif 78 85 Download(DownloadManager&, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename = { }); … … 131 138 RefPtr<SandboxExtension> m_sandboxExtension; 132 139 140 #if USE(NETWORK_SESSION) 133 141 #if PLATFORM(COCOA) 134 #if USE(NETWORK_SESSION)135 142 RetainPtr<NSURLSessionDownloadTask> m_download; 143 #elif USE(SOUP) 144 RefPtr<NetworkDataTask> m_download; 145 #endif 136 146 WebCore::SessionID m_sessionID; 137 #else 147 #else // USE(NETWORK_SESSION) 148 #if PLATFORM(COCOA) 138 149 RetainPtr<NSURLDownload> m_nsURLDownload; 139 150 RetainPtr<WKDownloadAsDelegate> m_delegate; 140 151 #endif 141 #endif 152 #endif // USE(NETWORK_SESSION) 142 153 #if USE(CFURLCONNECTION) 143 154 RetainPtr<CFURLDownloadRef> m_download; -
trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp
r207405 r207586 29 29 30 30 #include "DataReference.h" 31 #include " DownloadSoupErrors.h"31 #include "NetworkDataTask.h" 32 32 #include <WebCore/NotImplemented.h> 33 #include <WebCore/ResourceHandleInternal.h>34 #include <gio/gio.h>35 #include <wtf/RunLoop.h>36 #include <wtf/glib/GRefPtr.h>37 #include <wtf/glib/GUniquePtr.h>38 #include <wtf/text/CString.h>39 40 #if PLATFORM(GTK)41 #include <glib/gi18n-lib.h>42 #endif43 33 44 34 using namespace WebCore; 45 35 46 36 namespace WebKit { 47 48 class DownloadClient final : public ResourceHandleClient {49 WTF_MAKE_NONCOPYABLE(DownloadClient);50 public:51 DownloadClient(Download& download)52 : m_download(download)53 , m_handleResponseLater(RunLoop::main(), this, &DownloadClient::handleResponse)54 , m_allowOverwrite(false)55 {56 }57 58 ~DownloadClient()59 {60 }61 62 void deleteFilesIfNeeded()63 {64 if (m_destinationFile)65 g_file_delete(m_destinationFile.get(), nullptr, nullptr);66 67 if (m_intermediateFile) {68 ASSERT(m_destinationFile);69 g_file_delete(m_intermediateFile.get(), nullptr, nullptr);70 }71 }72 73 void downloadFailed(const ResourceError& error)74 {75 deleteFilesIfNeeded();76 m_download.didFail(error, IPC::DataReference());77 }78 79 void didReceiveResponse(ResourceHandle*, ResourceResponse&& response) override80 {81 m_response = WTFMove(response);82 m_download.didReceiveResponse(m_response);83 84 if (m_response.httpStatusCode() >= 400) {85 downloadFailed(platformDownloadNetworkError(m_response.httpStatusCode(), m_response.url(), m_response.httpStatusText()));86 return;87 }88 89 String suggestedFilename = m_response.suggestedFilename();90 if (suggestedFilename.isEmpty()) {91 URL url = m_response.url();92 url.setQuery(String());93 url.removeFragmentIdentifier();94 suggestedFilename = decodeURLEscapeSequences(url.lastPathComponent());95 }96 97 String destinationURI = m_download.decideDestinationWithSuggestedFilename(suggestedFilename, m_allowOverwrite);98 if (destinationURI.isEmpty()) {99 #if PLATFORM(GTK)100 GUniquePtr<char> buffer(g_strdup_printf(_("Cannot determine destination URI for download with suggested filename %s"), suggestedFilename.utf8().data()));101 String errorMessage = String::fromUTF8(buffer.get());102 #else103 String errorMessage = makeString("Cannot determine destination URI for download with suggested filename ", suggestedFilename);104 #endif105 downloadFailed(platformDownloadDestinationError(m_response, errorMessage));106 return;107 }108 109 m_destinationFile = adoptGRef(g_file_new_for_uri(destinationURI.utf8().data()));110 GRefPtr<GFileOutputStream> outputStream;111 GUniqueOutPtr<GError> error;112 if (m_allowOverwrite)113 outputStream = adoptGRef(g_file_replace(m_destinationFile.get(), nullptr, FALSE, G_FILE_CREATE_NONE, nullptr, &error.outPtr()));114 else115 outputStream = adoptGRef(g_file_create(m_destinationFile.get(), G_FILE_CREATE_NONE, nullptr, &error.outPtr()));116 if (!outputStream) {117 m_destinationFile.clear();118 downloadFailed(platformDownloadDestinationError(m_response, error->message));119 return;120 }121 122 String intermediateURI = destinationURI + ".wkdownload";123 m_intermediateFile = adoptGRef(g_file_new_for_uri(intermediateURI.utf8().data()));124 m_outputStream = adoptGRef(g_file_replace(m_intermediateFile.get(), 0, TRUE, G_FILE_CREATE_NONE, 0, &error.outPtr()));125 if (!m_outputStream) {126 downloadFailed(platformDownloadDestinationError(m_response, error->message));127 return;128 }129 130 m_download.didCreateDestination(destinationURI);131 }132 133 void didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/) override134 {135 if (m_handleResponseLater.isActive()) {136 m_handleResponseLater.stop();137 handleResponse();138 }139 140 gsize bytesWritten;141 GUniqueOutPtr<GError> error;142 g_output_stream_write_all(G_OUTPUT_STREAM(m_outputStream.get()), data, length, &bytesWritten, 0, &error.outPtr());143 if (error) {144 downloadFailed(platformDownloadDestinationError(m_response, error->message));145 return;146 }147 m_download.didReceiveData(bytesWritten);148 }149 150 void didFinishLoading(ResourceHandle*, double) override151 {152 m_outputStream = nullptr;153 154 ASSERT(m_destinationFile);155 ASSERT(m_intermediateFile);156 GUniqueOutPtr<GError> error;157 if (!g_file_move(m_intermediateFile.get(), m_destinationFile.get(), G_FILE_COPY_OVERWRITE, nullptr, nullptr, nullptr, &error.outPtr())) {158 downloadFailed(platformDownloadDestinationError(m_response, error->message));159 return;160 }161 162 GRefPtr<GFileInfo> info = adoptGRef(g_file_info_new());163 CString uri = m_response.url().string().utf8();164 g_file_info_set_attribute_string(info.get(), "metadata::download-uri", uri.data());165 g_file_info_set_attribute_string(info.get(), "xattr::xdg.origin.url", uri.data());166 g_file_set_attributes_async(m_destinationFile.get(), info.get(), G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, nullptr, nullptr, nullptr);167 168 m_download.didFinish();169 }170 171 void didFail(ResourceHandle*, const ResourceError& error) override172 {173 downloadFailed(platformDownloadNetworkError(error.errorCode(), error.failingURL(), error.localizedDescription()));174 }175 176 void cancel(ResourceHandle* handle)177 {178 handle->cancel();179 deleteFilesIfNeeded();180 m_download.didCancel(IPC::DataReference());181 }182 183 void handleResponse()184 {185 didReceiveResponse(nullptr, WTFMove(m_delayedResponse));186 }187 188 void handleResponseLater(const ResourceResponse& response)189 {190 ASSERT(m_response.isNull());191 ASSERT(!m_handleResponseLater.isActive());192 193 m_delayedResponse = response;194 195 // Call didReceiveResponse in an idle to make sure the download is added196 // to the DownloadManager downloads map.197 m_handleResponseLater.startOneShot(0);198 }199 200 Download& m_download;201 GRefPtr<GFileOutputStream> m_outputStream;202 ResourceResponse m_response;203 GRefPtr<GFile> m_destinationFile;204 GRefPtr<GFile> m_intermediateFile;205 ResourceResponse m_delayedResponse;206 RunLoop::Timer<DownloadClient> m_handleResponseLater;207 bool m_allowOverwrite;208 };209 210 void Download::startNetworkLoad()211 {212 ASSERT(!m_downloadClient);213 ASSERT(!m_resourceHandle);214 m_downloadClient = std::make_unique<DownloadClient>(*this);215 m_resourceHandle = ResourceHandle::create(0, m_request, m_downloadClient.get(), false, true);216 didStart();217 }218 219 void Download::startNetworkLoadWithHandle(ResourceHandle* resourceHandle, const ResourceResponse& response)220 {221 ASSERT(!m_downloadClient);222 ASSERT(!m_resourceHandle);223 m_downloadClient = std::make_unique<DownloadClient>(*this);224 m_resourceHandle = resourceHandle->releaseForDownload(m_downloadClient.get());225 didStart();226 static_cast<DownloadClient*>(m_downloadClient.get())->handleResponseLater(response);227 }228 37 229 38 void Download::resume(const IPC::DataReference&, const String&, const SandboxExtension::Handle&) … … 234 43 void Download::cancelNetworkLoad() 235 44 { 236 if (!m_resourceHandle) 237 return; 238 239 // Cancelling the download will delete it and platformInvalidate() will be called by the destructor. 240 // So, we need to set m_resourceHandle to nullptr before actually cancelling the download to make sure 241 // it won't be cancelled again by platformInvalidate. See https://bugs.webkit.org/show_bug.cgi?id=127650. 242 RefPtr<ResourceHandle> resourceHandle = m_resourceHandle.release(); 243 static_cast<DownloadClient*>(m_downloadClient.get())->cancel(resourceHandle.get()); 45 m_download->cancel(); 46 didCancel({ }); 244 47 } 245 48 … … 250 53 void Download::platformDidFinish() 251 54 { 252 m_resourceHandle = nullptr;253 55 } 254 56 -
trunk/Source/WebKit2/NetworkProcess/NetworkDataTask.h
r207530 r207586 24 24 */ 25 25 26 #ifndef NetworkDataTask_h 27 #define NetworkDataTask_h 28 26 #pragma once 27 28 #if USE(NETWORK_SESSION) 29 30 #include "DownloadID.h" 29 31 #include "SandboxExtension.h" 30 32 #include <WebCore/Credential.h> … … 42 44 #endif 43 45 46 #if USE(SOUP) 47 #include <WebCore/ProtectionSpace.h> 48 #include <WebCore/ResourceResponse.h> 49 #include <wtf/RunLoop.h> 50 #include <wtf/glib/GRefPtr.h> 51 #endif 52 44 53 namespace WebCore { 45 54 class AuthenticationChallenge; … … 56 65 class NetworkSession; 57 66 class PendingDownload; 58 59 enum class AuthenticationChallengeDisposition { 60 UseCredential, 61 PerformDefaultHandling, 62 Cancel, 63 RejectProtectionSpace 64 }; 65 67 enum class AuthenticationChallengeDisposition; 68 66 69 typedef Function<void(const WebCore::ResourceRequest&)> RedirectCompletionHandler; 67 70 typedef Function<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> ChallengeCompletionHandler; … … 106 109 107 110 ~NetworkDataTask(); 108 111 112 #if PLATFORM(COCOA) 109 113 void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend); 110 114 void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&); … … 113 117 void didReceiveData(Ref<WebCore::SharedBuffer>&&); 114 118 void didBecomeDownload(); 115 119 120 void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&); 121 void transferSandboxExtensionToDownload(Download&); 122 #endif 116 123 NetworkDataTaskClient* client() const { return m_client; } 117 124 void clearClient() { m_client = nullptr; } 118 125 119 DownloadID pendingDownloadID() { return m_pendingDownloadID; }120 PendingDownload* pendingDownload() { return m_pendingDownload; }126 DownloadID pendingDownloadID() const { return m_pendingDownloadID; } 127 PendingDownload* pendingDownload() const { return m_pendingDownload; } 121 128 void setPendingDownloadID(DownloadID downloadID) 122 129 { … … 131 138 } 132 139 void setPendingDownloadLocation(const String& filename, const SandboxExtension::Handle&, bool allowOverwrite); 133 const String& pendingDownloadLocation() { return m_pendingDownloadLocation; } 140 const String& pendingDownloadLocation() const { return m_pendingDownloadLocation; } 141 bool isDownload() const { return !!m_pendingDownloadID.downloadID(); } 134 142 135 143 const WebCore::ResourceRequest& firstRequest() const { return m_firstRequest; } 136 144 String suggestedFilename(); 137 145 void setSuggestedFilename(const String&); 138 void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&);139 void transferSandboxExtensionToDownload(Download&);140 146 bool allowsSpecificHTTPSCertificateForHost(const WebCore::AuthenticationChallenge&); 141 147 … … 144 150 145 151 bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, const ChallengeCompletionHandler&); 152 153 #if USE(SOUP) 154 void timeoutFired(); 155 void startTimeout(); 156 void stopTimeout(); 157 void invalidateAndCancel(); 158 void createRequest(const WebCore::ResourceRequest&); 159 void clearRequest(); 160 static void sendRequestCallback(SoupRequest*, GAsyncResult*, NetworkDataTask*); 161 void didSendRequest(GRefPtr<GInputStream>&&); 162 void didReceiveResponse(); 163 static void tlsErrorsChangedCallback(SoupMessage*, GParamSpec*, NetworkDataTask*); 164 void tlsErrorsChanged(); 165 void applyAuthenticationToRequest(WebCore::ResourceRequest&); 166 static void authenticateCallback(SoupSession*, SoupMessage*, SoupAuth*, gboolean retrying, NetworkDataTask*); 167 void authenticate(WebCore::AuthenticationChallenge&&); 168 void continueAuthenticate(WebCore::AuthenticationChallenge&&); 169 static void skipInputStreamForRedirectionCallback(GInputStream*, GAsyncResult*, NetworkDataTask*); 170 void skipInputStreamForRedirection(); 171 void didFinishSkipInputStreamForRedirection(); 172 bool shouldStartHTTPRedirection(); 173 void continueHTTPRedirection(); 174 static void readCallback(GInputStream*, GAsyncResult*, NetworkDataTask*); 175 void read(); 176 void didRead(gssize bytesRead); 177 void didFinishRead(); 178 static void requestNextPartCallback(SoupMultipartInputStream*, GAsyncResult*, NetworkDataTask*); 179 void requestNextPart(); 180 void didRequestNextPart(GRefPtr<GInputStream>&&); 181 void didFinishRequestNextPart(); 182 static void gotHeadersCallback(SoupMessage*, NetworkDataTask*); 183 void didGetHeaders(); 184 static void wroteBodyDataCallback(SoupMessage*, SoupBuffer*, NetworkDataTask*); 185 void didWriteBodyData(uint64_t bytesSent); 186 void download(); 187 static void writeDownloadCallback(GOutputStream*, GAsyncResult*, NetworkDataTask*); 188 void writeDownload(); 189 void didWriteDownload(gsize bytesWritten); 190 void didFailDownload(const WebCore::ResourceError&); 191 void didFinishDownload(); 192 void cleanDownloadFiles(); 193 void didFail(const WebCore::ResourceError&); 194 #if ENABLE(WEB_TIMING) 195 static void networkEventCallback(SoupMessage*, GSocketClientEvent, GIOStream*, NetworkDataTask*); 196 void networkEvent(GSocketClientEvent); 197 #if SOUP_CHECK_VERSION(2, 49, 91) 198 static void startingCallback(SoupMessage*, NetworkDataTask*); 199 #else 200 static void requestStartedCallback(SoupSession*, SoupMessage*, SoupSocket*, NetworkDataTask*); 201 #endif 202 void didStartRequest(); 203 static void restartedCallback(SoupMessage*, NetworkDataTask*); 204 void didRestart(); 205 #endif 206 #endif 146 207 147 208 enum FailureType { … … 173 234 RetainPtr<NSURLSessionDataTask> m_task; 174 235 #endif 236 #if USE(SOUP) 237 State m_state { State::Suspended }; 238 WebCore::ContentSniffingPolicy m_shouldContentSniff; 239 GRefPtr<SoupRequest> m_soupRequest; 240 GRefPtr<SoupMessage> m_soupMessage; 241 GRefPtr<GInputStream> m_inputStream; 242 GRefPtr<SoupMultipartInputStream> m_multipartInputStream; 243 GRefPtr<GCancellable> m_cancellable; 244 GRefPtr<GAsyncResult> m_pendingResult; 245 WebCore::ProtectionSpace m_protectionSpaceForPersistentStorage; 246 WebCore::Credential m_credentialForPersistentStorage; 247 WebCore::ResourceResponse m_response; 248 Vector<char> m_readBuffer; 249 unsigned m_redirectCount { 0 }; 250 uint64_t m_bodyDataTotalBytesSent { 0 }; 251 GRefPtr<GFile> m_downloadDestinationFile; 252 GRefPtr<GFile> m_downloadIntermediateFile; 253 GRefPtr<GOutputStream> m_downloadOutputStream; 254 bool m_allowOverwriteDownload { false }; 255 #if ENABLE(WEB_TIMING) 256 double m_startTime { 0 }; 257 #endif 258 RunLoop::Timer<NetworkDataTask> m_timeoutSource; 259 #endif 175 260 String m_suggestedFilename; 176 261 }; … … 182 267 } 183 268 184 #endif 269 #endif // USE(NETWORK_SESSION) -
trunk/Source/WebKit2/NetworkProcess/NetworkLoad.cpp
r207530 r207586 272 272 { 273 273 ASSERT(isMainThread()); 274 if (m_task && m_task-> pendingDownloadID().downloadID())274 if (m_task && m_task->isDownload()) 275 275 NetworkProcess::singleton().findPendingDownloadLocation(*m_task.get(), WTFMove(completionHandler), response); 276 276 else if (sharedDidReceiveResponse(WTFMove(response)) == NetworkLoadClient::ShouldContinueDidReceiveResponse::Yes) -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
r207530 r207586 40 40 #include "NetworkProcessProxyMessages.h" 41 41 #include "NetworkResourceLoader.h" 42 #include "NetworkSession.h" 42 43 #include "RemoteNetworkingContext.h" 43 44 #include "SessionTracker.h" … … 101 102 addSupplement<WebCookieManager>(); 102 103 addSupplement<CustomProtocolManager>(); 103 #if USE(NETWORK_SESSION) 104 #if USE(NETWORK_SESSION) && PLATFORM(COCOA) 104 105 NetworkSession::setCustomProtocolManager(supplement<CustomProtocolManager>()); 105 106 #endif -
trunk/Source/WebKit2/NetworkProcess/NetworkSession.h
r206604 r207586 26 26 #pragma once 27 27 28 #if USE(NETWORK_SESSION) 29 28 30 #if PLATFORM(COCOA) 29 31 OBJC_CLASS NSURLSession; … … 36 38 #include <WebCore/SessionID.h> 37 39 #include <wtf/HashMap.h> 40 #include <wtf/HashSet.h> 38 41 #include <wtf/Ref.h> 39 42 #include <wtf/RefCounted.h> 43 44 #if USE(SOUP) 45 typedef struct _SoupSession SoupSession; 46 #endif 40 47 41 48 namespace WebCore { … … 63 70 WebCore::SessionID sessionID() const { return m_sessionID; } 64 71 72 #if USE(SOUP) 73 SoupSession* soupSession() const; 74 #endif 75 76 #if PLATFORM(COCOA) 65 77 // Must be called before any NetworkSession has been created. 66 78 static void setCustomProtocolManager(CustomProtocolManager*); 67 #if PLATFORM(COCOA)68 79 static void setSourceApplicationAuditTokenData(RetainPtr<CFDataRef>&&); 69 80 static void setSourceApplicationBundleIdentifier(const String&); … … 75 86 76 87 void clearCredentials(); 77 88 #if PLATFORM(COCOA) 78 89 NetworkDataTask* dataTaskForIdentifier(NetworkDataTask::TaskIdentifier, WebCore::StoredCredentials); 79 90 … … 81 92 DownloadID downloadID(NetworkDataTask::TaskIdentifier); 82 93 DownloadID takeDownloadID(NetworkDataTask::TaskIdentifier); 83 94 #endif 95 84 96 private: 85 97 NetworkSession(Type, WebCore::SessionID, CustomProtocolManager*); 86 WebCore::NetworkStorageSession& networkStorageSession() ;98 WebCore::NetworkStorageSession& networkStorageSession() const; 87 99 88 100 WebCore::SessionID m_sessionID; 89 101 102 #if PLATFORM(COCOA) 90 103 HashMap<NetworkDataTask::TaskIdentifier, NetworkDataTask*> m_dataTaskMapWithCredentials; 91 104 HashMap<NetworkDataTask::TaskIdentifier, NetworkDataTask*> m_dataTaskMapWithoutCredentials; 92 105 HashMap<NetworkDataTask::TaskIdentifier, DownloadID> m_downloadMap; 93 106 94 #if PLATFORM(COCOA)95 107 RetainPtr<NSURLSession> m_sessionWithCredentialStorage; 96 108 RetainPtr<WKNetworkSessionDelegate> m_sessionWithCredentialStorageDelegate; 97 109 RetainPtr<NSURLSession> m_sessionWithoutCredentialStorage; 98 110 RetainPtr<WKNetworkSessionDelegate> m_sessionWithoutCredentialStorageDelegate; 111 #elif USE(SOUP) 112 HashSet<NetworkDataTask*> m_dataTaskSet; 99 113 #endif 100 114 }; 101 115 102 116 } // namespace WebKit 117 118 #endif // USE(NETWORK_SESSION) -
trunk/Source/WebKit2/NetworkProcess/PingLoad.h
r206810 r207586 27 27 #define PingLoad_h 28 28 29 #include "AuthenticationManager.h" 29 30 #include "NetworkDataTask.h" 30 31 #include "SessionTracker.h" -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r207530 r207586 29 29 #if USE(NETWORK_SESSION) 30 30 31 #import "AuthenticationManager.h" 31 32 #import "Download.h" 32 33 #import "DownloadProxyMessages.h" -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r206987 r207586 29 29 #if USE(NETWORK_SESSION) 30 30 31 #import "AuthenticationManager.h" 31 32 #import "CustomProtocolManager.h" 32 33 #import "DataReference.h" … … 476 477 477 478 478 WebCore::NetworkStorageSession& NetworkSession::networkStorageSession() 479 WebCore::NetworkStorageSession& NetworkSession::networkStorageSession() const 479 480 { 480 481 auto* storageSession = WebCore::NetworkStorageSession::storageSession(m_sessionID); -
trunk/Source/WebKit2/NetworkProcess/soup/NetworkSessionSoup.cpp
r207585 r207586 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 University of Szeged. All rights reserved. 4 * Copyright (C) 2013 Company 100 Inc. 2 * Copyright (C) 2016 Igalia S.L. 5 3 * 6 4 * Redistribution and use in source and binary forms, with or without … … 27 25 28 26 #include "config.h" 29 #include " RemoteNetworkingContext.h"27 #include "NetworkSession.h" 30 28 31 29 #include <WebCore/NetworkStorageSession.h> 32 #include <WebCore/ NotImplemented.h>33 #include < WebCore/ResourceHandle.h>30 #include <WebCore/SoupNetworkSession.h> 31 #include <wtf/MainThread.h> 34 32 35 33 using namespace WebCore; … … 37 35 namespace WebKit { 38 36 39 RemoteNetworkingContext::~RemoteNetworkingContext() 37 Ref<NetworkSession> NetworkSession::create(Type type, SessionID sessionID, CustomProtocolManager*) 38 { 39 return adoptRef(*new NetworkSession(type, sessionID, nullptr)); 40 } 41 42 NetworkSession& NetworkSession::defaultSession() 43 { 44 ASSERT(isMainThread()); 45 static NetworkSession* session = &NetworkSession::create(NetworkSession::Type::Normal, SessionID::defaultSessionID(), nullptr).leakRef(); 46 return *session; 47 } 48 49 NetworkStorageSession& NetworkSession::networkStorageSession() const 50 { 51 auto* storageSession = NetworkStorageSession::storageSession(m_sessionID); 52 RELEASE_ASSERT(storageSession); 53 return *storageSession; 54 } 55 56 NetworkSession::NetworkSession(Type type, SessionID sessionID, CustomProtocolManager*) 57 : m_sessionID(sessionID) 40 58 { 41 59 } 42 60 43 bool RemoteNetworkingContext::isValid() const 61 NetworkSession::~NetworkSession() 44 62 { 45 return true;46 63 } 47 64 48 void RemoteNetworkingContext::ensurePrivateBrowsingSession(SessionID) 65 SoupSession* NetworkSession::soupSession() const 49 66 { 50 notImplemented();67 return networkStorageSession().soupNetworkSession().soupSession(); 51 68 } 52 69 53 NetworkStorageSession& RemoteNetworkingContext::storageSession() const 70 void NetworkSession::invalidateAndCancel() 54 71 { 55 return NetworkStorageSession::defaultStorageSession(); 72 for (auto* task : m_dataTaskSet) 73 task->invalidateAndCancel(); 56 74 } 57 75 76 void NetworkSession::clearCredentials() 77 { 58 78 } 79 80 } // namespace WebKit -
trunk/Source/WebKit2/NetworkProcess/soup/RemoteNetworkingContextSoup.cpp
r192697 r207586 29 29 #include "RemoteNetworkingContext.h" 30 30 31 #include "NetworkSession.h" 32 #include "SessionTracker.h" 31 33 #include <WebCore/NetworkStorageSession.h> 32 34 #include <WebCore/NotImplemented.h> … … 46 48 } 47 49 48 void RemoteNetworkingContext::ensurePrivateBrowsingSession(SessionID )50 void RemoteNetworkingContext::ensurePrivateBrowsingSession(SessionID sessionID) 49 51 { 50 notImplemented(); 52 ASSERT(sessionID.isEphemeral()); 53 54 if (NetworkStorageSession::storageSession(sessionID)) 55 return; 56 57 NetworkStorageSession::ensurePrivateBrowsingSession(sessionID, String::number(sessionID.sessionID())); 58 SessionTracker::setSession(sessionID, NetworkSession::create(NetworkSession::Type::Ephemeral, sessionID, nullptr)); 51 59 } 52 60 53 61 NetworkStorageSession& RemoteNetworkingContext::storageSession() const 54 62 { 63 if (auto session = NetworkStorageSession::storageSession(m_sessionID)) 64 return *session; 55 65 return NetworkStorageSession::defaultStorageSession(); 56 66 } -
trunk/Source/WebKit2/PlatformEfl.cmake
r206331 r207586 15 15 NetworkProcess/efl/NetworkProcessMainEfl.cpp 16 16 17 NetworkProcess/soup/NetworkDataTaskSoup.cpp 17 18 NetworkProcess/soup/NetworkProcessSoup.cpp 19 NetworkProcess/soup/NetworkSessionSoup.cpp 18 20 NetworkProcess/soup/RemoteNetworkingContextSoup.cpp 19 21 -
trunk/Source/WebKit2/PlatformGTK.cmake
r206331 r207586 40 40 NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp 41 41 42 NetworkProcess/soup/NetworkDataTaskSoup.cpp 42 43 NetworkProcess/soup/NetworkProcessMainSoup.cpp 43 44 NetworkProcess/soup/NetworkProcessSoup.cpp 45 NetworkProcess/soup/NetworkSessionSoup.cpp 44 46 NetworkProcess/soup/RemoteNetworkingContextSoup.cpp 45 47 -
trunk/Source/WebKit2/Shared/Authentication/AuthenticationManager.h
r206583 r207586 29 29 #include "MessageReceiver.h" 30 30 #include "NetworkProcessSupplement.h" 31 #include "NetworkSession.h"32 31 #include "WebProcessSupplement.h" 33 32 #include <WebCore/AuthenticationChallenge.h> 34 33 #include <wtf/Forward.h> 34 #include <wtf/Function.h> 35 35 #include <wtf/HashMap.h> 36 36 … … 48 48 class PendingDownload; 49 49 class WebFrame; 50 51 enum class AuthenticationChallengeDisposition { 52 UseCredential, 53 PerformDefaultHandling, 54 Cancel, 55 RejectProtectionSpace 56 }; 57 typedef Function<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> ChallengeCompletionHandler; 50 58 51 59 class AuthenticationManager : public WebProcessSupplement, public NetworkProcessSupplement, public IPC::MessageReceiver { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
r204466 r207586 28 28 #include "WebFrameNetworkingContext.h" 29 29 30 #include "NetworkSession.h" 30 31 #include "SessionTracker.h" 31 32 #include "WebFrame.h" … … 44 45 { 45 46 ASSERT(isMainThread()); 47 ASSERT(sessionID.isEphemeral()); 46 48 47 49 if (NetworkStorageSession::storageSession(sessionID)) … … 49 51 50 52 NetworkStorageSession::ensurePrivateBrowsingSession(sessionID, String::number(sessionID.sessionID())); 53 SessionTracker::setSession(sessionID, NetworkSession::create(NetworkSession::Type::Ephemeral, sessionID, nullptr)); 51 54 } 52 55 -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r206811 r207586 38 38 #include "NetworkConnectionToWebProcessMessages.h" 39 39 #include "NetworkProcessConnection.h" 40 #include "NetworkSession.h" 40 41 #include "PluginProcessConnectionManager.h" 41 42 #include "SessionTracker.h" -
trunk/Source/WebKit2/config.h
r205556 r207586 76 76 #endif 77 77 78 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) 78 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || USE(SOUP) 79 79 #ifndef USE_NETWORK_SESSION 80 80 #define USE_NETWORK_SESSION 1
Note: See TracChangeset
for help on using the changeset viewer.