NetworkDataTask redirection should not keep alive its NetworkSession
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Mar 2019 02:41:21 +0000 (02:41 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Mar 2019 02:41:21 +0000 (02:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194927

Reviewed by Darin Adler.

This should fix rdar://problem/47580502

* NetworkProcess/NetworkDataTask.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242304 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkDataTask.h
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

index cae8f7a..7312feb 100644 (file)
@@ -1,5 +1,18 @@
 2019-03-01  Alex Christensen  <achristensen@webkit.org>
 
+        NetworkDataTask redirection should not keep alive its NetworkSession
+        https://bugs.webkit.org/show_bug.cgi?id=194927
+
+        Reviewed by Darin Adler.
+
+        This should fix rdar://problem/47580502
+
+        * NetworkProcess/NetworkDataTask.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
+
+2019-03-01  Alex Christensen  <achristensen@webkit.org>
+
         Revert r241223, r241235, and r241287
         https://bugs.webkit.org/show_bug.cgi?id=194427
         <rdar://48045861>
index 9c19720..ce7b2ad 100644 (file)
@@ -77,7 +77,7 @@ public:
     virtual ~NetworkDataTaskClient() { }
 };
 
-class NetworkDataTask : public RefCounted<NetworkDataTask> {
+class NetworkDataTask : public RefCounted<NetworkDataTask>, public CanMakeWeakPtr<NetworkDataTask> {
 public:
     static Ref<NetworkDataTask> create(NetworkSession&, NetworkDataTaskClient&, const NetworkLoadParameters&);
 
index f959cd9..28c0c65 100644 (file)
@@ -375,7 +375,9 @@ void NetworkDataTaskCocoa::willPerformHTTPRedirection(WebCore::ResourceResponse&
     updateTaskWithFirstPartyForSameSiteCookies(m_task.get(), request);
 
     if (m_client)
-        m_client->willPerformHTTPRedirection(WTFMove(redirectResponse), WTFMove(request), [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)] (auto&& request) mutable {
+        m_client->willPerformHTTPRedirection(WTFMove(redirectResponse), WTFMove(request), [completionHandler = WTFMove(completionHandler), this, weakThis = makeWeakPtr(*this)] (auto&& request) mutable {
+            if (!weakThis)
+                return completionHandler({ });
             if (!request.isNull()) {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
                 bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);