Title: [205052] trunk/Source/WebKit2
Revision
205052
Author
ander...@apple.com
Date
2016-08-26 15:16:36 -0700 (Fri, 26 Aug 2016)

Log Message

Get rid of NetworkResourceLoader::sendAbortingOnFailure
https://bugs.webkit.org/show_bug.cgi?id=161267

Reviewed by Dan Bernstein.

NetworkResourceLoader::sendAbortingOnFailure sends an IPC message, and if IPC::Connection::send returns false,
it will abort the network resource load.

IPC::Connection::send will only return false if the connection is invalid, and when it becomes invalidated the
connection client member function "didClose" is invoked. For the network process, this will call abort on all outstanding
network loads.

Auditing all the sendAbortingOnFailure call sites, shows that none of them can be called with an invalid connection,
so replace sendAbortingOnFailure with send.

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveResponse):
This is a NetworkLoadClient function which won't be called if the load has been aborted.

(WebKit::NetworkResourceLoader::didReceiveBuffer):
Ditto.

(WebKit::NetworkResourceLoader::didFinishLoading):
Ditto. Also, update a call to sendBufferMaybeAborting to sendBuffer.

(WebKit::NetworkResourceLoader::willSendRedirectedRequest):
This is another NetworkLoadClient function.

(WebKit::NetworkResourceLoader::bufferingTimerFired):
The buffering timer is stopped when abort() is called.

(WebKit::NetworkResourceLoader::sendBuffer):
Rename this from sendBufferMaybeAborting. It has three call sites:
- didReceiveBuffer and didFinishLoading are both NetworkLoadClient functions.
- didRetrieveCacheEntry is called from didFinishLoading (a NetworkLoadClient function) and from
  the completion function of retrieveCacheEntry, which has an early return for when the loader has been aborted.

(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
This is called from the retrieveCacheEntry completion function, which has an early return for when the loader has been aborted.

(WebKit::NetworkResourceLoader::dispatchWillSendRequestForCacheEntry):
Ditto.

(WebKit::NetworkResourceLoader::sendAbortingOnFailure): Deleted.
* NetworkProcess/NetworkResourceLoader.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (205051 => 205052)


--- trunk/Source/WebKit2/ChangeLog	2016-08-26 22:07:04 UTC (rev 205051)
+++ trunk/Source/WebKit2/ChangeLog	2016-08-26 22:16:36 UTC (rev 205052)
@@ -1,3 +1,51 @@
+2016-08-26  Anders Carlsson  <ander...@apple.com>
+
+        Get rid of NetworkResourceLoader::sendAbortingOnFailure
+        https://bugs.webkit.org/show_bug.cgi?id=161267
+
+        Reviewed by Dan Bernstein.
+
+        NetworkResourceLoader::sendAbortingOnFailure sends an IPC message, and if IPC::Connection::send returns false,
+        it will abort the network resource load.
+
+        IPC::Connection::send will only return false if the connection is invalid, and when it becomes invalidated the
+        connection client member function "didClose" is invoked. For the network process, this will call abort on all outstanding
+        network loads.
+
+        Auditing all the sendAbortingOnFailure call sites, shows that none of them can be called with an invalid connection,
+        so replace sendAbortingOnFailure with send.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didReceiveResponse):
+        This is a NetworkLoadClient function which won't be called if the load has been aborted.
+
+        (WebKit::NetworkResourceLoader::didReceiveBuffer):
+        Ditto.
+
+        (WebKit::NetworkResourceLoader::didFinishLoading):
+        Ditto. Also, update a call to sendBufferMaybeAborting to sendBuffer.
+
+        (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
+        This is another NetworkLoadClient function.
+
+        (WebKit::NetworkResourceLoader::bufferingTimerFired):
+        The buffering timer is stopped when abort() is called.
+
+        (WebKit::NetworkResourceLoader::sendBuffer):
+        Rename this from sendBufferMaybeAborting. It has three call sites:
+        - didReceiveBuffer and didFinishLoading are both NetworkLoadClient functions.
+        - didRetrieveCacheEntry is called from didFinishLoading (a NetworkLoadClient function) and from
+          the completion function of retrieveCacheEntry, which has an early return for when the loader has been aborted.
+
+        (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
+        This is called from the retrieveCacheEntry completion function, which has an early return for when the loader has been aborted.
+
+        (WebKit::NetworkResourceLoader::dispatchWillSendRequestForCacheEntry):
+        Ditto.
+
+        (WebKit::NetworkResourceLoader::sendAbortingOnFailure): Deleted.
+        * NetworkProcess/NetworkResourceLoader.h:
+
 2016-08-26  Dan Bernstein  <m...@apple.com>
 
         [Cocoa] Infinite recursion calling -charValue on a WKNSNumber

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (205051 => 205052)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2016-08-26 22:07:04 UTC (rev 205051)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2016-08-26 22:16:36 UTC (rev 205052)
@@ -323,10 +323,7 @@
             m_synchronousLoadData->response = m_response;
         else {
             RELEASE_LOG_IF_ALLOWED("Sending didReceiveResponse message to the WebContent process: loader = %p, pageID = %llu, frameID = %llu, isMainResource = %d, isSynchronous = %d", this, static_cast<unsigned long long>(m_parameters.webPageID), static_cast<unsigned long long>(m_parameters.webFrameID), isMainResource(), isSynchronous());
-            if (!sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(m_response, shouldWaitContinueDidReceiveResponse))) {
-                RELEASE_LOG_ERROR_IF_ALLOWED("Failed to send the didReceiveResponse IPC message to the WebContent process: loader = %p, pageID = %llu, frameID = %llu, isMainResource = %d, isSynchronous = %d", this, static_cast<unsigned long long>(m_parameters.webPageID), static_cast<unsigned long long>(m_parameters.webFrameID), isMainResource(), isSynchronous());
-                return ShouldContinueDidReceiveResponse::No;
-            }
+            send(Messages::WebResourceLoader::DidReceiveResponse(m_response, shouldWaitContinueDidReceiveResponse));
         }
     }
 
