| 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 "core/dom/Script.h" |
| 14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 15 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 15 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 16 #include "platform/weborigin/KURL.h" | 16 #include "platform/weborigin/KURL.h" |
| 17 #include "public/platform/WebURLRequest.h" | 17 #include "public/platform/WebURLRequest.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 // 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 |
| 22 enum class ModuleInstantiationState { | 22 enum class ModuleInstantiationState { |
| 23 kUninstantiated, | 23 kUninstantiated, |
| 24 kErrored, | 24 kErrored, |
| 25 kInstantiated, | 25 kInstantiated, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // ModuleScript is a model object for the "module script" spec concept. | 28 // ModuleScript is a model object for the "module script" spec concept. |
| 29 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script | 29 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script |
| 30 class CORE_EXPORT ModuleScript final : public Script { | 30 class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase { |
| 31 public: | 31 public: |
| 32 static ModuleScript* Create( | 32 static ModuleScript* Create( |
| 33 ScriptModule record, | 33 ScriptModule record, |
| 34 const KURL& base_url, | 34 const KURL& base_url, |
| 35 const String& nonce, | 35 const String& nonce, |
| 36 ParserDisposition parser_state, | 36 ParserDisposition parser_state, |
| 37 WebURLRequest::FetchCredentialsMode credentials_mode) { | 37 WebURLRequest::FetchCredentialsMode credentials_mode) { |
| 38 return new ModuleScript(record, base_url, nonce, parser_state, | 38 return new ModuleScript(record, base_url, nonce, parser_state, |
| 39 credentials_mode); | 39 credentials_mode); |
| 40 } | 40 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 51 void SetInstantiationSuccess(); | 51 void SetInstantiationSuccess(); |
| 52 void SetInstantiationError(v8::Isolate*, v8::Local<v8::Value> error); | 52 void SetInstantiationError(v8::Isolate*, v8::Local<v8::Value> error); |
| 53 | 53 |
| 54 ParserDisposition ParserState() const { return parser_state_; } | 54 ParserDisposition ParserState() const { return parser_state_; } |
| 55 WebURLRequest::FetchCredentialsMode CredentialsMode() const { | 55 WebURLRequest::FetchCredentialsMode CredentialsMode() const { |
| 56 return credentials_mode_; | 56 return credentials_mode_; |
| 57 } | 57 } |
| 58 const String& Nonce() const { return nonce_; } | 58 const String& Nonce() const { return nonce_; } |
| 59 | 59 |
| 60 DECLARE_TRACE(); | 60 DECLARE_TRACE(); |
| 61 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 61 DECLARE_TRACE_WRAPPERS(); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 ModuleScript(ScriptModule record, | 64 ModuleScript(ScriptModule record, |
| 65 const KURL& base_url, | 65 const KURL& base_url, |
| 66 const String& nonce, | 66 const String& nonce, |
| 67 ParserDisposition parser_state, | 67 ParserDisposition parser_state, |
| 68 WebURLRequest::FetchCredentialsMode credentials_mode) | 68 WebURLRequest::FetchCredentialsMode credentials_mode) |
| 69 : record_(record), | 69 : record_(record), |
| 70 base_url_(base_url), | 70 base_url_(base_url), |
| 71 instantiation_error_(this), | 71 instantiation_error_(this), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 ScriptModule record_; | 89 ScriptModule record_; |
| 90 | 90 |
| 91 // 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 |
| 92 const KURL base_url_; | 92 const KURL base_url_; |
| 93 | 93 |
| 94 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-state | 94 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-state |
| 95 ModuleInstantiationState instantiation_state_ = | 95 ModuleInstantiationState instantiation_state_ = |
| 96 ModuleInstantiationState::kUninstantiated; | 96 ModuleInstantiationState::kUninstantiated; |
| 97 | 97 |
| 98 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-error | 98 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-instantiation-error |
| 99 // |
| 100 // |instantiation_error_| is TraceWrappers()ed and kept alive via the path of |
| 101 // v8::Context -> PerContextData -> Modulator/ModulatorImpl |
| 102 // -> ModuleMap -> ModuleMap::Entry -> ModuleScript -> instantiation_error_. |
| 103 // All the classes/references on the path above should be |
| 104 // TraceWrapperBase/TraceWrapperMember<>/etc., |
| 105 // but other references to those classes can be normal Member<>. |
| 99 TraceWrapperV8Reference<v8::Value> instantiation_error_; | 106 TraceWrapperV8Reference<v8::Value> instantiation_error_; |
| 100 | 107 |
| 101 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-nonce | 108 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-nonce |
| 102 const String nonce_; | 109 const String nonce_; |
| 103 | 110 |
| 104 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser | 111 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-parser |
| 105 const ParserDisposition parser_state_; | 112 const ParserDisposition parser_state_; |
| 106 | 113 |
| 107 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode | 114 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
t-credentials-mode |
| 108 const WebURLRequest::FetchCredentialsMode credentials_mode_; | 115 const WebURLRequest::FetchCredentialsMode credentials_mode_; |
| 109 }; | 116 }; |
| 110 | 117 |
| 111 } // namespace blink | 118 } // namespace blink |
| 112 | 119 |
| 113 #endif | 120 #endif |
| OLD | NEW |