OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/fetch/GlobalFetch.h" | 6 #include "modules/fetch/GlobalFetch.h" |
7 | 7 |
8 #include "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 private: | 76 private: |
77 StopDetector(ExecutionContext* executionContext, FetchManager* fetchMana
ger) | 77 StopDetector(ExecutionContext* executionContext, FetchManager* fetchMana
ger) |
78 : ActiveDOMObject(executionContext) | 78 : ActiveDOMObject(executionContext) |
79 , m_fetchManager(fetchManager) | 79 , m_fetchManager(fetchManager) |
80 { | 80 { |
81 suspendIfNeeded(); | 81 suspendIfNeeded(); |
82 } | 82 } |
83 | 83 |
84 // Having a raw pointer is safe, because |m_fetchManager| is owned by | 84 // Having a raw pointer is safe, because |m_fetchManager| is owned by |
85 // the owner of this object. | 85 // the owner of this object. |
86 GC_PLUGIN_IGNORE("crbug.com/444740") RawPtrWillBeMember<FetchManager> m_
fetchManager; | 86 RawPtrWillBeMember<FetchManager> m_fetchManager; |
87 }; | 87 }; |
88 | 88 |
89 explicit GlobalFetchImpl(ExecutionContext* executionContext) | 89 explicit GlobalFetchImpl(ExecutionContext* executionContext) |
90 : m_fetchManager(FetchManager::create(executionContext)) | 90 : m_fetchManager(FetchManager::create(executionContext)) |
91 , m_stopDetector(StopDetector::create(executionContext, m_fetchManager.g
et())) | 91 , m_stopDetector(StopDetector::create(executionContext, m_fetchManager.g
et())) |
92 { | 92 { |
93 } | 93 } |
94 static const char* name() { return "GlobalFetch"; } | 94 static const char* name() { return "GlobalFetch"; } |
95 | 95 |
96 OwnPtrWillBeMember<FetchManager> m_fetchManager; | 96 OwnPtrWillBeMember<FetchManager> m_fetchManager; |
97 OwnPtrWillBeMember<StopDetector> m_stopDetector; | 97 OwnPtrWillBeMember<StopDetector> m_stopDetector; |
98 }; | 98 }; |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co
nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState) | 102 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co
nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState) |
103 { | 103 { |
104 UseCounter::count(window.executionContext(), UseCounter::Fetch); | 104 UseCounter::count(window.executionContext(), UseCounter::Fetch); |
105 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo
w.executionContext()).fetch(scriptState, input, init, exceptionState); | 105 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo
w.executionContext()).fetch(scriptState, input, init, exceptionState); |
106 } | 106 } |
107 | 107 |
108 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo
rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio
nState) | 108 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo
rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio
nState) |
109 { | 109 { |
110 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. | 110 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. |
111 UseCounter::count(worker.executionContext(), UseCounter::Fetch); | 111 UseCounter::count(worker.executionContext(), UseCounter::Fetch); |
112 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.executionCont
ext()).fetch(scriptState, input, init, exceptionState); | 112 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.executionCont
ext()).fetch(scriptState, input, init, exceptionState); |
113 } | 113 } |
114 | 114 |
115 } // namespace blink | 115 } // namespace blink |
OLD | NEW |