Changeset 167853 in webkit
- Timestamp:
- Apr 27, 2014 4:53:43 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r167852 r167853 1 2014-04-27 Antti Koivisto <antti@apple.com> 2 3 Coalesce responses on network process side 4 https://bugs.webkit.org/show_bug.cgi?id=132229 5 6 Reviewed by Andreas Kling. 7 8 * WebCore.exp.in: 9 1 10 2014-04-27 David Kilzer <ddkilzer@apple.com> 2 11 -
trunk/Source/WebCore/WebCore.exp.in
r167825 r167853 234 234 __ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE 235 235 __ZN7WebCore12SharedBuffer6appendEPKcj 236 __ZN7WebCore12SharedBuffer6appendEPS0_ 236 237 __ZN7WebCore12SharedBufferC1EPKcj 237 238 __ZN7WebCore12SharedBufferC1EPKhj -
trunk/Source/WebKit2/ChangeLog
r167849 r167853 1 2014-04-27 Antti Koivisto <antti@apple.com> 2 3 Coalesce responses on network process side 4 https://bugs.webkit.org/show_bug.cgi?id=132229 5 6 Reviewed by Andreas Kling. 7 8 To reduce IPC we should coalesce response data in the network process and send it over with single IPC call. 9 10 * NetworkProcess/AsynchronousNetworkLoaderClient.cpp: 11 (WebKit::AsynchronousNetworkLoaderClient::AsynchronousNetworkLoaderClient): 12 (WebKit::AsynchronousNetworkLoaderClient::didReceiveResponse): 13 (WebKit::AsynchronousNetworkLoaderClient::didReceiveBuffer): 14 (WebKit::AsynchronousNetworkLoaderClient::didFinishLoading): 15 (WebKit::AsynchronousNetworkLoaderClient::didFail): 16 (WebKit::AsynchronousNetworkLoaderClient::dispatchPartialCoalescedResponse): 17 (WebKit::AsynchronousNetworkLoaderClient::clearCoalescedResponse): 18 (WebKit::AsynchronousNetworkLoaderClient::responseCoalesceTimerFired): 19 20 Coalesce the response. Completed response is sent on didFinishLoading. If the coalesce timer fires 21 before that the data accumulated so far is dispatched. 22 23 * NetworkProcess/AsynchronousNetworkLoaderClient.h: 24 * NetworkProcess/NetworkResourceLoader.h: 25 * WebProcess/Network/WebResourceLoader.cpp: 26 (WebKit::WebResourceLoader::didReceiveCompleteResponse): 27 * WebProcess/Network/WebResourceLoader.h: 28 * WebProcess/Network/WebResourceLoader.messages.in: 29 30 Add a new message type that covers didReceiveResponse, didReceiveBuffer and didFinishLoading in a single message. 31 1 32 2014-04-26 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.cpp
r161148 r167853 43 43 44 44 AsynchronousNetworkLoaderClient::AsynchronousNetworkLoaderClient() 45 : m_responseCoalescingTimer(RunLoop::main(), this, &AsynchronousNetworkLoaderClient::responseCoalescingTimerFired) 46 , m_coalescingLoader(nullptr) 47 , m_coalescingResponseEncodedDataLength(0) 45 48 { 46 49 } … … 64 67 void AsynchronousNetworkLoaderClient::didReceiveResponse(NetworkResourceLoader* loader, const ResourceResponse& response) 65 68 { 69 if (!loader->isLoadingMainResource()) { 70 ASSERT(!m_coalescingLoader); 71 m_coalescingResponse = response; 72 m_coalescingLoader = loader; 73 74 // FIXME: Some resources can only be used when completely loaded. We should always delay those until completion. 75 static const double responseCoalescingTime = 0.1; 76 m_responseCoalescingTimer.startOneShot(responseCoalescingTime); 77 return; 78 } 79 66 80 loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(response, CertificateInfo(response), loader->isLoadingMainResource())); 67 81 } … … 73 87 NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(shareableResourceHandle, buffer); 74 88 if (!shareableResourceHandle.isNull()) { 89 if (m_responseCoalescingTimer.isActive()) { 90 ASSERT(!m_coalescingResponse.isNull()); 91 ASSERT(!m_coalescingResponseData); 92 loader->send(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(m_coalescingResponse, CertificateInfo(m_coalescingResponse), false)); 93 clearCoalescedResponse(); 94 } 75 95 // 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. 76 96 loader->abort(); … … 79 99 } 80 100 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 101 102 if (m_responseCoalescingTimer.isActive()) { 103 ASSERT(m_coalescingLoader == loader); 104 ASSERT(!m_coalescingResponse.isNull()); 105 if (m_coalescingResponseData) 106 m_coalescingResponseData->append(buffer); 107 else 108 m_coalescingResponseData = buffer; 109 m_coalescingResponseEncodedDataLength += encodedDataLength; 110 return; 111 } 81 112 82 113 IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size()); … … 91 122 void AsynchronousNetworkLoaderClient::didFinishLoading(NetworkResourceLoader* loader, double finishTime) 92 123 { 124 if (m_responseCoalescingTimer.isActive()) { 125 ASSERT(!m_coalescingResponse.isNull()); 126 IPC::DataReference dataReference; 127 if (m_coalescingResponseData) 128 dataReference = IPC::DataReference(reinterpret_cast<const uint8_t*>(m_coalescingResponseData->data()), m_coalescingResponseData->size()); 129 130 loader->send(Messages::WebResourceLoader::DidReceiveCompleteResponse(m_coalescingResponse, CertificateInfo(m_coalescingResponse), dataReference, m_coalescingResponseEncodedDataLength, finishTime)); 131 clearCoalescedResponse(); 132 return; 133 } 134 93 135 loader->send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime)); 94 136 } … … 96 138 void AsynchronousNetworkLoaderClient::didFail(NetworkResourceLoader* loader, const ResourceError& error) 97 139 { 140 if (m_responseCoalescingTimer.isActive()) 141 dispatchPartialCoalescedResponse(loader); 142 98 143 loader->send(Messages::WebResourceLoader::DidFailResourceLoad(error)); 99 144 } 145 146 void AsynchronousNetworkLoaderClient::dispatchPartialCoalescedResponse(NetworkResourceLoader* loader) 147 { 148 ASSERT(m_coalescingLoader == loader); 149 ASSERT(!m_coalescingResponse.isNull()); 150 loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(m_coalescingResponse, CertificateInfo(m_coalescingResponse), false)); 151 152 if (m_coalescingResponseData) { 153 IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(m_coalescingResponseData->data()), m_coalescingResponseData->size()); 154 loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, m_coalescingResponseEncodedDataLength)); 155 } 156 157 clearCoalescedResponse(); 158 } 159 160 void AsynchronousNetworkLoaderClient::clearCoalescedResponse() 161 { 162 m_coalescingResponse = ResourceResponse(); 163 m_coalescingLoader = nullptr; 164 m_coalescingResponseData = nullptr; 165 m_coalescingResponseEncodedDataLength = 0; 166 m_responseCoalescingTimer.stop(); 167 } 168 169 void AsynchronousNetworkLoaderClient::responseCoalescingTimerFired() 170 { 171 ASSERT(m_coalescingLoader); 172 dispatchPartialCoalescedResponse(m_coalescingLoader); 173 } 174 100 175 101 176 } // namespace WebKit -
trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.h
r162139 r167853 29 29 #include "NetworkLoaderClient.h" 30 30 #include "ShareableResource.h" 31 #include <WebCore/ResourceResponse.h> 32 #include <wtf/RunLoop.h> 31 33 32 34 #if ENABLE(NETWORK_PROCESS) … … 48 50 virtual void didFinishLoading(NetworkResourceLoader*, double finishTime) override; 49 51 virtual void didFail(NetworkResourceLoader*, const WebCore::ResourceError&) override; 52 53 void dispatchPartialCoalescedResponse(NetworkResourceLoader*); 54 void clearCoalescedResponse(); 55 void responseCoalescingTimerFired(); 56 57 RunLoop::Timer<AsynchronousNetworkLoaderClient> m_responseCoalescingTimer; 58 NetworkResourceLoader* m_coalescingLoader; 59 WebCore::ResourceResponse m_coalescingResponse; 60 RefPtr<WebCore::SharedBuffer> m_coalescingResponseData; 61 long long m_coalescingResponseEncodedDataLength; 50 62 }; 51 63 -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
r167793 r167853 36 36 #include <WebCore/ResourceLoaderOptions.h> 37 37 #include <WebCore/ResourceRequest.h> 38 #include <WebCore/ResourceResponse.h> 38 39 #include <WebCore/SessionID.h> 39 40 #include <wtf/MainThread.h> -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
r167188 r167853 131 131 } 132 132 133 void WebResourceLoader::didReceiveCompleteResponse(const ResourceResponse& response, const CertificateInfo& certificateInfo, const IPC::DataReference& data, int64_t encodedDataLength, double finishTime) 134 { 135 LOG(Network, "(WebProcess) WebResourceLoader::didReceiveCompleteResponse for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode()); 136 137 Ref<WebResourceLoader> protect(*this); 138 139 didReceiveResponseWithCertificateInfo(response, certificateInfo, false); 140 if (!m_coreLoader) 141 return; 142 if (!data.isEmpty()) 143 didReceiveData(data, encodedDataLength); 144 if (!m_coreLoader) 145 return; 146 didFinishResourceLoad(finishTime); 147 } 148 133 149 void WebResourceLoader::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength) 134 150 { -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h
r167207 r167853 82 82 void didSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent); 83 83 void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const WebCore::CertificateInfo&, bool needsContinueDidReceiveResponseMessage); 84 void didReceiveCompleteResponse(const WebCore::ResourceResponse&, const WebCore::CertificateInfo&, const IPC::DataReference&, int64_t encodedDataLength, double finishTime); 84 85 void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength); 85 86 void didFinishResourceLoad(double finishTime); -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in
r161148 r167853 31 31 DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent) 32 32 DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebCore::CertificateInfo certificateInfo, bool needsContinueDidReceiveResponseMessage) 33 DidReceiveCompleteResponse(WebCore::ResourceResponse response, WebCore::CertificateInfo certificateInfo, IPC::DataReference data, int64_t encodedDataLength, double finishTime) 33 34 DidReceiveData(IPC::DataReference data, int64_t encodedDataLength) 34 35 DidFinishResourceLoad(double finishTime)
Note: See TracChangeset
for help on using the changeset viewer.