// Copyright 2021 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_BINDINGS_CORE_V8_SCRIPT_CACHE_CONSUMER_H_ #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SCRIPT_CACHE_CONSUMER_H_ #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "v8/include/v8.h" namespace base { class SingleThreadTaskRunner; } namespace blink { class CachedMetadata; class ClassicScript; class ScriptCacheConsumerClient; // A V8 code cache consumer for a script's code cache, which consumes the code // cache off-thread and notifies a given ScriptCacheConsumerClient once it has // completed. // // ScriptCacheConsumer works on unchecked CachedMetadata speculatively, before // the source is available. If CachedMetadataHandler::Check() fails later, // the CachedMetadata on the CachedMetadataHandler will be cleared, and the // result of this ScriptCacheConsumer will be dropped on TakeV8ConsumeTask() due // to a CachedMetadata mismatch. // // The state of the ScriptCacheConsumer state is associated with a single // CachedMetadata, but it is independent of the state of the corresponding // ScriptResource or its CachedMetadataHandler. Thus, it's fine that one // ClassicPendingScript for the ScriptResource can get a non-null // ConsumeCodeCacheTask from TakeV8ConsumeTask(), while others with the same // ScriptResource don't use ScriptCacheConsumer. It's fine even if a // ClassicPendingScript is notified finished (with or without // ScriptCacheConsumer), and executes a script for a ScriptResource while // another ClassicPendingScript for the same ScriptResource with the same // CachedMetadata is still waiting for ScriptCacheConsumer completion. class CORE_EXPORT ScriptCacheConsumer final : public GarbageCollected<ScriptCacheConsumer> { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SCRIPT_CACHE_CONSUMER_H_