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

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

Issue 2643003002: [ES6 modules] Introduce ModuleScript model object (Closed)
Patch Set: yhirano / CORE_EXPORT 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/BUILD.gn ('k') | third_party/WebKit/Source/core/dom/ModuleScript.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5efe745b3db767df8531fd460c6ba0047e8e33c9
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/ModuleScript.h
@@ -0,0 +1,98 @@
+// 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 "core/CoreExport.h"
+#include "platform/heap/Handle.h"
+#include "platform/loader/fetch/ResourceLoaderOptions.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 ModuleInstantiationState {
+ 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 CORE_EXPORT 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; }
+ void clearRecord() { m_record = ScriptModule(); }
+ const KURL& baseURL() const { return m_baseURL; }
+
+ ParserDisposition parserState() const { return m_parserState; }
+ WebURLRequest::FetchCredentialsMode credentialsMode() const {
+ return m_credentialsMode;
+ }
+ const String& nonce() const { return m_nonce; }
+
+ ModuleInstantiationState instantiationState() const {
+ return m_instantiationState;
+ }
+
+ DECLARE_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) {}
+
+ // Note: A "module script"'s "setttings object" is ommitted, as we currently
+ // always have access to the corresponding Modulator when operating on a
+ // ModuleScript instance.
+ // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object
+
+ // 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
+ ModuleInstantiationState m_instantiationState =
+ ModuleInstantiationState::Uninstantiated;
+
+ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-instantiation-error
+ // TODO(kouhei): Add a corresponding member.
+
+ // 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/BUILD.gn ('k') | third_party/WebKit/Source/core/dom/ModuleScript.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698