utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, 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. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #include "CachedResourceClient.h" |
| 29 | #include "CachedResourceHandle.h" |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 30 | #include "CachedScriptFetcher.h" |
| 31 | #include "ModuleScriptLoader.h" |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 32 | #include <wtf/Ref.h> |
| 33 | #include <wtf/RefCounted.h> |
| 34 | #include <wtf/RefPtr.h> |
ysuzuki@apple.com | 3166c80 | 2020-01-12 01:25:25 +0000 | [diff] [blame] | 35 | #include <wtf/URL.h> |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 36 | |
| 37 | namespace WebCore { |
| 38 | |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 39 | class ModuleScriptLoaderClient; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 40 | class CachedScript; |
| 41 | class DeferredPromise; |
utatane.tea@gmail.com | 48ea08e | 2017-01-11 12:12:37 +0000 | [diff] [blame] | 42 | class Document; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 43 | class JSDOMGlobalObject; |
utatane.tea@gmail.com | 6069db2 | 2017-10-12 13:12:48 +0000 | [diff] [blame] | 44 | class ModuleFetchParameters; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 45 | |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 46 | class CachedModuleScriptLoader final : public ModuleScriptLoader, private CachedResourceClient { |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 47 | public: |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 48 | static Ref<CachedModuleScriptLoader> create(ModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&); |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 49 | |
| 50 | virtual ~CachedModuleScriptLoader(); |
| 51 | |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 52 | bool load(Document&, URL&& sourceURL); |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 53 | |
| 54 | CachedScript* cachedScript() { return m_cachedScript.get(); } |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 55 | CachedScriptFetcher& scriptFetcher() { return static_cast<CachedScriptFetcher&>(ModuleScriptLoader::scriptFetcher()); } |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 56 | |
| 57 | private: |
ysuzuki@apple.com | 8c1c24c | 2021-02-20 20:28:27 +0000 | [diff] [blame] | 58 | CachedModuleScriptLoader(ModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&); |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 59 | |
commit-queue@webkit.org | 9a4c860 | 2020-05-13 04:14:59 +0000 | [diff] [blame] | 60 | void notifyFinished(CachedResource&, const NetworkLoadMetrics&) final; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 61 | |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 62 | CachedResourceHandle<CachedScript> m_cachedScript; |
ysuzuki@apple.com | 3166c80 | 2020-01-12 01:25:25 +0000 | [diff] [blame] | 63 | URL m_sourceURL; |
utatane.tea@gmail.com | 750fa06 | 2016-11-16 11:39:43 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace WebCore |