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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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 "modules/fetch/GlobalFetch.h" 5 #include "modules/fetch/GlobalFetch.h"
6 6
7 #include "core/dom/ActiveDOMObject.h" 7 #include "core/dom/ActiveDOMObject.h"
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/UseCounter.h" 9 #include "core/frame/UseCounter.h"
10 #include "core/workers/WorkerGlobalScope.h" 10 #include "core/workers/WorkerGlobalScope.h"
11 #include "modules/fetch/FetchManager.h" 11 #include "modules/fetch/FetchManager.h"
12 #include "modules/fetch/Request.h" 12 #include "modules/fetch/Request.h"
13 #include "platform/Supplementable.h" 13 #include "platform/Supplementable.h"
14 #include "platform/heap/Handle.h" 14 #include "platform/heap/Handle.h"
15 #include "wtf/OwnPtr.h" 15 #include "wtf/OwnPtr.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 namespace { 19 namespace {
20 20
21 template <typename T> 21 template <typename T>
22 class GlobalFetchImpl final : public NoBaseWillBeGarbageCollectedFinalized<Globa lFetchImpl<T>>, public GlobalFetch::ScopedFetcher, public WillBeHeapSupplement<T > { 22 class GlobalFetchImpl final : public GarbageCollectedFinalized<GlobalFetchImpl<T >>, public GlobalFetch::ScopedFetcher, public HeapSupplement<T> {
23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(GlobalFetchImpl); 23 USING_GARBAGE_COLLECTED_MIXIN(GlobalFetchImpl);
24 public: 24 public:
25 static WeakPtrWillBeRawPtr<ScopedFetcher> from(T& supplementable, ExecutionC ontext* executionContext) 25 static RawPtr<ScopedFetcher> from(T& supplementable, ExecutionContext* execu tionContext)
26 { 26 {
27 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(WillBeHeapSu pplement<T>::from(supplementable, supplementName())); 27 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(HeapSuppleme nt<T>::from(supplementable, supplementName()));
28 if (!supplement) { 28 if (!supplement) {
29 supplement = new GlobalFetchImpl(executionContext); 29 supplement = new GlobalFetchImpl(executionContext);
30 WillBeHeapSupplement<T>::provideTo(supplementable, supplementName(), adoptPtrWillBeNoop(supplement)); 30 HeapSupplement<T>::provideTo(supplementable, supplementName(), (supp lement));
31 } 31 }
32 #if ENABLE(OILPAN) 32 #if ENABLE(OILPAN)
33 return supplement; 33 return supplement;
34 #else 34 #else
35 return supplement->m_weakFactory.createWeakPtr(); 35 return supplement->m_weakFactory.createWeakPtr();
36 #endif 36 #endif
37 } 37 }
38 38
39 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons t Dictionary& init, ExceptionState& exceptionState) override 39 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons t Dictionary& init, ExceptionState& exceptionState) override
40 { 40 {
41 if (m_fetchManager->isStopped()) { 41 if (m_fetchManager->isStopped()) {
42 exceptionState.throwTypeError("The global scope is shutting down."); 42 exceptionState.throwTypeError("The global scope is shutting down.");
43 return ScriptPromise(); 43 return ScriptPromise();
44 } 44 }
45 45
46 // "Let |r| be the associated request of the result of invoking the 46 // "Let |r| be the associated request of the result of invoking the
47 // initial value of Request as constructor with |input| and |init| as 47 // initial value of Request as constructor with |input| and |init| as
48 // arguments. If this throws an exception, reject |p| with it." 48 // arguments. If this throws an exception, reject |p| with it."
49 Request* r = Request::create(scriptState, input, init, exceptionState); 49 Request* r = Request::create(scriptState, input, init, exceptionState);
50 if (exceptionState.hadException()) 50 if (exceptionState.hadException())
51 return ScriptPromise(); 51 return ScriptPromise();
52 return m_fetchManager->fetch(scriptState, r->passRequestData()); 52 return m_fetchManager->fetch(scriptState, r->passRequestData());
53 } 53 }
54 54
55 DEFINE_INLINE_VIRTUAL_TRACE() 55 DEFINE_INLINE_VIRTUAL_TRACE()
56 { 56 {
57 visitor->trace(m_fetchManager); 57 visitor->trace(m_fetchManager);
58 visitor->trace(m_stopDetector); 58 visitor->trace(m_stopDetector);
59 ScopedFetcher::trace(visitor); 59 ScopedFetcher::trace(visitor);
60 WillBeHeapSupplement<T>::trace(visitor); 60 HeapSupplement<T>::trace(visitor);
61 } 61 }
62 62
63 private: 63 private:
64 class StopDetector final : public GarbageCollectedFinalized<StopDetector>, p ublic ActiveDOMObject { 64 class StopDetector final : public GarbageCollectedFinalized<StopDetector>, p ublic ActiveDOMObject {
65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StopDetector); 65 USING_GARBAGE_COLLECTED_MIXIN(StopDetector);
66 public: 66 public:
67 static StopDetector* create(ExecutionContext* executionContext, FetchMan ager* fetchManager) 67 static StopDetector* create(ExecutionContext* executionContext, FetchMan ager* fetchManager)
68 { 68 {
69 return new StopDetector(executionContext, fetchManager); 69 return new StopDetector(executionContext, fetchManager);
70 } 70 }
71 71
72 void stop() override { m_fetchManager->stop(); } 72 void stop() override { m_fetchManager->stop(); }
73 73
74 DEFINE_INLINE_TRACE() 74 DEFINE_INLINE_TRACE()
75 { 75 {
(...skipping 15 matching lines...) Expand all
91 explicit GlobalFetchImpl(ExecutionContext* executionContext) 91 explicit GlobalFetchImpl(ExecutionContext* executionContext)
92 : m_fetchManager(FetchManager::create(executionContext)) 92 : m_fetchManager(FetchManager::create(executionContext))
93 , m_stopDetector(StopDetector::create(executionContext, m_fetchManager.g et())) 93 , m_stopDetector(StopDetector::create(executionContext, m_fetchManager.g et()))
94 #if !ENABLE(OILPAN) 94 #if !ENABLE(OILPAN)
95 , m_weakFactory(this) 95 , m_weakFactory(this)
96 #endif 96 #endif
97 { 97 {
98 } 98 }
99 static const char* supplementName() { return "GlobalFetch"; } 99 static const char* supplementName() { return "GlobalFetch"; }
100 100
101 PersistentWillBeMember<FetchManager> m_fetchManager; 101 Member<FetchManager> m_fetchManager;
102 PersistentWillBeMember<StopDetector> m_stopDetector; 102 Member<StopDetector> m_stopDetector;
103 #if !ENABLE(OILPAN) 103 #if !ENABLE(OILPAN)
104 WeakPtrFactory<ScopedFetcher> m_weakFactory; 104 WeakPtrFactory<ScopedFetcher> m_weakFactory;
105 #endif 105 #endif
106 }; 106 };
107 107
108 } // namespace 108 } // namespace
109 109
110 GlobalFetch::ScopedFetcher::~ScopedFetcher() 110 GlobalFetch::ScopedFetcher::~ScopedFetcher()
111 { 111 {
112 } 112 }
113 113
114 WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from (DOMWindow& window) 114 RawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from(DOMWindow& w indow)
115 { 115 {
116 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo w.executionContext()); 116 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo w.executionContext());
117 } 117 }
118 118
119 WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from (WorkerGlobalScope& worker) 119 RawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from(WorkerGlobal Scope& worker)
120 { 120 {
121 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.executionCont ext()); 121 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.executionCont ext());
122 } 122 }
123 123
124 DEFINE_TRACE(GlobalFetch::ScopedFetcher) 124 DEFINE_TRACE(GlobalFetch::ScopedFetcher)
125 { 125 {
126 } 126 }
127 127
128 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState) 128 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState)
129 { 129 {
130 UseCounter::count(window.executionContext(), UseCounter::Fetch); 130 UseCounter::count(window.executionContext(), UseCounter::Fetch);
131 return ScopedFetcher::from(window)->fetch(scriptState, input, init, exceptio nState); 131 return ScopedFetcher::from(window)->fetch(scriptState, input, init, exceptio nState);
132 } 132 }
133 133
134 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio nState) 134 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio nState)
135 { 135 {
136 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. 136 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker.
137 UseCounter::count(worker.executionContext(), UseCounter::Fetch); 137 UseCounter::count(worker.executionContext(), UseCounter::Fetch);
138 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio nState); 138 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio nState);
139 } 139 }
140 140
141 } // namespace blink 141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698