utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Apple, Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 28 | #include "LoadableScript.h" |
| 29 | #include <wtf/TypeCasts.h> |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
utatane.tea@gmail.com | 5da4e1a | 2017-01-28 00:47:30 +0000 | [diff] [blame] | 33 | class ScriptSourceCode; |
utatane.tea@gmail.com | 6069db2 | 2017-10-12 13:12:48 +0000 | [diff] [blame] | 34 | class ModuleFetchParameters; |
utatane.tea@gmail.com | 5da4e1a | 2017-01-28 00:47:30 +0000 | [diff] [blame] | 35 | |
| 36 | class LoadableModuleScript final : public LoadableScript { |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 37 | public: |
| 38 | virtual ~LoadableModuleScript(); |
| 39 | |
rniwa@webkit.org | b5617a9 | 2022-02-01 19:12:52 +0000 | [diff] [blame] | 40 | static Ref<LoadableModuleScript> create(const AtomString& nonce, const AtomString& integrity, ReferrerPolicy, const AtomString& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree); |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 41 | |
| 42 | bool isLoaded() const final; |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 43 | std::optional<Error> error() const final; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 44 | bool wasCanceled() const final; |
| 45 | |
utatane.tea@gmail.com | d53760f | 2017-01-27 10:49:23 +0000 | [diff] [blame] | 46 | bool isClassicScript() const final { return false; } |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 47 | bool isModuleScript() const final { return true; } |
| 48 | |
| 49 | void execute(ScriptElement&) final; |
| 50 | |
| 51 | void setError(Error&&); |
| 52 | |
jlewis3@apple.com | 91a058b | 2017-10-20 17:58:32 +0000 | [diff] [blame] | 53 | void notifyLoadCompleted(UniquedStringImpl&); |
| 54 | void notifyLoadFailed(LoadableScript::Error&&); |
| 55 | void notifyLoadWasCanceled(); |
utatane.tea@gmail.com | 5da4e1a | 2017-01-28 00:47:30 +0000 | [diff] [blame] | 56 | |
jlewis3@apple.com | 91a058b | 2017-10-20 17:58:32 +0000 | [diff] [blame] | 57 | UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); } |
utatane.tea@gmail.com | 11efb90 | 2017-10-20 07:19:02 +0000 | [diff] [blame] | 58 | |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 59 | ModuleFetchParameters& parameters() { return m_parameters.get(); } |
| 60 | |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 61 | private: |
rniwa@webkit.org | b5617a9 | 2022-02-01 19:12:52 +0000 | [diff] [blame] | 62 | LoadableModuleScript(const AtomString& nonce, const AtomString& integrity, ReferrerPolicy, const AtomString& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree); |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 63 | |
utatane.tea@gmail.com | 6069db2 | 2017-10-12 13:12:48 +0000 | [diff] [blame] | 64 | Ref<ModuleFetchParameters> m_parameters; |
utatane.tea@gmail.com | 5da4e1a | 2017-01-28 00:47:30 +0000 | [diff] [blame] | 65 | RefPtr<UniquedStringImpl> m_moduleKey; |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 66 | std::optional<LoadableScript::Error> m_error; |
utatane.tea@gmail.com | 5da4e1a | 2017-01-28 00:47:30 +0000 | [diff] [blame] | 67 | bool m_wasCanceled { false }; |
| 68 | bool m_isLoaded { false }; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } |
| 72 | |
| 73 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LoadableModuleScript) |
| 74 | static bool isType(const WebCore::LoadableScript& script) { return script.isModuleScript(); } |
| 75 | SPECIALIZE_TYPE_TRAITS_END() |