Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/ModuleScript.h |
| diff --git a/third_party/WebKit/Source/core/dom/ModuleScript.h b/third_party/WebKit/Source/core/dom/ModuleScript.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e8ba012fb7f6dded5dfd26c401517a1237deb7d0 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/dom/ModuleScript.h |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ModuleScript_h |
| +#define ModuleScript_h |
| + |
| +#include "bindings/core/v8/ScriptModule.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
| +#include "core/fetch/ResourceLoaderOptions.h" |
| +#include "platform/heap/Handle.h" |
| +#include "platform/weborigin/KURL.h" |
| +#include "public/platform/WebURLRequest.h" |
| + |
| +namespace blink { |
| + |
| +// https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-instantiation-state |
| +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.
|
| + Uninstantiated, |
| + Errored, |
| + Instantiated, |
| +}; |
| + |
| +// ModuleScript is a model object for the "module script" spec concept. |
| +// https://html.spec.whatwg.org/multipage/webappapis.html#module-script |
| +class ModuleScript final : public GarbageCollectedFinalized<ModuleScript> { |
| + public: |
| + static ModuleScript* create( |
| + ScriptModule record, |
| + const KURL& baseURL, |
| + const String& nonce, |
| + ParserDisposition parserState, |
| + WebURLRequest::FetchCredentialsMode credentialsMode) { |
| + return new ModuleScript(record, baseURL, nonce, parserState, |
| + credentialsMode); |
| + } |
| + ~ModuleScript() = default; |
| + |
| + ScriptModule record() { return m_record; } |
|
yhirano
2017/01/19 04:17:04
+const
kouhei (in TOK)
2017/01/27 18:46:27
Done.
|
| + const KURL& baseURL() { return m_baseURL; } |
|
yhirano
2017/01/19 04:17:05
+const
kouhei (in TOK)
2017/01/27 18:46:27
Done.
|
| + |
| + InstantiationState instantiationState() const { return m_instantiationState; } |
| + void updateStateAfterInstantiation(ScriptValue maybeError); |
| + |
| + ScriptValue instantiationError() { return m_instantiationError; } |
| + void propagateUpstreamError(ScriptValue error); |
| + void propagateUpstreamSuccess(); |
| + |
| + ParserDisposition parserState() const { return m_parserState; }; |
| + WebURLRequest::FetchCredentialsMode credentialsMode() const { |
| + return m_credentialsMode; |
| + } |
| + const String& nonce() const { return m_nonce; } |
| + |
|
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
|
| + DEFINE_INLINE_TRACE() {} |
| + |
| + private: |
| + ModuleScript(ScriptModule record, |
| + const KURL& baseURL, |
| + const String& nonce, |
| + ParserDisposition parserState, |
| + WebURLRequest::FetchCredentialsMode credentialsMode) |
| + : m_record(record), |
| + m_baseURL(baseURL), |
| + m_nonce(nonce), |
| + m_parserState(parserState), |
| + m_credentialsMode(credentialsMode) {} |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-module-record |
| + ScriptModule m_record; |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-base-url |
| + const KURL m_baseURL; |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-instantiation-state |
| + InstantiationState m_instantiationState = InstantiationState::Uninstantiated; |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-instantiation-error |
| + 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
|
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-nonce |
| + const String m_nonce; |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-parser |
| + const ParserDisposition m_parserState; |
| + |
| + // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-credentials-mode |
| + const WebURLRequest::FetchCredentialsMode m_credentialsMode; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif |