Changeset 173115 in webkit
- Timestamp:
- Aug 29, 2014 11:15:04 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/CMakeLists.txt
r172927 r173115 146 146 147 147 set(WebKit2_SOURCES 148 NetworkProcess/AsynchronousNetworkLoaderClient.cpp149 148 NetworkProcess/NetworkConnectionToWebProcess.cpp 150 149 NetworkProcess/NetworkProcess.cpp … … 152 151 NetworkProcess/NetworkResourceLoadScheduler.cpp 153 152 NetworkProcess/NetworkResourceLoader.cpp 154 NetworkProcess/SynchronousNetworkLoaderClient.cpp155 153 156 154 NetworkProcess/FileAPI/NetworkBlobRegistry.cpp -
trunk/Source/WebKit2/ChangeLog
r173113 r173115 1 2014-08-29 Antti Koivisto <antti@apple.com> 2 3 Remove NetworkResourceLoaderClient and subclasses. 4 https://bugs.webkit.org/show_bug.cgi?id=136370 5 6 Reviewed by Darin Adler. 7 8 This code is needlessly abstract. Move what logic these classes have to NetworkResourceLoader. 9 10 * NetworkProcess/AsynchronousNetworkLoaderClient.cpp: Removed. 11 * NetworkProcess/AsynchronousNetworkLoaderClient.h: Removed. 12 * NetworkProcess/NetworkLoaderClient.h: Removed. 13 * NetworkProcess/NetworkResourceLoader.cpp: 14 (WebKit::NetworkResourceLoader::NetworkResourceLoader): 15 (WebKit::NetworkResourceLoader::~NetworkResourceLoader): 16 (WebKit::NetworkResourceLoader::isSynchronous): 17 (WebKit::NetworkResourceLoader::didReceiveResponseAsync): 18 (WebKit::NetworkResourceLoader::didReceiveBuffer): 19 (WebKit::NetworkResourceLoader::didFinishLoading): 20 (WebKit::NetworkResourceLoader::didFail): 21 (WebKit::NetworkResourceLoader::willSendRequestAsync): 22 (WebKit::NetworkResourceLoader::didSendData): 23 (WebKit::NetworkResourceLoader::sendBuffer): 24 (WebKit::NetworkResourceLoader::sendReplyToSynchronousRequest): 25 (WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync): 26 * NetworkProcess/NetworkResourceLoader.h: 27 (WebKit::NetworkResourceLoader::SynchronousLoadData::SynchronousLoadData): 28 * NetworkProcess/SynchronousNetworkLoaderClient.cpp: Removed. 29 * NetworkProcess/SynchronousNetworkLoaderClient.h: Removed. 30 * WebKit2.xcodeproj/project.pbxproj: 31 1 32 2014-08-29 Csaba Osztrogonác <ossy@webkit.org> 2 33 -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
r172946 r173115 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if ENABLE(NETWORK_PROCESS) 30 30 31 #include "AsynchronousNetworkLoaderClient.h"32 31 #include "AuthenticationManager.h" 33 32 #include "DataReference.h" … … 41 40 #include "ShareableResource.h" 42 41 #include "SharedMemory.h" 43 #include "SynchronousNetworkLoaderClient.h"44 42 #include "WebCoreArgumentCoders.h" 45 43 #include "WebErrors.h" 46 44 #include "WebResourceLoaderMessages.h" 47 45 #include <WebCore/BlobDataFileReference.h> 46 #include <WebCore/CertificateInfo.h> 48 47 #include <WebCore/NotImplemented.h> 49 48 #include <WebCore/ResourceBuffer.h> 50 49 #include <WebCore/ResourceHandle.h> 51 50 #include <WebCore/SharedBuffer.h> 51 #include <WebCore/SynchronousLoaderClient.h> 52 #include <wtf/CurrentTime.h> 52 53 #include <wtf/MainThread.h> 53 54 … … 55 56 56 57 namespace WebKit { 58 59 struct NetworkResourceLoader::SynchronousLoadData { 60 SynchronousLoadData(WebCore::ResourceRequest& request, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply> reply) 61 : m_originalRequest(request) 62 , m_delayedReply(reply) 63 { 64 ASSERT(m_delayedReply); 65 } 66 WebCore::ResourceRequest m_originalRequest; 67 WebCore::ResourceRequest m_currentRequest; 68 RefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply> m_delayedReply; 69 WebCore::ResourceResponse m_response; 70 WebCore::ResourceError m_error; 71 }; 72 73 static void sendReplyToSynchronousRequest(NetworkResourceLoader::SynchronousLoadData& data, WebCore::SharedBuffer* buffer) 74 { 75 ASSERT(data.m_delayedReply); 76 ASSERT(!data.m_response.isNull() || !data.m_error.isNull()); 77 78 Vector<char> responseBuffer; 79 if (buffer && buffer->size()) 80 responseBuffer.append(buffer->data(), buffer->size()); 81 82 data.m_delayedReply->send(data.m_error, data.m_response, responseBuffer); 83 data.m_delayedReply = nullptr; 84 } 57 85 58 86 NetworkResourceLoader::NetworkResourceLoader(const NetworkResourceLoadParameters& parameters, NetworkConnectionToWebProcess* connection, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply> reply) … … 104 132 105 133 if (reply) 106 m_networkLoaderClient = std::make_unique<SynchronousNetworkLoaderClient>(m_request, reply); 107 else 108 m_networkLoaderClient = std::make_unique<AsynchronousNetworkLoaderClient>(); 134 m_synchronousLoadData = std::make_unique<SynchronousLoadData>(m_request, reply); 109 135 } 110 136 … … 113 139 ASSERT(RunLoop::isMain()); 114 140 ASSERT(!m_handle); 141 ASSERT(!isSynchronous() || !m_synchronousLoadData->m_delayedReply); 115 142 } 116 143 117 144 bool NetworkResourceLoader::isSynchronous() const 118 145 { 119 return m_networkLoaderClient->isSynchronous();146 return !!m_synchronousLoadData; 120 147 } 121 148 … … 190 217 ASSERT_UNUSED(handle, handle == m_handle); 191 218 192 m_networkLoaderClient->didReceiveResponse(this, response); 193 194 // m_handle will be 0 if the request got aborted above. 219 if (isSynchronous()) 220 m_synchronousLoadData->m_response = response; 221 else 222 sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(response, CertificateInfo(response), isLoadingMainResource())); 223 224 // m_handle will be null if the request got aborted above. 195 225 if (!m_handle) 196 226 return; … … 213 243 ASSERT_UNUSED(handle, handle == m_handle); 214 244 215 // FIXME (NetworkProcess): For the memory cache we'll also need to cache the response data here.216 // Such buffering will need to be thread safe, as this callback is happening on a background thread.217 218 245 m_bytesReceived += buffer->size(); 219 if (m_bufferedData) 246 if (m_bufferedData) { 220 247 m_bufferedData->append(buffer.get()); 221 else 222 m_networkLoaderClient->didReceiveBuffer(this, buffer.get(), encodedDataLength); 248 return; 249 } 250 sendBuffer(buffer.get(), encodedDataLength); 223 251 } 224 252 … … 227 255 ASSERT_UNUSED(handle, handle == m_handle); 228 256 229 // Send the full resource data if we were buffering it. 230 if (m_bufferedData && m_bufferedData->size()) 231 m_networkLoaderClient->didReceiveBuffer(this, m_bufferedData.get(), m_bufferedData->size()); 232 233 m_networkLoaderClient->didFinishLoading(this, finishTime); 257 if (isSynchronous()) 258 sendReplyToSynchronousRequest(*m_synchronousLoadData, m_bufferedData.get()); 259 else { 260 if (m_bufferedData && m_bufferedData->size()) 261 sendBuffer(m_bufferedData.get(), m_bufferedData->size()); 262 send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime)); 263 } 234 264 235 265 cleanup(); … … 240 270 ASSERT_UNUSED(handle, handle == m_handle); 241 271 242 m_networkLoaderClient->didFail(this, error); 272 if (isSynchronous()) { 273 m_synchronousLoadData->m_error = error; 274 sendReplyToSynchronousRequest(*m_synchronousLoadData, nullptr); 275 } else 276 send(Messages::WebResourceLoader::DidFailResourceLoad(error)); 243 277 244 278 cleanup(); … … 253 287 ASSERT(RunLoop::isMain()); 254 288 255 ResourceRequest proposedRequest = request;256 289 m_suggestedRequestForWillSendRequest = request; 257 290 258 m_networkLoaderClient->willSendRequest(this, proposedRequest, redirectResponse); 291 if (isSynchronous()) { 292 // FIXME: This needs to be fixed to follow the redirect correctly even for cross-domain requests. 293 // This includes at least updating host records, and comparing the current request instead of the original request here. 294 if (protocolHostAndPortAreEqual(m_synchronousLoadData->m_originalRequest.url(), request.url())) 295 m_synchronousLoadData->m_currentRequest = request; 296 else { 297 ASSERT(m_synchronousLoadData->m_error.isNull()); 298 m_synchronousLoadData->m_error = SynchronousLoaderClient::platformBadResponseError(); 299 m_synchronousLoadData->m_currentRequest = ResourceRequest(); 300 } 301 continueWillSendRequest(m_synchronousLoadData->m_currentRequest); 302 return; 303 } 304 sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(request, redirectResponse)); 259 305 } 260 306 … … 293 339 ASSERT_UNUSED(handle, handle == m_handle); 294 340 295 m_networkLoaderClient->didSendData(this, bytesSent, totalBytesToBeSent); 341 if (!isSynchronous()) 342 send(Messages::WebResourceLoader::DidSendData(bytesSent, totalBytesToBeSent)); 296 343 } 297 344 … … 351 398 m_handle->cancel(); 352 399 didFail(m_handle.get(), cancelledError(m_request)); 400 } 401 402 void NetworkResourceLoader::sendBuffer(WebCore::SharedBuffer* buffer, int encodedDataLength) 403 { 404 ASSERT(!isSynchronous()); 405 406 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) 407 ShareableResource::Handle shareableResourceHandle; 408 NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(shareableResourceHandle, buffer); 409 if (!shareableResourceHandle.isNull()) { 410 // Since we're delivering this resource by ourselves all at once and don't need anymore data or callbacks from the network layer, abort the loader. 411 abort(); 412 send(Messages::WebResourceLoader::DidReceiveResource(shareableResourceHandle, currentTime())); 413 return; 414 } 415 #endif 416 IPC::SharedBufferDataReference dataReference(buffer); 417 sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength)); 353 418 } 354 419 … … 396 461 ASSERT_UNUSED(handle, handle == m_handle); 397 462 398 m_networkLoaderClient->canAuthenticateAgainstProtectionSpace(this, protectionSpace); 463 if (isSynchronous()) { 464 // FIXME: We should ask the WebProcess like the asynchronous case below does. 465 // This is currently impossible as the WebProcess is blocked waiting on this synchronous load. 466 // It's possible that we can jump straight to the UI process to resolve this. 467 continueCanAuthenticateAgainstProtectionSpace(true); 468 return; 469 } 470 sendAbortingOnFailure(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(protectionSpace)); 399 471 } 400 472 … … 403 475 m_handle->continueCanAuthenticateAgainstProtectionSpace(result); 404 476 } 405 406 477 #endif 407 478 -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
r172946 r173115 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "NetworkResourceLoadParameters.h" 34 34 #include "ShareableResource.h" 35 #include <WebCore/ResourceError.h> 35 36 #include <WebCore/ResourceHandleClient.h> 36 37 #include <WebCore/ResourceLoaderOptions.h> 37 38 #include <WebCore/ResourceRequest.h> 39 #include <WebCore/ResourceResponse.h> 38 40 #include <WebCore/SessionID.h> 39 41 #include <wtf/MainThread.h> … … 52 54 53 55 class NetworkConnectionToWebProcess; 54 class NetworkLoaderClient;55 56 class NetworkResourceLoadParameters; 56 57 class RemoteNetworkingContext; … … 146 147 WebCore::SharedBuffer* bufferedData() const { return m_bufferedData.get(); } 147 148 149 struct SynchronousLoadData; 150 148 151 private: 149 152 NetworkResourceLoader(const NetworkResourceLoadParameters&, NetworkConnectionToWebProcess*, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>); … … 159 162 void platformDidReceiveResponse(const WebCore::ResourceResponse&); 160 163 164 void sendBuffer(WebCore::SharedBuffer*, int encodedDataLength); 165 161 166 void consumeSandboxExtensions(); 162 167 void invalidateSandboxExtensions(); … … 171 176 172 177 bool m_handleConvertedToDownload; 173 std::unique_ptr<NetworkLoaderClient> m_networkLoaderClient; 178 179 std::unique_ptr<SynchronousLoadData> m_synchronousLoadData; 174 180 175 181 ResourceLoadIdentifier m_identifier; -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r172979 r173115 995 995 51FA2D7715212E2600C1BA0B /* WKBundleDOMWindowExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FA2D7515212E1E00C1BA0B /* WKBundleDOMWindowExtension.cpp */; }; 996 996 51FB08FF1639DE1A00EC324A /* WebResourceLoadScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ABF65616392F1500132A7A /* WebResourceLoadScheduler.cpp */; }; 997 51FCB18517BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCB18017BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp */; };998 51FCB18617BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FCB18117BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h */; };999 51FCB18717BBFE0300394CD8 /* NetworkLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FCB18217BBFE0300394CD8 /* NetworkLoaderClient.h */; };1000 51FCB18817BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCB18317BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp */; };1001 51FCB18917BBFE0300394CD8 /* SynchronousNetworkLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FCB18417BBFE0300394CD8 /* SynchronousNetworkLoaderClient.h */; };1002 997 51FD18B51651FBAD00DBE1CE /* NetworkResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FD18B31651FBAD00DBE1CE /* NetworkResourceLoader.cpp */; }; 1003 998 51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */; }; … … 3035 3030 51FA2D7515212E1E00C1BA0B /* WKBundleDOMWindowExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleDOMWindowExtension.cpp; sourceTree = "<group>"; }; 3036 3031 51FB0902163A3B1C00EC324A /* NetworkProcessConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = NetworkProcessConnection.messages.in; path = Network/NetworkProcessConnection.messages.in; sourceTree = "<group>"; }; 3037 51FCB18017BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AsynchronousNetworkLoaderClient.cpp; path = NetworkProcess/AsynchronousNetworkLoaderClient.cpp; sourceTree = "<group>"; };3038 51FCB18117BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsynchronousNetworkLoaderClient.h; path = NetworkProcess/AsynchronousNetworkLoaderClient.h; sourceTree = "<group>"; };3039 51FCB18217BBFE0300394CD8 /* NetworkLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoaderClient.h; path = NetworkProcess/NetworkLoaderClient.h; sourceTree = "<group>"; };3040 51FCB18317BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SynchronousNetworkLoaderClient.cpp; path = NetworkProcess/SynchronousNetworkLoaderClient.cpp; sourceTree = "<group>"; };3041 51FCB18417BBFE0300394CD8 /* SynchronousNetworkLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SynchronousNetworkLoaderClient.h; path = NetworkProcess/SynchronousNetworkLoaderClient.h; sourceTree = "<group>"; };3042 3032 51FD18B31651FBAD00DBE1CE /* NetworkResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkResourceLoader.cpp; path = NetworkProcess/NetworkResourceLoader.cpp; sourceTree = "<group>"; }; 3043 3033 51FD18B41651FBAD00DBE1CE /* NetworkResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkResourceLoader.h; path = NetworkProcess/NetworkResourceLoader.h; sourceTree = "<group>"; }; … … 5177 5167 E1798C7616E6815500240139 /* FileAPI */, 5178 5168 510CC7DC16138E2900D03ED3 /* mac */, 5179 51FCB18017BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp */,5180 51FCB18117BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h */,5181 5169 513A16491630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp */, 5182 5170 513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */, 5183 5171 513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */, 5184 51FCB18217BBFE0300394CD8 /* NetworkLoaderClient.h */,5185 5172 510CC7DF16138E2900D03ED3 /* NetworkProcess.cpp */, 5186 5173 510CC7E016138E2900D03ED3 /* NetworkProcess.h */, … … 5194 5181 51829DA41637C70C000953D6 /* NetworkResourceLoadScheduler.h */, 5195 5182 E1B78470163F24690007B692 /* RemoteNetworkingContext.h */, 5196 51FCB18317BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp */,5197 51FCB18417BBFE0300394CD8 /* SynchronousNetworkLoaderClient.h */,5198 5183 ); 5199 5184 name = NetworkProcess; … … 7218 7203 1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */, 7219 7204 1A232903162C867300D82F7A /* MessageDecoder.h in Headers */, 7220 51FCB18617BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h in Headers */,7221 7205 1A3CC16918907EB0001E6ED8 /* WKProcessPoolInternal.h in Headers */, 7222 7206 2D1B5D5E185869C8006C6596 /* ViewGestureControllerMessages.h in Headers */, … … 7289 7273 C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */, 7290 7274 E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */, 7291 51FCB18917BBFE0300394CD8 /* SynchronousNetworkLoaderClient.h in Headers */,7292 7275 1AE00D4F182D6F5000087DD7 /* WKBrowsingContextHandleInternal.h in Headers */, 7293 7276 BCC43ABB127B95DC00317F16 /* PlatformPopupMenuData.h in Headers */, … … 7765 7748 A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */, 7766 7749 370F34A51829BEA3009027C8 /* WKNavigationDataInternal.h in Headers */, 7767 51FCB18717BBFE0300394CD8 /* NetworkLoaderClient.h in Headers */,7768 7750 7C135AA9173B0BCA00586AE2 /* WKPluginInformation.h in Headers */, 7769 7751 1AC86FF4130B46D3002C1257 /* WKPluginSiteDataManager.h in Headers */, … … 9310 9292 BC90A1D3122DD55E00CC8C50 /* APIURLResponse.cpp in Sources */, 9311 9293 C0337DD1127A2980008FF4F4 /* WebWheelEvent.cpp in Sources */, 9312 51FCB18517BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp in Sources */,9313 9294 29CD55AB128E294F00133C85 /* WKAccessibilityWebPageObjectBase.mm in Sources */, 9314 9295 1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */, … … 9417 9398 BC85806312B8505700EDEB2E /* WKOpenPanelParameters.cpp in Sources */, 9418 9399 BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */, 9419 51FCB18817BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp in Sources */,9420 9400 3F418EFB1887BD97002795FD /* WebVideoFullscreenManagerProxyMessageReceiver.cpp in Sources */, 9421 9401 BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.