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

Side by Side Diff: third_party/WebKit/Source/core/dom/Modulator.h

Issue 2795593006: Abstract out Modulator from V8PerContextData (Closed)
Patch Set: Add new from method for Modulator Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 Modulator_h 5 #ifndef Modulator_h
6 #define Modulator_h 6 #define Modulator_h
7 7
8 #include "bindings/core/v8/V8PerContextData.h"
8 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
9 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
10 #include "platform/weborigin/KURL.h" 11 #include "platform/weborigin/KURL.h"
11 #include "platform/weborigin/ReferrerPolicy.h" 12 #include "platform/weborigin/ReferrerPolicy.h"
12 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class LocalFrame; 17 class LocalFrame;
17 class ModuleScript; 18 class ModuleScript;
(...skipping 14 matching lines...) Expand all
32 33
33 // spec: "top-level module fetch flag" 34 // spec: "top-level module fetch flag"
34 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to p-level 35 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to p-level
35 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch }; 36 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch };
36 37
37 // A Modulator is an interface for "environment settings object" concept for 38 // A Modulator is an interface for "environment settings object" concept for
38 // module scripts. 39 // module scripts.
39 // https://html.spec.whatwg.org/#environment-settings-object 40 // https://html.spec.whatwg.org/#environment-settings-object
40 // 41 //
41 // A Modulator also serves as an entry point for various module spec algorithms. 42 // A Modulator also serves as an entry point for various module spec algorithms.
42 class CORE_EXPORT Modulator : public GarbageCollectedFinalized<Modulator> { 43 class CORE_EXPORT Modulator : public GarbageCollectedFinalized<Modulator>,
44 public V8PerContextData::Data {
45 USING_GARBAGE_COLLECTED_MIXIN(Modulator);
46
43 public: 47 public:
44 static Modulator* from(LocalFrame*); 48 static Modulator* from(LocalFrame*);
49 static Modulator* from(V8PerContextData*);
45 virtual ~Modulator(); 50 virtual ~Modulator();
46 51
52 static void setModulator(LocalFrame*, Modulator*);
53 static void clearModulator(LocalFrame*);
54
47 DEFINE_INLINE_VIRTUAL_TRACE() {} 55 DEFINE_INLINE_VIRTUAL_TRACE() {}
48 56
49 virtual ScriptModuleResolver* scriptModuleResolver() = 0; 57 virtual ScriptModuleResolver* scriptModuleResolver() = 0;
50 virtual WebTaskRunner* taskRunner() = 0; 58 virtual WebTaskRunner* taskRunner() = 0;
51 virtual ReferrerPolicy referrerPolicy() = 0; 59 virtual ReferrerPolicy referrerPolicy() = 0;
52 virtual SecurityOrigin* securityOrigin() = 0; 60 virtual SecurityOrigin* securityOrigin() = 0;
53 61
54 // https://html.spec.whatwg.org/#resolve-a-module-specifier 62 // https://html.spec.whatwg.org/#resolve-a-module-specifier
55 static KURL resolveModuleSpecifier(const String& moduleRequest, 63 static KURL resolveModuleSpecifier(const String& moduleRequest,
56 const KURL& baseURL); 64 const KURL& baseURL);
57 65
58 virtual ScriptModule compileModule(const String& script, 66 virtual ScriptModule compileModule(const String& script,
59 const String& urlStr) = 0; 67 const String& urlStr) = 0;
60 68
61 private: 69 private:
62 friend class ModuleMap; 70 friend class ModuleMap;
63 71
64 // Fetches a single module script. 72 // Fetches a single module script.
65 // This is triggered from fetchSingle() implementation (which is in ModuleMap) 73 // This is triggered from fetchSingle() implementation (which is in ModuleMap)
66 // if the cached entry doesn't exist. 74 // if the cached entry doesn't exist.
67 // The client can be notified either synchronously or asynchronously. 75 // The client can be notified either synchronously or asynchronously.
68 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&, 76 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&,
69 ModuleGraphLevel, 77 ModuleGraphLevel,
70 ModuleScriptLoaderClient*) = 0; 78 ModuleScriptLoaderClient*) = 0;
71 }; 79 };
72 80
73 } // namespace blink 81 } // namespace blink
74 82
75 #endif 83 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698