Chromium Code Reviews| 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/fetch/ResourceLoaderOptions.h" | |
| 11 #include "platform/heap/Handle.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 InstantiationState { | |
|
yhirano
2017/01/19 04:17:04
Isn't this too generic? Maybe ModuleInstantiationS
kouhei (in TOK)
2017/01/27 18:46:27
Done.
| |
| 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 ModuleScript final : public GarbageCollectedFinalized<ModuleScript> { | |
| 27 public: | |
| 28 static ModuleScript* create( | |
| 29 ScriptModule record, | |
| 30 const KURL& baseURL, | |
| 31 const String& nonce, | |
| 32 ParserDisposition parserState, | |
| 33 WebURLRequest::FetchCredentialsMode credentialsMode) { | |
| 34 return new ModuleScript(record, baseURL, nonce, parserState, | |
| 35 credentialsMode); | |
| 36 } | |
| 37 ~ModuleScript() = default; | |
| 38 | |
| 39 ScriptModule record() { return m_record; } | |
|
yhirano
2017/01/19 04:17:04
+const
kouhei (in TOK)
2017/01/27 18:46:27
Done.
| |
| 40 const KURL& baseURL() { return m_baseURL; } | |
|
yhirano
2017/01/19 04:17:05
+const
kouhei (in TOK)
2017/01/27 18:46:27
Done.
| |
| 41 | |
| 42 InstantiationState instantiationState() const { return m_instantiationState; } | |
| 43 void updateStateAfterInstantiation(ScriptValue maybeError); | |
| 44 | |
| 45 ScriptValue instantiationError() { return m_instantiationError; } | |
| 46 void propagateUpstreamError(ScriptValue error); | |
| 47 void propagateUpstreamSuccess(); | |
| 48 | |
| 49 ParserDisposition parserState() const { return m_parserState; }; | |
| 50 WebURLRequest::FetchCredentialsMode credentialsMode() const { | |
| 51 return m_credentialsMode; | |
| 52 } | |
| 53 const String& nonce() const { return m_nonce; } | |
| 54 | |
|
domenic
2017/01/19 05:23:59
I guess the spec's "settings object" (~ v8::Contex
kouhei (in TOK)
2017/01/19 05:27:37
We will use Modulator::m_scriptState->v8::Context.
kouhei (in TOK)
2017/01/19 08:50:21
The V8 callback for the abstract operation passes
| |
| 55 DEFINE_INLINE_TRACE() {} | |
| 56 | |
| 57 private: | |
| 58 ModuleScript(ScriptModule record, | |
| 59 const KURL& baseURL, | |
| 60 const String& nonce, | |
| 61 ParserDisposition parserState, | |
| 62 WebURLRequest::FetchCredentialsMode credentialsMode) | |
| 63 : m_record(record), | |
| 64 m_baseURL(baseURL), | |
| 65 m_nonce(nonce), | |
| 66 m_parserState(parserState), | |
| 67 m_credentialsMode(credentialsMode) {} | |
| 68 | |
| 69 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record | |
| 70 ScriptModule m_record; | |
| 71 | |
| 72 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url | |
| 73 const KURL m_baseURL; | |
| 74 | |
| 75 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-state | |
| 76 InstantiationState m_instantiationState = InstantiationState::Uninstantiated; | |
| 77 | |
| 78 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-error | |
| 79 ScriptValue m_instantiationError; | |
|
yhirano
2017/01/19 04:17:04
Having a ScriptValue is problematic because it can
domenic
2017/01/19 05:23:59
I guess technically this can only be one of the er
kouhei (in TOK)
2017/01/19 05:27:37
Still trying to wrap around my head. I'm trying to
| |
| 80 | |
| 81 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-nonce | |
| 82 const String m_nonce; | |
| 83 | |
| 84 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser | |
| 85 const ParserDisposition m_parserState; | |
| 86 | |
| 87 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode | |
| 88 const WebURLRequest::FetchCredentialsMode m_credentialsMode; | |
| 89 }; | |
| 90 | |
| 91 } // namespace blink | |
| 92 | |
| 93 #endif | |
| OLD | NEW |