Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit fc64649

Browse files
Stop to use ActiveDOMObject::setPendingActivity() for Modules/fetch
https://bugs.webkit.org/show_bug.cgi?id=213037 Patch by Tetsuharu Ohzeki <[email protected]> on 2020-06-12 Reviewed by Youenn Fablet. By ActiveDOMObject's comments, these methods should be replaced with using makePendingActivity(). `JSFetchRequest`/`JSFetchResponse` (as derived class of `JSDOMWrapper`) hold `FetchRequest`/`FetchResponse`, and they have `FetchBodyOwner` as a base class and keep alive it. We can replace `setPendingActivity()` calling from `FetchBodyOwner`. * Modules/fetch/FetchBodyOwner.cpp: (WebCore::FetchBodyOwner::loadBlob): (WebCore::FetchBodyOwner::finishBlobLoading): (WebCore::FetchBodyOwner::virtualHasPendingActivity const): * Modules/fetch/FetchBodyOwner.h: * Modules/fetch/FetchBodySource.cpp: (WebCore::FetchBodySource::setActive): (WebCore::FetchBodySource::setInactive): * Modules/fetch/FetchBodySource.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@262972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 2008e96 commit fc64649

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

Source/WebCore/ChangeLog

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2020-06-12 Tetsuharu Ohzeki <[email protected]>
2+
3+
Stop to use ActiveDOMObject::setPendingActivity() for Modules/fetch
4+
https://bugs.webkit.org/show_bug.cgi?id=213037
5+
6+
Reviewed by Youenn Fablet.
7+
8+
By ActiveDOMObject's comments,
9+
these methods should be replaced with using makePendingActivity().
10+
11+
`JSFetchRequest`/`JSFetchResponse` (as derived class of `JSDOMWrapper`) hold
12+
`FetchRequest`/`FetchResponse`, and they have `FetchBodyOwner`
13+
as a base class and keep alive it. We can replace
14+
`setPendingActivity()` calling from `FetchBodyOwner`.
15+
16+
* Modules/fetch/FetchBodyOwner.cpp:
17+
(WebCore::FetchBodyOwner::loadBlob):
18+
(WebCore::FetchBodyOwner::finishBlobLoading):
19+
(WebCore::FetchBodyOwner::virtualHasPendingActivity const):
20+
* Modules/fetch/FetchBodyOwner.h:
21+
* Modules/fetch/FetchBodySource.cpp:
22+
(WebCore::FetchBodySource::setActive):
23+
(WebCore::FetchBodySource::setInactive):
24+
* Modules/fetch/FetchBodySource.h:
25+
26+
127
2020-06-12 Takashi Komori <[email protected]>
228

329
[Curl] Implement functions to use ResourceLoadStatistics.

Source/WebCore/Modules/fetch/FetchBodyOwner.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,13 @@ void FetchBodyOwner::loadBlob(const Blob& blob, FetchBodyConsumer* consumer)
256256
m_blobLoader = WTF::nullopt;
257257
return;
258258
}
259-
setPendingActivity(*this);
260259
}
261260

262261
void FetchBodyOwner::finishBlobLoading()
263262
{
264263
ASSERT(m_blobLoader);
265264

266265
m_blobLoader = WTF::nullopt;
267-
unsetPendingActivity(*this);
268266
}
269267

270268
void FetchBodyOwner::blobLoadingSucceeded()
@@ -384,6 +382,11 @@ Optional<Exception> FetchBodyOwner::loadingException() const
384382
});
385383
}
386384

385+
bool FetchBodyOwner::virtualHasPendingActivity() const
386+
{
387+
return !!m_blobLoader;
388+
}
389+
387390
bool FetchBodyOwner::hasLoadingError() const
388391
{
389392
return WTF::switchOn(m_loadingError, [](const ResourceError&) {

Source/WebCore/Modules/fetch/FetchBodyOwner.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class FetchBodyOwner : public RefCounted<FetchBodyOwner>, public ActiveDOMObject
102102
void blobLoadingFailed();
103103
void finishBlobLoading();
104104

105+
// ActiveDOMObject API
106+
bool virtualHasPendingActivity() const final;
107+
105108
struct BlobLoader final : FetchLoaderClient {
106109
BlobLoader(FetchBodyOwner&);
107110

Source/WebCore/Modules/fetch/FetchBodySource.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ FetchBodySource::FetchBodySource(FetchBodyOwner& bodyOwner)
4141
void FetchBodySource::setActive()
4242
{
4343
ASSERT(m_bodyOwner);
44+
ASSERT(!m_pendingActivity);
4445
if (m_bodyOwner)
45-
m_bodyOwner->setPendingActivity(*m_bodyOwner);
46+
m_pendingActivity = m_bodyOwner->makePendingActivity(*m_bodyOwner);
4647
}
4748

4849
void FetchBodySource::setInactive()
4950
{
5051
ASSERT(m_bodyOwner);
51-
if (m_bodyOwner)
52-
m_bodyOwner->unsetPendingActivity(*m_bodyOwner);
52+
ASSERT(m_pendingActivity);
53+
m_pendingActivity = nullptr;
5354
}
5455

5556
void FetchBodySource::doStart()

Source/WebCore/Modules/fetch/FetchBodySource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#if ENABLE(STREAMS_API)
3030

31+
#include "ActiveDOMObject.h"
3132
#include "ReadableStreamSource.h"
3233

3334
namespace JSC {
@@ -63,6 +64,7 @@ class FetchBodySource final : public ReadableStreamSource {
6364
#if ASSERT_ENABLED
6465
bool m_isClosed { false };
6566
#endif
67+
RefPtr<ActiveDOMObject::PendingActivity<FetchBodyOwner>> m_pendingActivity;
6668
};
6769

6870
} // namespace WebCore

0 commit comments

Comments
 (0)