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 "core/CoreExport.h" |
| 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 12 #include "platform/weborigin/KURL.h" |
| 13 #include "public/platform/WebURLRequest.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-
instantiation-state |
| 18 enum class ModuleInstantiationState { |
| 19 Uninstantiated, |
| 20 Errored, |
| 21 Instantiated, |
| 22 }; |
| 23 |
| 24 // ModuleScript is a model object for the "module script" spec concept. |
| 25 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script |
| 26 class CORE_EXPORT ModuleScript final |
| 27 : 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() { 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; } |
| 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 |