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

Side by Side Diff: third_party/WebKit/Source/core/dom/ModuleScript.cpp

Issue 2845743003: Move "create a module script" from ModuleScriptLoader to ModuleScript (Closed)
Patch Set: Rebase Created 3 years, 7 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 #include "core/dom/ModuleScript.h" 5 #include "core/dom/ModuleScript.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "v8/include/v8.h" 9 #include "v8/include/v8.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 ModuleScript* ModuleScript::Create(
14 const String& source_text,
15 Modulator* modulator,
16 const KURL& base_url,
17 const String& nonce,
18 ParserDisposition parser_state,
19 WebURLRequest::FetchCredentialsMode credentials_mode,
20 AccessControlStatus access_control_status) {
21 // Step 1. Let script be a new module script that this algorithm will
22 // subsequently initialize.
23 // Step 2. Set script's settings object to the environment settings object
24 // provided.
25 // Note: "script's settings object" will be "modulator".
26
27 // Delegate to Modulator::compileModule to process Steps 3-6.
28 ScriptModule result = modulator->CompileModule(
29 source_text, base_url.GetString(), access_control_status);
30 // Step 6: "...return null, and abort these steps."
31 if (result.IsNull())
32 return nullptr;
33 // Step 7. Set script's module record to result.
34 // Step 8. Set script's base URL to the script base URL provided.
35 // Step 9. Set script's cryptographic nonce to the cryptographic nonce
36 // provided.
37 // Step 10. Set script's parser state to the parser state.
38 // Step 11. Set script's credentials mode to the credentials mode provided.
39 // Step 12. Return script.
40 return new ModuleScript(modulator, result, base_url, nonce, parser_state,
41 credentials_mode);
42 }
43
13 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) { 44 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) {
14 // Implements Step 7.1 of: 45 // Implements Step 7.1 of:
15 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri pt-graph-fetching-procedure 46 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri pt-graph-fetching-procedure
16 47
17 // "set script's instantiation state to "errored", ..." 48 // "set script's instantiation state to "errored", ..."
18 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); 49 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated);
19 instantiation_state_ = ModuleInstantiationState::kErrored; 50 instantiation_state_ = ModuleInstantiationState::kErrored;
20 51
21 // "its instantiation error to instantiationStatus.[[Value]], and ..." 52 // "its instantiation error to instantiationStatus.[[Value]], and ..."
22 DCHECK(!error.IsEmpty()); 53 DCHECK(!error.IsEmpty());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 93 }
63 94
64 String ModuleScript::InlineSourceTextForCSP() const { 95 String ModuleScript::InlineSourceTextForCSP() const {
65 // Currently we don't support inline module scripts. 96 // Currently we don't support inline module scripts.
66 // TODO(hiroshige): Implement this. 97 // TODO(hiroshige): Implement this.
67 NOTREACHED(); 98 NOTREACHED();
68 return String(); 99 return String();
69 } 100 }
70 101
71 } // namespace blink 102 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ModuleScript.h ('k') | third_party/WebKit/Source/core/dom/ScriptModuleResolverImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698