Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 ModuleScript_h | 5 #ifndef ModuleScript_h |
| 6 #define ModuleScript_h | 6 #define ModuleScript_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptModule.h" | 8 #include "bindings/core/v8/ScriptModule.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "bindings/core/v8/TraceWrapperV8Reference.h" | 11 #include "bindings/core/v8/TraceWrapperV8Reference.h" |
| 12 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
| 13 #include "core/dom/Script.h" | |
| 13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 14 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 15 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 15 #include "platform/weborigin/KURL.h" | 16 #include "platform/weborigin/KURL.h" |
| 16 #include "public/platform/WebURLRequest.h" | 17 #include "public/platform/WebURLRequest.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script- instantiation-state | 21 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script- instantiation-state |
| 21 enum class ModuleInstantiationState { | 22 enum class ModuleInstantiationState { |
| 22 Uninstantiated, | 23 Uninstantiated, |
| 23 Errored, | 24 Errored, |
| 24 Instantiated, | 25 Instantiated, |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 // ModuleScript is a model object for the "module script" spec concept. | 28 // ModuleScript is a model object for the "module script" spec concept. |
| 28 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script | 29 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script |
| 29 class CORE_EXPORT ModuleScript final | 30 class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase { |
|
kouhei (in TOK)
2017/04/06 09:42:35
I think Script needs to be TraceWrapperBase if we
hiroshige
2017/04/06 17:36:29
Done.
| |
| 30 : public GarbageCollectedFinalized<ModuleScript>, | |
| 31 public TraceWrapperBase { | |
| 32 public: | 31 public: |
| 33 static ModuleScript* create( | 32 static ModuleScript* create( |
| 34 ScriptModule record, | 33 ScriptModule record, |
| 35 const KURL& baseURL, | 34 const KURL& baseURL, |
| 36 const String& nonce, | 35 const String& nonce, |
| 37 ParserDisposition parserState, | 36 ParserDisposition parserState, |
| 38 WebURLRequest::FetchCredentialsMode credentialsMode) { | 37 WebURLRequest::FetchCredentialsMode credentialsMode) { |
| 39 return new ModuleScript(record, baseURL, nonce, parserState, | 38 return new ModuleScript(record, baseURL, nonce, parserState, |
| 40 credentialsMode); | 39 credentialsMode); |
| 41 } | 40 } |
| 42 ~ModuleScript() = default; | 41 ~ModuleScript() override = default; |
| 43 | 42 |
| 44 ScriptModule& record() { return m_record; } | 43 ScriptModule& record() { return m_record; } |
| 45 void clearRecord() { m_record = ScriptModule(); } | 44 void clearRecord() { m_record = ScriptModule(); } |
| 46 const KURL& baseURL() const { return m_baseURL; } | 45 const KURL& baseURL() const { return m_baseURL; } |
| 47 | 46 |
| 48 ModuleInstantiationState instantiationState() const { | 47 ModuleInstantiationState instantiationState() const { |
| 49 return m_instantiationState; | 48 return m_instantiationState; |
| 50 } | 49 } |
| 51 | 50 |
| 52 void setInstantiationSuccess(); | 51 void setInstantiationSuccess(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 67 const String& nonce, | 66 const String& nonce, |
| 68 ParserDisposition parserState, | 67 ParserDisposition parserState, |
| 69 WebURLRequest::FetchCredentialsMode credentialsMode) | 68 WebURLRequest::FetchCredentialsMode credentialsMode) |
| 70 : m_record(record), | 69 : m_record(record), |
| 71 m_baseURL(baseURL), | 70 m_baseURL(baseURL), |
| 72 m_instantiationError(this), | 71 m_instantiationError(this), |
| 73 m_nonce(nonce), | 72 m_nonce(nonce), |
| 74 m_parserState(parserState), | 73 m_parserState(parserState), |
| 75 m_credentialsMode(credentialsMode) {} | 74 m_credentialsMode(credentialsMode) {} |
| 76 | 75 |
| 76 ScriptType scriptType() const override { return ScriptType::Module; } | |
| 77 bool isEmpty() const override; | |
| 78 bool checkMIMETypeBeforeRunScript(Document* contextDocument, | |
| 79 const SecurityOrigin*) const override; | |
| 80 void runScript(LocalFrame*, const SecurityOrigin*) const override; | |
| 81 String inlineSourceTextForCSP() const override; | |
| 82 | |
| 77 // Note: A "module script"'s "setttings object" is ommitted, as we currently | 83 // Note: A "module script"'s "setttings object" is ommitted, as we currently |
| 78 // always have access to the corresponding Modulator when operating on a | 84 // always have access to the corresponding Modulator when operating on a |
| 79 // ModuleScript instance. | 85 // ModuleScript instance. |
| 80 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object | 86 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object |
| 81 | 87 |
| 82 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record | 88 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record |
| 83 ScriptModule m_record; | 89 ScriptModule m_record; |
| 84 | 90 |
| 85 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url | 91 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url |
| 86 const KURL m_baseURL; | 92 const KURL m_baseURL; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 98 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser | 104 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser |
| 99 const ParserDisposition m_parserState; | 105 const ParserDisposition m_parserState; |
| 100 | 106 |
| 101 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode | 107 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode |
| 102 const WebURLRequest::FetchCredentialsMode m_credentialsMode; | 108 const WebURLRequest::FetchCredentialsMode m_credentialsMode; |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 } // namespace blink | 111 } // namespace blink |
| 106 | 112 |
| 107 #endif | 113 #endif |
| OLD | NEW |