Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: third_party/WebKit/Source/core/dom/ModuleScript.h

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: address haraken/yhirano comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2ab708a55ea95eb317990a51fcc7b033add52c8f
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/ModuleScript.h
@@ -0,0 +1,73 @@
+// 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 "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 {
+ 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) {
+ return new ModuleScript(record, baseURL);
+ }
+ ~ModuleScript() = default;
+
+ ScriptModule record() { return m_record; }
+ const KURL& baseURL() { return m_baseURL; }
+
+ InstantiationState instantiationState() const { return m_instantiationState; }
+ void updateStateAfterInstantiation(ScriptValue maybeError);
+
+ void propagateUpstreamError(ScriptValue error);
+ void propagateUpstreamSuccess();
+
+ ScriptValue instantiationError() const { return m_instantiationError; }
+
+ DEFINE_INLINE_TRACE() {}
+
+ private:
+ ModuleScript(ScriptModule record, const KURL& baseURL)
+ : m_record(record), m_baseURL(baseURL) {}
+
+ // 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;
+
+ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-credentials-mode
+ // const WebURLRequest::FetchCredentialsMode m_credentialsMode;
+
+ // 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;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698