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

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, 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 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/frame/LocalDOMWindow.h" 7 #include "core/frame/LocalDOMWindow.h"
8 #include "core/frame/UseCounter.h" 8 #include "core/frame/UseCounter.h"
9 #include "core/workers/WorkerGlobalScope.h" 9 #include "core/workers/WorkerGlobalScope.h"
10 #include "modules/fetch/FetchManager.h" 10 #include "modules/fetch/FetchManager.h"
11 #include "modules/fetch/Request.h" 11 #include "modules/fetch/Request.h"
12 #include "platform/Supplementable.h" 12 #include "platform/Supplementable.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 #include "wtf/OwnPtr.h" 14 #include "wtf/OwnPtr.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 namespace { 18 namespace {
19 19
20 template <typename T> 20 template <typename T>
21 class GlobalFetchImpl final : public NoBaseWillBeGarbageCollectedFinalized<Globa lFetchImpl<T>>, public GlobalFetch::ScopedFetcher, public WillBeHeapSupplement<T > { 21 class GlobalFetchImpl final : public GarbageCollectedFinalized<GlobalFetchImpl<T >>, public GlobalFetch::ScopedFetcher, public HeapSupplement<T> {
22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(GlobalFetchImpl); 22 USING_GARBAGE_COLLECTED_MIXIN(GlobalFetchImpl);
23 public: 23 public:
24 static WeakPtrWillBeRawPtr<ScopedFetcher> from(T& supplementable, ExecutionC ontext* executionContext) 24 static RawPtr<ScopedFetcher> from(T& supplementable, ExecutionContext* execu tionContext)
25 { 25 {
26 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(WillBeHeapSu pplement<T>::from(supplementable, supplementName())); 26 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(HeapSuppleme nt<T>::from(supplementable, supplementName()));
27 if (!supplement) { 27 if (!supplement) {
28 supplement = new GlobalFetchImpl(executionContext); 28 supplement = new GlobalFetchImpl(executionContext);
29 WillBeHeapSupplement<T>::provideTo(supplementable, supplementName(), adoptPtrWillBeNoop(supplement)); 29 HeapSupplement<T>::provideTo(supplementable, supplementName(), adopt PtrWillBeNoop(supplement));
30 } 30 }
31 #if ENABLE(OILPAN) 31 #if ENABLE(OILPAN)
32 return supplement; 32 return supplement;
33 #else 33 #else
34 return supplement->m_weakFactory.createWeakPtr(); 34 return supplement->m_weakFactory.createWeakPtr();
35 #endif 35 #endif
36 } 36 }
37 37
38 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons t Dictionary& init, ExceptionState& exceptionState) override 38 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons t Dictionary& init, ExceptionState& exceptionState) override
39 { 39 {
40 if (m_fetchManager->isStopped()) { 40 if (m_fetchManager->isStopped()) {
41 exceptionState.throwTypeError("The global scope is shutting down."); 41 exceptionState.throwTypeError("The global scope is shutting down.");
42 return ScriptPromise(); 42 return ScriptPromise();
43 } 43 }
44 44
45 // "Let |r| be the associated request of the result of invoking the 45 // "Let |r| be the associated request of the result of invoking the
46 // initial value of Request as constructor with |input| and |init| as 46 // initial value of Request as constructor with |input| and |init| as
47 // arguments. If this throws an exception, reject |p| with it." 47 // arguments. If this throws an exception, reject |p| with it."
48 Request* r = Request::create(scriptState, input, init, exceptionState); 48 Request* r = Request::create(scriptState, input, init, exceptionState);
49 if (exceptionState.hadException()) 49 if (exceptionState.hadException())
50 return ScriptPromise(); 50 return ScriptPromise();
51 return m_fetchManager->fetch(scriptState, r->passRequestData()); 51 return m_fetchManager->fetch(scriptState, r->passRequestData());
52 } 52 }
53 53
54 DEFINE_INLINE_VIRTUAL_TRACE() 54 DEFINE_INLINE_VIRTUAL_TRACE()
55 { 55 {
56 visitor->trace(m_fetchManager); 56 visitor->trace(m_fetchManager);
57 ScopedFetcher::trace(visitor); 57 ScopedFetcher::trace(visitor);
58 WillBeHeapSupplement<T>::trace(visitor); 58 HeapSupplement<T>::trace(visitor);
59 } 59 }
60 60
61 private: 61 private:
62 explicit GlobalFetchImpl(ExecutionContext* executionContext) 62 explicit GlobalFetchImpl(ExecutionContext* executionContext)
63 : m_fetchManager(FetchManager::create(executionContext)) 63 : m_fetchManager(FetchManager::create(executionContext))
64 #if !ENABLE(OILPAN) 64 #if !ENABLE(OILPAN)
65 , m_weakFactory(this) 65 , m_weakFactory(this)
66 #endif 66 #endif
67 { 67 {
68 } 68 }
69 static const char* supplementName() { return "GlobalFetch"; } 69 static const char* supplementName() { return "GlobalFetch"; }
70 70
71 PersistentWillBeMember<FetchManager> m_fetchManager; 71 Member<FetchManager> m_fetchManager;
72 #if !ENABLE(OILPAN) 72 #if !ENABLE(OILPAN)
73 WeakPtrFactory<ScopedFetcher> m_weakFactory; 73 WeakPtrFactory<ScopedFetcher> m_weakFactory;
74 #endif 74 #endif
75 }; 75 };
76 76
77 } // namespace 77 } // namespace
78 78
79 GlobalFetch::ScopedFetcher::~ScopedFetcher() 79 GlobalFetch::ScopedFetcher::~ScopedFetcher()
80 { 80 {
81 } 81 }
82 82
83 WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from (DOMWindow& window) 83 RawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from(DOMWindow& w indow)
84 { 84 {
85 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo w.getExecutionContext()); 85 return GlobalFetchImpl<LocalDOMWindow>::from(toLocalDOMWindow(window), windo w.getExecutionContext());
86 } 86 }
87 87
88 WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from (WorkerGlobalScope& worker) 88 RawPtr<GlobalFetch::ScopedFetcher> GlobalFetch::ScopedFetcher::from(WorkerGlobal Scope& worker)
89 { 89 {
90 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.getExecutionC ontext()); 90 return GlobalFetchImpl<WorkerGlobalScope>::from(worker, worker.getExecutionC ontext());
91 } 91 }
92 92
93 DEFINE_TRACE(GlobalFetch::ScopedFetcher) 93 DEFINE_TRACE(GlobalFetch::ScopedFetcher)
94 { 94 {
95 } 95 }
96 96
97 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState) 97 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, DOMWindow& window, co nst RequestInfo& input, const Dictionary& init, ExceptionState& exceptionState)
98 { 98 {
99 UseCounter::count(window.getExecutionContext(), UseCounter::Fetch); 99 UseCounter::count(window.getExecutionContext(), UseCounter::Fetch);
100 return ScopedFetcher::from(window)->fetch(scriptState, input, init, exceptio nState); 100 return ScopedFetcher::from(window)->fetch(scriptState, input, init, exceptio nState);
101 } 101 }
102 102
103 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio nState) 103 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio nState)
104 { 104 {
105 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. 105 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker.
106 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch); 106 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch);
107 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio nState); 107 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio nState);
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/GlobalFetch.h ('k') | third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698