Title: [221427] trunk/Source/WebCore
Revision
221427
Author
commit-qu...@webkit.org
Date
2017-08-31 11:21:27 -0700 (Thu, 31 Aug 2017)

Log Message

Move consume promise from FetchBody to FetchBodyConsumer
https://bugs.webkit.org/show_bug.cgi?id=176121

Patch by Youenn Fablet <you...@apple.com> on 2017-08-31
Reviewed by Alex Christensen.

No change of behavior.

FetchBodyConsumer should be made responsible for data consumption through promise getters and ReadableStream.
This will allow making data consumption consistent for Request and Response.
This patch is doing the first step.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consumeOnceLoadingFinished):
(WebCore::FetchBody::consumeBlob):
(WebCore::FetchBody::loadingFailed):
(WebCore::FetchBody::loadingSucceeded):
(WebCore::FetchBody::clone const):
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::cleanConsumer):
(WebCore::FetchBody::cleanConsumePromise): Deleted.
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::setConsumePromise):
(WebCore::FetchBodyConsumer::loadingFailed):
(WebCore::FetchBodyConsumer::loadingSucceeded):
(WebCore::FetchBodyConsumer::clean):
* Modules/fetch/FetchBodyConsumer.h:
(WebCore::FetchBodyConsumer::clean): Deleted.
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::stop):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221426 => 221427)


--- trunk/Source/WebCore/ChangeLog	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/ChangeLog	2017-08-31 18:21:27 UTC (rev 221427)
@@ -1,3 +1,35 @@
+2017-08-31  Youenn Fablet  <you...@apple.com>
+
+        Move consume promise from FetchBody to FetchBodyConsumer
+        https://bugs.webkit.org/show_bug.cgi?id=176121
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        FetchBodyConsumer should be made responsible for data consumption through promise getters and ReadableStream.
+        This will allow making data consumption consistent for Request and Response.
+        This patch is doing the first step.
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::consumeOnceLoadingFinished):
+        (WebCore::FetchBody::consumeBlob):
+        (WebCore::FetchBody::loadingFailed):
+        (WebCore::FetchBody::loadingSucceeded):
+        (WebCore::FetchBody::clone const):
+        * Modules/fetch/FetchBody.h:
+        (WebCore::FetchBody::cleanConsumer):
+        (WebCore::FetchBody::cleanConsumePromise): Deleted.
+        * Modules/fetch/FetchBodyConsumer.cpp:
+        (WebCore::FetchBodyConsumer::setConsumePromise):
+        (WebCore::FetchBodyConsumer::loadingFailed):
+        (WebCore::FetchBodyConsumer::loadingSucceeded):
+        (WebCore::FetchBodyConsumer::clean):
+        * Modules/fetch/FetchBodyConsumer.h:
+        (WebCore::FetchBodyConsumer::clean): Deleted.
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::stop):
+
 2017-08-22  Darin Adler  <da...@apple.com>
 
         REGRESSION (r220052): ASSERTION FAILED: !frame().isMainFrame() || !needsStyleRecalcOrLayout()  in WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive()

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (221426 => 221427)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-08-31 18:21:27 UTC (rev 221427)
@@ -105,7 +105,7 @@
 void FetchBody::consumeOnceLoadingFinished(FetchBodyConsumer::Type type, Ref<DeferredPromise>&& promise, const String& contentType)
 {
     m_consumer.setType(type);
-    m_consumePromise = WTFMove(promise);
+    m_consumer.setConsumePromise(WTFMove(promise));
     if (type == FetchBodyConsumer::Type::Blob)
         m_consumer.setContentType(Blob::normalizedContentType(extractMIMETypeFromMediaType(contentType)));
 }
@@ -194,7 +194,7 @@
 
 void FetchBody::consumeBlob(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
-    m_consumePromise = WTFMove(promise);
+    m_consumer.setConsumePromise(WTFMove(promise));
     owner.loadBlob(blobBody(), &m_consumer);
     m_data = nullptr;
 }
@@ -201,16 +201,12 @@
 
 void FetchBody::loadingFailed()
 {
-    if (m_consumePromise) {
-        m_consumePromise->reject();
-        m_consumePromise = nullptr;
-    }
+    m_consumer.loadingFailed();
 }
 
 void FetchBody::loadingSucceeded()
 {
-    if (m_consumePromise)
-        m_consumer.resolve(m_consumePromise.releaseNonNull());
+    m_consumer.loadingSucceeded();
 }
 
 RefPtr<FormData> FetchBody::bodyAsFormData(ScriptExecutionContext& context) const
@@ -276,7 +272,6 @@
 
 FetchBody FetchBody::clone() const
 {
-    ASSERT(!m_consumePromise);
     FetchBody clone(m_consumer);
 
     if (isArrayBuffer())

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (221426 => 221427)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-08-31 18:21:27 UTC (rev 221427)
@@ -78,7 +78,7 @@
     FetchBodyConsumer& consumer() { return m_consumer; }
 
     void consumeOnceLoadingFinished(FetchBodyConsumer::Type, Ref<DeferredPromise>&&, const String&);
-    void cleanConsumePromise() { m_consumePromise = nullptr; }
+    void cleanConsumer() { m_consumer.clean(); }
 
     FetchBody clone() const;
     ReadableStream* readableStream() { return m_readableStream.get(); }
@@ -119,7 +119,6 @@
     Data m_data { nullptr };
 
     FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
-    RefPtr<DeferredPromise> m_consumePromise;
     RefPtr<ReadableStream> m_readableStream;
 };
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp (221426 => 221427)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp	2017-08-31 18:21:27 UTC (rev 221427)
@@ -148,4 +148,30 @@
     return text;
 }
 
+void FetchBodyConsumer::setConsumePromise(Ref<DeferredPromise>&& promise)
+{
+    ASSERT(!m_consumePromise);
+    m_consumePromise = WTFMove(promise);
+}
+
+void FetchBodyConsumer::loadingFailed()
+{
+    if (m_consumePromise) {
+        m_consumePromise->reject();
+        m_consumePromise = nullptr;
+    }
+}
+
+void FetchBodyConsumer::loadingSucceeded()
+{
+    if (m_consumePromise)
+        resolve(m_consumePromise.releaseNonNull());
+}
+
+void FetchBodyConsumer::clean()
+{
+    m_buffer = nullptr;
+    m_consumePromise = nullptr;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h (221426 => 221427)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h	2017-08-31 18:21:27 UTC (rev 221427)
@@ -55,7 +55,7 @@
     void setContentType(const String& contentType) { m_contentType = contentType; }
     void setType(Type type) { m_type = type; }
 
-    void clean() { m_buffer = nullptr; }
+    void clean();
 
     void resolve(Ref<DeferredPromise>&&);
     void resolveWithData(Ref<DeferredPromise>&&, const unsigned char*, unsigned);
@@ -62,10 +62,16 @@
 
     bool hasData() const { return !!m_buffer; }
 
+    void loadingFailed();
+    void loadingSucceeded();
+
+    void setConsumePromise(Ref<DeferredPromise>&&);
+
 private:
     Type m_type;
     String m_contentType;
     RefPtr<SharedBuffer> m_buffer;
+    RefPtr<DeferredPromise> m_consumePromise;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (221426 => 221427)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-08-31 18:19:54 UTC (rev 221426)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-08-31 18:21:27 UTC (rev 221427)
@@ -48,7 +48,7 @@
 void FetchBodyOwner::stop()
 {
     if (m_body)
-        m_body->cleanConsumePromise();
+        m_body->cleanConsumer();
 
     if (m_blobLoader) {
         bool isUniqueReference = hasOneRef();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to