Title: [280005] trunk/Source/WebCore
Revision
280005
Author
beid...@apple.com
Date
2021-07-16 15:59:36 -0700 (Fri, 16 Jul 2021)

Log Message

FetchBodySource/FetchBodyOwner cleanup
<rdar://80318044> and https://bugs.webkit.org/show_bug.cgi?id=228035

Reviewed by Geoffrey Garen.

FetchBodyOwner should have a WeakPtr factory, and FetchBodySource should use it.

* Modules/fetch/FetchBodyOwner.h:
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::FetchBodySource):
(WebCore::FetchBodySource::doCancel):
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/fetch/FetchResponse.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (280004 => 280005)


--- trunk/Source/WebCore/ChangeLog	2021-07-16 22:18:46 UTC (rev 280004)
+++ trunk/Source/WebCore/ChangeLog	2021-07-16 22:59:36 UTC (rev 280005)
@@ -1,3 +1,20 @@
+2021-07-16  Brady Eidson  <beid...@apple.com>
+
+        FetchBodySource/FetchBodyOwner cleanup
+        <rdar://80318044> and https://bugs.webkit.org/show_bug.cgi?id=228035
+
+        Reviewed by Geoffrey Garen.
+
+        FetchBodyOwner should have a WeakPtr factory, and FetchBodySource should use it.
+        
+        * Modules/fetch/FetchBodyOwner.h:
+        * Modules/fetch/FetchBodySource.cpp:
+        (WebCore::FetchBodySource::FetchBodySource):
+        (WebCore::FetchBodySource::doCancel):
+        (WebCore::FetchBodySource::close):
+        * Modules/fetch/FetchBodySource.h:
+        * Modules/fetch/FetchResponse.h:
+
 2021-07-16  Alan Bujtas  <za...@apple.com>
 
         [RenderTreeBuilder] Update the fragmented status of the renderer when it becomes in-flow

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (280004 => 280005)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2021-07-16 22:18:46 UTC (rev 280004)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2021-07-16 22:59:36 UTC (rev 280005)
@@ -40,7 +40,7 @@
 
 namespace WebCore {
 
-class FetchBodyOwner : public RefCounted<FetchBodyOwner>, public ActiveDOMObject {
+class FetchBodyOwner : public RefCounted<FetchBodyOwner>, public ActiveDOMObject, public CanMakeWeakPtr<FetchBodyOwner> {
 public:
     FetchBodyOwner(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&);
     ~FetchBodyOwner();

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodySource.cpp (280004 => 280005)


--- trunk/Source/WebCore/Modules/fetch/FetchBodySource.cpp	2021-07-16 22:18:46 UTC (rev 280004)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodySource.cpp	2021-07-16 22:59:36 UTC (rev 280005)
@@ -32,7 +32,7 @@
 namespace WebCore {
 
 FetchBodySource::FetchBodySource(FetchBodyOwner& bodyOwner)
-    : m_bodyOwner(&bodyOwner)
+    : m_bodyOwner(makeWeakPtr(bodyOwner))
 {
 }
 
@@ -68,7 +68,6 @@
 void FetchBodySource::doCancel()
 {
     m_isCancelling = true;
-    ASSERT(m_bodyOwner || m_isClosed);
     if (!m_bodyOwner)
         return;
 
@@ -79,6 +78,7 @@
 void FetchBodySource::close()
 {
 #if ASSERT_ENABLED
+    ASSERT(!m_isClosed);
     m_isClosed = true;
 #endif
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodySource.h (280004 => 280005)


--- trunk/Source/WebCore/Modules/fetch/FetchBodySource.h	2021-07-16 22:18:46 UTC (rev 280004)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodySource.h	2021-07-16 22:59:36 UTC (rev 280005)
@@ -57,7 +57,8 @@
     void setActive() final;
     void setInactive() final;
 
-    FetchBodyOwner* m_bodyOwner;
+    WeakPtr<FetchBodyOwner> m_bodyOwner;
+
     bool m_isCancelling { false };
 #if ASSERT_ENABLED
     bool m_isClosed { false };

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (280004 => 280005)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2021-07-16 22:18:46 UTC (rev 280004)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2021-07-16 22:59:36 UTC (rev 280005)
@@ -47,7 +47,7 @@
 class FetchRequest;
 class ReadableStreamSource;
 
-class FetchResponse final : public FetchBodyOwner, public CanMakeWeakPtr<FetchResponse> {
+class FetchResponse final : public FetchBodyOwner {
 public:
     using Type = ResourceResponse::Type;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to