OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WorkletScriptLoader_h | 5 #ifndef WorkletScriptLoader_h |
6 #define WorkletScriptLoader_h | 6 #define WorkletScriptLoader_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/fetch/ResourceClient.h" | 9 #include "core/fetch/ResourceClient.h" |
10 #include "core/fetch/ResourceOwner.h" | 10 #include "core/fetch/ResourceOwner.h" |
11 #include "core/fetch/ScriptResource.h" | 11 #include "core/fetch/ScriptResource.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class Worklet; | 15 class Worklet; |
16 | 16 |
17 // Class that is responsible for processing {@code resource} that is associated
with worklet's import promise. | 17 // Class that is responsible for processing {@code resource} that is associated |
| 18 // with worklet's import promise. |
18 class WorkletScriptLoader final | 19 class WorkletScriptLoader final |
19 : public GarbageCollectedFinalized<WorkletScriptLoader>, | 20 : public GarbageCollectedFinalized<WorkletScriptLoader>, |
20 public ResourceOwner<ScriptResource, ScriptResourceClient> { | 21 public ResourceOwner<ScriptResource, ScriptResourceClient> { |
21 USING_GARBAGE_COLLECTED_MIXIN(WorkletScriptLoader); | 22 USING_GARBAGE_COLLECTED_MIXIN(WorkletScriptLoader); |
22 WTF_MAKE_NONCOPYABLE(WorkletScriptLoader); | 23 WTF_MAKE_NONCOPYABLE(WorkletScriptLoader); |
23 | 24 |
24 public: | 25 public: |
25 static WorkletScriptLoader* create( | 26 static WorkletScriptLoader* create( |
26 ScriptPromiseResolver* scriptPromiseResolver, | 27 ScriptPromiseResolver* scriptPromiseResolver, |
27 Worklet* worklet, | 28 Worklet* worklet, |
28 ScriptResource* resource) { | 29 ScriptResource* resource) { |
29 return new WorkletScriptLoader(scriptPromiseResolver, worklet, resource); | 30 return new WorkletScriptLoader(scriptPromiseResolver, worklet, resource); |
30 } | 31 } |
31 | 32 |
32 ~WorkletScriptLoader() override = default; | 33 ~WorkletScriptLoader() override = default; |
33 | 34 |
34 // Cancels loading of {@code m_resource}. | 35 // Cancels loading of {@code m_resource}. |
35 // | 36 // |
36 // Typically it gets called when WorkletScriptLoader's host is about to be dis
posed off. | 37 // Typically it gets called when WorkletScriptLoader's host is about to be |
| 38 // disposed off. |
37 void cancel(); | 39 void cancel(); |
38 | 40 |
39 DECLARE_TRACE(); | 41 DECLARE_TRACE(); |
40 | 42 |
41 private: | 43 private: |
42 // Default constructor. | 44 // Default constructor. |
43 // | 45 // |
44 // @param resolver Promise resolver that is used to reject/resolve the promise
on ScriptResourceClient::notifyFinished event. | 46 // @param resolver Promise resolver that is used to reject/resolve the promise |
| 47 // on ScriptResourceClient::notifyFinished event. |
45 // @param host Host that needs be notified when the resource is downloaded. | 48 // @param host Host that needs be notified when the resource is downloaded. |
46 // @param resource that needs to be downloaded. | 49 // @param resource that needs to be downloaded. |
47 WorkletScriptLoader(ScriptPromiseResolver*, Worklet* host, ScriptResource*); | 50 WorkletScriptLoader(ScriptPromiseResolver*, Worklet* host, ScriptResource*); |
48 | 51 |
49 // ResourceClient | 52 // ResourceClient |
50 void notifyFinished(Resource*) final; | 53 void notifyFinished(Resource*) final; |
51 String debugName() const final { return "WorkletLoader"; } | 54 String debugName() const final { return "WorkletLoader"; } |
52 | 55 |
53 Member<ScriptPromiseResolver> m_resolver; | 56 Member<ScriptPromiseResolver> m_resolver; |
54 Member<Worklet> m_host; | 57 Member<Worklet> m_host; |
55 }; | 58 }; |
56 | 59 |
57 } // namespace blink | 60 } // namespace blink |
58 | 61 |
59 #endif // WorkletScriptLoader_h | 62 #endif // WorkletScriptLoader_h |
OLD | NEW |