// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKLET_MODULE_RESPONSES_MAP_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKLET_MODULE_RESPONSES_MAP_H_ #include <optional> #include "base/synchronization/lock.h" #include "base/task/single_thread_task_runner.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h" #include "third_party/blink/renderer/core/loader/modulescript/module_script_fetcher.h" #include "third_party/blink/renderer/platform/heap/cross_thread_persistent.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl_hash.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" namespace blink { // WorkletModuleResponsesMap implements the module responses map concept and the // "fetch a worklet script" algorithm: // https://drafts.css-houdini.org/worklets/#module-responses-map // https://drafts.css-houdini.org/worklets/#fetch-a-worklet-script // // This acts as a cache for creation params (including source code) of module // scripts. The creation params are added using SetEntryParams(), and retrieved // using GetEntry(). If a module script for a given URL has already been // fetched, GetEntry() returns the cached creation params. Otherwise, GetEntry() // returns false and defers to WorkletModuleScriptFetcher to perform the fetch. // Once the module script is fetched, its creation params are cached and // GetEntry() returns it. This class is created on the main thread and shared // across worklet threads. All access to this class should be mutex-guarded, // and any data passed in or read out is copied to ensure that this object's // internal state can be safely destructed from the main thread. class CORE_EXPORT WorkletModuleResponsesMap final : public GarbageCollected<WorkletModuleResponsesMap> { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKLET_MODULE_RESPONSES_MAP_H_