Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Unified Diff: Source/modules/fetch/GlobalFetch.cpp

Issue 1072763002: (WONT COMMIT) FetchAPI: Make GlobalFetchImpl non-templated (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/GlobalFetch.cpp
diff --git a/Source/modules/fetch/GlobalFetch.cpp b/Source/modules/fetch/GlobalFetch.cpp
index 5a720252922d8c82274a52be3f9d056625a20e23..4e9f9530fd66782aaace923fbf743dd680f06034 100644
--- a/Source/modules/fetch/GlobalFetch.cpp
+++ b/Source/modules/fetch/GlobalFetch.cpp
@@ -19,16 +19,25 @@ namespace blink {
namespace {
-template <typename T>
-class GlobalFetchImpl final : public NoBaseWillBeGarbageCollectedFinalized<GlobalFetchImpl<T>>, public WillBeHeapSupplement<T> {
+class GlobalFetchImpl final : public NoBaseWillBeGarbageCollectedFinalized<GlobalFetchImpl>, public WillBeHeapSupplement<LocalDOMWindow>, public WillBeHeapSupplement<WorkerGlobalScope> {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(GlobalFetchImpl);
public:
- static GlobalFetchImpl& from(T& supplementable, ExecutionContext* executionContext)
+ static GlobalFetchImpl& from(LocalDOMWindow& supplementable, ExecutionContext* executionContext)
{
- GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(WillBeHeapSupplement<T>::from(supplementable, name()));
+ GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(WillBeHeapSupplement<LocalDOMWindow>::from(supplementable, name()));
if (!supplement) {
supplement = new GlobalFetchImpl(executionContext);
- WillBeHeapSupplement<T>::provideTo(supplementable, name(), adoptPtrWillBeNoop(supplement));
+ WillBeHeapSupplement<LocalDOMWindow>::provideTo(supplementable, name(), adoptPtrWillBeNoop(supplement));
+ }
+ return *supplement;
+ }
+
+ static GlobalFetchImpl& from(WorkerGlobalScope& supplementable, ExecutionContext* executionContext)
+ {
+ GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(WillBeHeapSupplement<WorkerGlobalScope>::from(supplementable, name()));
+ if (!supplement) {
+ supplement = new GlobalFetchImpl(executionContext);
+ WillBeHeapSupplement<WorkerGlobalScope>::provideTo(supplementable, name(), adoptPtrWillBeNoop(supplement));
}
return *supplement;
}
@@ -53,7 +62,8 @@ public:
{
visitor->trace(m_fetchManager);
visitor->trace(m_stopDetector);
- WillBeHeapSupplement<T>::trace(visitor);
+ WillBeHeapSupplement<LocalDOMWindow>::trace(visitor);
+ WillBeHeapSupplement<WorkerGlobalScope>::trace(visitor);
}
private:
@@ -102,14 +112,14 @@ private:
ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState)
{
UseCounter::count(window.executionContext(), UseCounter::Fetch);
- return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), window.executionContext()).fetch(scriptState, input, init, exceptionState);
+ return GlobalFetchImpl::from(toLocalDOMWindow(window), window.executionContext()).fetch(scriptState, input, init, exceptionState);
}
ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& worker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState)
{
// Note that UseCounter doesn't work with SharedWorker or ServiceWorker.
UseCounter::count(worker.executionContext(), UseCounter::Fetch);
- return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.executionContext()).fetch(scriptState, input, init, exceptionState);
+ return GlobalFetchImpl::from(worker, worker.executionContext()).fetch(scriptState, input, init, exceptionState);
}
} // namespace blink
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698