OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ModuleScript_h | |
6 #define ModuleScript_h | |
7 | |
8 #include "bindings/core/v8/ScriptModule.h" | |
9 #include "bindings/core/v8/ScriptValue.h" | |
10 #include "core/dom/DOMException.h" | |
11 #include "platform/heap/Handle.h" | |
12 #include "platform/loader/fetch/ResourceLoaderOptions.h" | |
13 #include "platform/weborigin/KURL.h" | |
14 #include "public/platform/WebURLRequest.h" | |
15 | |
16 namespace blink { | |
17 | |
18 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script- instantiation-state | |
19 enum class ModuleInstantiationState { | |
20 Uninstantiated, | |
21 Errored, | |
22 Instantiated, | |
23 }; | |
24 | |
25 // ModuleScript is a model object for the "module script" spec concept. | |
26 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script | |
27 class ModuleScript final : public GarbageCollectedFinalized<ModuleScript> { | |
28 public: | |
29 static ModuleScript* create( | |
30 ScriptModule record, | |
31 const KURL& baseURL, | |
32 const String& nonce, | |
33 ParserDisposition parserState, | |
34 WebURLRequest::FetchCredentialsMode credentialsMode) { | |
35 return new ModuleScript(record, baseURL, nonce, parserState, | |
36 credentialsMode); | |
37 } | |
38 ~ModuleScript() = default; | |
39 | |
40 ScriptModule record() const { return m_record; } | |
41 void clearRecord() { m_record = ScriptModule(); } | |
42 const KURL& baseURL() const { return m_baseURL; } | |
43 | |
44 ParserDisposition parserState() const { return m_parserState; }; | |
hiroshige
2017/01/27 20:54:41
nit: extra semicolon.
kouhei (in TOK)
2017/01/30 17:12:19
Done.
| |
45 WebURLRequest::FetchCredentialsMode credentialsMode() const { | |
46 return m_credentialsMode; | |
47 } | |
48 const String& nonce() const { return m_nonce; } | |
49 | |
50 ModuleInstantiationState instantiationState() const { | |
51 return m_instantiationState; | |
52 } | |
53 | |
54 DECLARE_TRACE(); | |
55 | |
56 private: | |
57 ModuleScript(ScriptModule record, | |
58 const KURL& baseURL, | |
59 const String& nonce, | |
60 ParserDisposition parserState, | |
61 WebURLRequest::FetchCredentialsMode credentialsMode) | |
62 : m_record(record), | |
63 m_baseURL(baseURL), | |
64 m_nonce(nonce), | |
65 m_parserState(parserState), | |
66 m_credentialsMode(credentialsMode) {} | |
67 | |
68 // Note: A "module script"'s "setttings object" is ommitted, as we currently | |
69 // always have access to the corresponding Modulator when operating on a | |
70 // ModuleScript instance. | |
71 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object | |
72 | |
73 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record | |
74 ScriptModule m_record; | |
75 | |
76 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url | |
77 const KURL m_baseURL; | |
78 | |
79 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-state | |
80 ModuleInstantiationState m_instantiationState = | |
81 ModuleInstantiationState::Uninstantiated; | |
82 | |
83 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-error | |
84 // TODO(kouhei): Add a corresponding member. | |
85 | |
86 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-nonce | |
87 const String m_nonce; | |
88 | |
89 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser | |
90 const ParserDisposition m_parserState; | |
91 | |
92 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode | |
93 const WebURLRequest::FetchCredentialsMode m_credentialsMode; | |
94 }; | |
95 | |
96 } // namespace blink | |
97 | |
98 #endif | |
OLD | NEW |