| OLD | NEW | 
|    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" |    9 #include "bindings/core/v8/ScriptValue.h" | 
|   10 #include "bindings/core/v8/ScriptWrappable.h" |   10 #include "bindings/core/v8/ScriptWrappable.h" | 
|   11 #include "bindings/core/v8/TraceWrapperV8Reference.h" |   11 #include "bindings/core/v8/TraceWrapperV8Reference.h" | 
|   12 #include "core/CoreExport.h" |   12 #include "core/CoreExport.h" | 
|   13 #include "core/dom/Modulator.h" |   13 #include "core/dom/Modulator.h" | 
|   14 #include "core/dom/Script.h" |   14 #include "core/dom/Script.h" | 
|   15 #include "platform/heap/Handle.h" |   15 #include "platform/heap/Handle.h" | 
|   16 #include "platform/loader/fetch/ResourceLoaderOptions.h" |   16 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 
|   17 #include "platform/weborigin/KURL.h" |   17 #include "platform/weborigin/KURL.h" | 
|   18 #include "public/platform/WebURLRequest.h" |   18 #include "public/platform/WebURLRequest.h" | 
|   19  |   19  | 
|   20 namespace blink { |   20 namespace blink { | 
|   21  |   21  | 
 |   22 class ScriptModuleResolver; | 
 |   23  | 
|   22 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-
     instantiation-state |   24 // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-script-
     instantiation-state | 
|   23 enum class ModuleInstantiationState { |   25 enum class ModuleInstantiationState { | 
|   24   kUninstantiated, |   26   kUninstantiated, | 
|   25   kErrored, |   27   kErrored, | 
|   26   kInstantiated, |   28   kInstantiated, | 
|   27 }; |   29 }; | 
|   28  |   30  | 
|   29 // ModuleScript is a model object for the "module script" spec concept. |   31 // ModuleScript is a model object for the "module script" spec concept. | 
|   30 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script |   32 // https://html.spec.whatwg.org/multipage/webappapis.html#module-script | 
|   31 class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase { |   33 class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase { | 
|   32  public: |   34  public: | 
|   33   static ModuleScript* Create( |   35   static ModuleScript* Create( | 
|   34       Modulator* settings_object, |   36       Modulator* settings_object, | 
|   35       ScriptModule record, |   37       ScriptModule record, | 
|   36       const KURL& base_url, |   38       const KURL& base_url, | 
|   37       const String& nonce, |   39       const String& nonce, | 
|   38       ParserDisposition parser_state, |   40       ParserDisposition parser_state, | 
|   39       WebURLRequest::FetchCredentialsMode credentials_mode) { |   41       WebURLRequest::FetchCredentialsMode credentials_mode) { | 
|   40     return new ModuleScript(settings_object, record, base_url, nonce, |   42     return new ModuleScript(settings_object, record, base_url, nonce, | 
|   41                             parser_state, credentials_mode); |   43                             parser_state, credentials_mode); | 
|   42   } |   44   } | 
|   43   ~ModuleScript() override = default; |   45   ~ModuleScript() override = default; | 
|   44  |   46  | 
|   45   ScriptModule& Record() { return record_; } |   47   const ScriptModule& Record() const { return record_; } | 
|   46   const KURL& BaseURL() const { return base_url_; } |   48   const KURL& BaseURL() const { return base_url_; } | 
|   47  |   49  | 
|   48   ModuleInstantiationState InstantiationState() const { |   50   ModuleInstantiationState InstantiationState() const { | 
|   49     return instantiation_state_; |   51     return instantiation_state_; | 
|   50   } |   52   } | 
|   51  |   53  | 
|   52   // Implements Step 7.1 of: |   54   // Implements Step 7.1 of: | 
|   53   // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
     pt-graph-fetching-procedure |   55   // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
     pt-graph-fetching-procedure | 
|   54   void SetInstantiationErrorAndClearRecord(ScriptValue error); |   56   void SetInstantiationErrorAndClearRecord(ScriptValue error); | 
|   55   // Implements Step 7.2 of: |   57   // Implements Step 7.2 of: | 
|   56   // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
     pt-graph-fetching-procedure |   58   // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
     pt-graph-fetching-procedure | 
|   57   void SetInstantiationSuccess(); |   59   void SetInstantiationSuccess(); | 
|   58  |   60  | 
|   59   ParserDisposition ParserState() const { return parser_state_; } |   61   ParserDisposition ParserState() const { return parser_state_; } | 
|   60   WebURLRequest::FetchCredentialsMode CredentialsMode() const { |   62   WebURLRequest::FetchCredentialsMode CredentialsMode() const { | 
|   61     return credentials_mode_; |   63     return credentials_mode_; | 
|   62   } |   64   } | 
|   63   const String& Nonce() const { return nonce_; } |   65   const String& Nonce() const { return nonce_; } | 
|   64  |   66  | 
 |   67   v8::Local<v8::Value> CreateInstantiationError(v8::Isolate* isolate) const { | 
 |   68     return instantiation_error_.NewLocal(isolate); | 
 |   69   } | 
 |   70  | 
|   65   DECLARE_TRACE(); |   71   DECLARE_TRACE(); | 
|   66   DECLARE_TRACE_WRAPPERS(); |   72   DECLARE_TRACE_WRAPPERS(); | 
|   67  |   73  | 
|   68  private: |   74  private: | 
|   69   ModuleScript(Modulator* settings_object, |   75   ModuleScript(Modulator* settings_object, | 
|   70                ScriptModule record, |   76                ScriptModule record, | 
|   71                const KURL& base_url, |   77                const KURL& base_url, | 
|   72                const String& nonce, |   78                const String& nonce, | 
|   73                ParserDisposition parser_state, |   79                ParserDisposition parser_state, | 
|   74                WebURLRequest::FetchCredentialsMode credentials_mode) |   80                WebURLRequest::FetchCredentialsMode credentials_mode) | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  116   // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
     t-parser |  122   // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
     t-parser | 
|  117   const ParserDisposition parser_state_; |  123   const ParserDisposition parser_state_; | 
|  118  |  124  | 
|  119   // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
     t-credentials-mode |  125   // https://html.spec.whatwg.org/multipage/webappapis.html#concept-module-scrip
     t-credentials-mode | 
|  120   const WebURLRequest::FetchCredentialsMode credentials_mode_; |  126   const WebURLRequest::FetchCredentialsMode credentials_mode_; | 
|  121 }; |  127 }; | 
|  122  |  128  | 
|  123 }  // namespace blink |  129 }  // namespace blink | 
|  124  |  130  | 
|  125 #endif |  131 #endif | 
| OLD | NEW |