@@ -369,7 +366,7 @@
         startBufferingTimerIfNeeded();
         return;
     }
-    sendBufferMaybeAborting(buffer, encodedDataLength);
+    sendBuffer(buffer, encodedDataLength);
 }
 
 void NetworkResourceLoader::didFinishLoading(double finishTime)
@@ -391,9 +388,7 @@
     else {
         if (m_bufferedData && !m_bufferedData->isEmpty()) {
             // FIXME: Pass a real value or remove the encoded data size feature.
-            bool shouldContinue = sendBufferMaybeAborting(*m_bufferedData, -1);
-            if (!shouldContinue)
-                return;
+            sendBuffer(*m_bufferedData, -1);
         }
         send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime));
     }
@@ -441,7 +436,7 @@
         continueWillSendRequest(WTFMove(overridenRequest));
         return;
     }
-    sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(redirectRequest, redirectResponse));
+    send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, redirectResponse));
 
 #if ENABLE(NETWORK_CACHE)
     if (canUseCachedRedirect(request))
@@ -510,15 +505,15 @@
     m_bufferedData = SharedBuffer::create();
     m_bufferedDataEncodedDataLength = 0;
 
-    sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedLength));
+    send(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedLength));
 }
 
-bool NetworkResourceLoader::sendBufferMaybeAborting(SharedBuffer& buffer, size_t encodedDataLength)
+void NetworkResourceLoader::sendBuffer(SharedBuffer& buffer, size_t encodedDataLength)
 {
     ASSERT(!isSynchronous());
 
     IPC::SharedBufferDataReference dataReference(&buffer);
-    return sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength));
+    send(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength));
 }
 
 #if ENABLE(NETWORK_CACHE)
@@ -546,7 +541,7 @@
         sendReplyToSynchronousRequest(*m_synchronousLoadData, entry->buffer());
     } else {
         bool needsContinueDidReceiveResponseMessage = isMainResource();
-        sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(entry->response(), needsContinueDidReceiveResponseMessage));
+        send(Messages::WebResourceLoader::DidReceiveResponse(entry->response(), needsContinueDidReceiveResponseMessage));
 
 #if ENABLE(SHAREABLE_RESOURCE)
         if (!entry->shareableResourceHandle().isNull())
@@ -553,9 +548,7 @@
             send(Messages::WebResourceLoader::DidReceiveResource(entry->shareableResourceHandle(), currentTime()));
         else {
 #endif
-            bool shouldContinue = sendBufferMaybeAborting(*entry->buffer(), entry->buffer()->size());
-            if (!shouldContinue)
-                return;
+            sendBuffer(*entry->buffer(), entry->buffer()->size());
             send(Messages::WebResourceLoader::DidFinishResourceLoad(currentTime()));
 #if ENABLE(SHAREABLE_RESOURCE)
         }
@@ -592,7 +585,7 @@
     LOG(NetworkCache, "(NetworkProcess) Executing cached redirect");
 
     ++m_redirectCount;
-    sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(*entry->redirectRequest(), entry->response()));
+    send(Messages::WebResourceLoader::WillSendRequest(*entry->redirectRequest(), entry->response()));
     m_isWaitingContinueWillSendRequestForCachedRedirect = true;
 }
 #endif
@@ -634,15 +627,6 @@
     m_fileReferences.clear();
 }
 
-template<typename T>
-bool NetworkResourceLoader::sendAbortingOnFailure(T&& message, OptionSet<IPC::SendOption> sendOption)
-{
-    bool result = messageSenderConnection()->send(std::forward<T>(message), messageSenderDestinationID(), sendOption);
-    if (!result)
-        abort();
-    return result;
-}
-
 void NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(const ProtectionSpace& protectionSpace)
 {
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (205051 => 205052)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2016-08-26 22:07:04 UTC (rev 205051)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2016-08-26 22:16:36 UTC (rev 205052)
@@ -129,13 +129,11 @@
 
     void startBufferingTimerIfNeeded();
     void bufferingTimerFired();
-    bool sendBufferMaybeAborting(WebCore::SharedBuffer&, size_t encodedDataLength);
+    void sendBuffer(WebCore::SharedBuffer&, size_t encodedDataLength);
 
     void consumeSandboxExtensions();
     void invalidateSandboxExtensions();
 
-    template<typename T> bool sendAbortingOnFailure(T&& message, OptionSet<IPC::SendOption> sendOption = { });
-
     const NetworkResourceLoadParameters m_parameters;
 
     Ref<NetworkConnectionToWebProcess> m_connection;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to