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

Side by Side 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: rebased Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "bindings/core/v8/TraceWrapperV8Reference.h"
9 #include "core/CoreExport.h" 12 #include "core/CoreExport.h"
10 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
11 #include "platform/loader/fetch/ResourceLoaderOptions.h" 14 #include "platform/loader/fetch/ResourceLoaderOptions.h"
12 #include "platform/weborigin/KURL.h" 15 #include "platform/weborigin/KURL.h"
13 #include "public/platform/WebURLRequest.h" 16 #include "public/platform/WebURLRequest.h"
14 17
15 namespace blink { 18 namespace blink {
16 19
17 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script- instantiation-state 20 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script- instantiation-state
18 enum class ModuleInstantiationState { 21 enum class ModuleInstantiationState {
19 Uninstantiated, 22 Uninstantiated,
20 Errored, 23 Errored,
21 Instantiated, 24 Instantiated,
22 }; 25 };
23 26
24 // ModuleScript is a model object for the "module script" spec concept. 27 // ModuleScript is a model object for the "module script" spec concept.
25 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script 28 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script
26 class CORE_EXPORT ModuleScript final 29 class CORE_EXPORT ModuleScript final
27 : public GarbageCollectedFinalized<ModuleScript> { 30 : public GarbageCollectedFinalized<ModuleScript>, public TraceWrapperBase {
28 public: 31 public:
29 static ModuleScript* create( 32 static ModuleScript* create(
30 ScriptModule record, 33 ScriptModule record,
31 const KURL& baseURL, 34 const KURL& baseURL,
32 const String& nonce, 35 const String& nonce,
33 ParserDisposition parserState, 36 ParserDisposition parserState,
34 WebURLRequest::FetchCredentialsMode credentialsMode) { 37 WebURLRequest::FetchCredentialsMode credentialsMode) {
35 return new ModuleScript(record, baseURL, nonce, parserState, 38 return new ModuleScript(record, baseURL, nonce, parserState,
36 credentialsMode); 39 credentialsMode);
37 } 40 }
38 ~ModuleScript() = default; 41 ~ModuleScript() = default;
39 42
40 ScriptModule& record() { return m_record; } 43 ScriptModule& record() { return m_record; }
41 void clearRecord() { m_record = ScriptModule(); } 44 void clearRecord() { m_record = ScriptModule(); }
42 const KURL& baseURL() const { return m_baseURL; } 45 const KURL& baseURL() const { return m_baseURL; }
43 46
47 ModuleInstantiationState instantiationState() const {
48 return m_instantiationState;
49 }
50
51 void setInstantiationSuccess();
52 void setInstantiationError(v8::Isolate* isolate, v8::Local<v8::Value> error);
53
44 ParserDisposition parserState() const { return m_parserState; } 54 ParserDisposition parserState() const { return m_parserState; }
45 WebURLRequest::FetchCredentialsMode credentialsMode() const { 55 WebURLRequest::FetchCredentialsMode credentialsMode() const {
46 return m_credentialsMode; 56 return m_credentialsMode;
47 } 57 }
48 const String& nonce() const { return m_nonce; } 58 const String& nonce() const { return m_nonce; }
49 59
50 ModuleInstantiationState instantiationState() const {
51 return m_instantiationState;
52 }
53
54 DECLARE_TRACE(); 60 DECLARE_TRACE();
61 DECLARE_VIRTUAL_TRACE_WRAPPERS();
55 62
56 private: 63 private:
57 ModuleScript(ScriptModule record, 64 ModuleScript(ScriptModule record,
58 const KURL& baseURL, 65 const KURL& baseURL,
59 const String& nonce, 66 const String& nonce,
60 ParserDisposition parserState, 67 ParserDisposition parserState,
61 WebURLRequest::FetchCredentialsMode credentialsMode) 68 WebURLRequest::FetchCredentialsMode credentialsMode)
62 : m_record(record), 69 : m_record(record),
63 m_baseURL(baseURL), 70 m_baseURL(baseURL),
71 m_instantiationError(this),
64 m_nonce(nonce), 72 m_nonce(nonce),
65 m_parserState(parserState), 73 m_parserState(parserState),
66 m_credentialsMode(credentialsMode) {} 74 m_credentialsMode(credentialsMode) {}
67 75
68 // Note: A "module script"'s "setttings object" is ommitted, as we currently 76 // Note: A "module script"'s "setttings object" is ommitted, as we currently
69 // always have access to the corresponding Modulator when operating on a 77 // always have access to the corresponding Modulator when operating on a
70 // ModuleScript instance. 78 // ModuleScript instance.
71 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object 79 // https://html.spec.whatwg.org/multipage/webappapis.html#settings-object
72 80
73 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record 81 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-module-record
74 ScriptModule m_record; 82 ScriptModule m_record;
75 83
76 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url 84 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-base-url
77 const KURL m_baseURL; 85 const KURL m_baseURL;
78 86
79 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-state 87 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-state
80 ModuleInstantiationState m_instantiationState = 88 ModuleInstantiationState m_instantiationState =
81 ModuleInstantiationState::Uninstantiated; 89 ModuleInstantiationState::Uninstantiated;
82 90
83 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-error 91 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-instantiation-error
84 // TODO(kouhei): Add a corresponding member. 92 TraceWrapperV8Reference<v8::Value> m_instantiationError;
85 93
86 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-nonce 94 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-nonce
87 const String m_nonce; 95 const String m_nonce;
88 96
89 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser 97 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-parser
90 const ParserDisposition m_parserState; 98 const ParserDisposition m_parserState;
91 99
92 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode 100 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip t-credentials-mode
93 const WebURLRequest::FetchCredentialsMode m_credentialsMode; 101 const WebURLRequest::FetchCredentialsMode m_credentialsMode;
94 }; 102 };
95 103
96 } // namespace blink 104 } // namespace blink
97 105
98 #endif 106 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698