Index: Source/modules/fetch/FetchManager.cpp |
diff --git a/Source/modules/fetch/FetchManager.cpp b/Source/modules/fetch/FetchManager.cpp |
index c17645f9e9dc3f56188f3fe116639cce195b9269..60b91eedba2fd1a9fe070ac4ba9c120bd029d439 100644 |
--- a/Source/modules/fetch/FetchManager.cpp |
+++ b/Source/modules/fetch/FetchManager.cpp |
@@ -30,10 +30,17 @@ |
namespace blink { |
-class FetchManager::Loader : public ThreadableLoaderClient, public ContextLifecycleObserver { |
+class FetchManager::Loader final : public NoBaseWillBeGarbageCollectedFinalized<FetchManager::Loader>, public ThreadableLoaderClient, public ContextLifecycleObserver { |
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FetchManager::Loader); |
public: |
- Loader(ExecutionContext*, FetchManager*, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, const FetchRequestData*); |
+ static PassOwnPtrWillBeRawPtr<Loader> create(ExecutionContext* executionContext, FetchManager* fetchManager, PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, const FetchRequestData* request) |
+ { |
+ return adoptPtrWillBeNoop(new Loader(executionContext, fetchManager, resolver, request)); |
+ } |
+ |
~Loader() override; |
+ void trace(Visitor*) override; |
+ |
void didReceiveResponse(unsigned long, const ResourceResponse&, PassOwnPtr<WebDataConsumerHandle>) override; |
void didReceiveData(const char*, unsigned) override; |
void didFinishLoading(unsigned long, double) override; |
@@ -45,16 +52,18 @@ public: |
void cleanup(); |
private: |
+ Loader(ExecutionContext*, FetchManager*, PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, const FetchRequestData*); |
+ |
void performBasicFetch(); |
void performNetworkError(const String& message); |
void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); |
void failed(const String& message); |
void notifyFinished(); |
- FetchManager* m_fetchManager; |
- RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
- Persistent<FetchRequestData> m_request; |
- Persistent<BodyStreamBuffer> m_responseBuffer; |
+ RawPtrWillBeMember<FetchManager> m_fetchManager; |
+ RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; |
+ PersistentWillBeMember<FetchRequestData> m_request; |
+ PersistentWillBeMember<BodyStreamBuffer> m_responseBuffer; |
RefPtr<ThreadableLoader> m_loader; |
bool m_failed; |
}; |
@@ -74,6 +83,15 @@ FetchManager::Loader::~Loader() |
m_loader->cancel(); |
} |
+void FetchManager::Loader::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_fetchManager); |
+ visitor->trace(m_resolver); |
+ visitor->trace(m_request); |
+ visitor->trace(m_responseBuffer); |
+ ContextLifecycleObserver::trace(visitor); |
+} |
+ |
void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) |
{ |
// FIXME: Use |handle|. |
@@ -375,8 +393,10 @@ FetchManager::FetchManager(ExecutionContext* executionContext) |
FetchManager::~FetchManager() |
{ |
+#if !ENABLE(OILPAN) |
if (!m_isStopped) |
stop(); |
+#endif |
} |
ScriptPromise FetchManager::fetch(ScriptState* scriptState, const FetchRequestData* request) |
@@ -384,7 +404,7 @@ ScriptPromise FetchManager::fetch(ScriptState* scriptState, const FetchRequestDa |
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
ScriptPromise promise = resolver->promise(); |
- OwnPtr<Loader> ownLoader(adoptPtr(new Loader(m_executionContext, this, resolver.release(), request))); |
+ OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, this, resolver.release(), request); |
Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); |
loader->start(); |
return promise; |
@@ -407,7 +427,10 @@ void FetchManager::onLoaderFinished(Loader* loader) |
void FetchManager::trace(Visitor* visitor) |
{ |
+#if ENABLE(OILPAN) |
visitor->trace(m_executionContext); |
+ visitor->trace(m_loaders); |
+#endif |
} |
} // namespace blink |