#include "third_party/blink/renderer/core/loader/resource/script_resource.h"
#include <utility>
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/types/expected.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/code_cache.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_code_cache.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_compile_hints_consumer.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_compile_hints_producer.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/loader/subresource_integrity_helper.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/web_memory_allocator_dump.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/web_process_memory_dump.h"
#include "third_party/blink/renderer/platform/loader/fetch/cached_metadata.h"
#include "third_party/blink/renderer/platform/loader/fetch/data_pipe_bytes_consumer.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/integrity_metadata.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_client_walker.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader.h"
#include "third_party/blink/renderer/platform/loader/fetch/response_body_loader.h"
#include "third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h"
#include "third_party/blink/renderer/platform/loader/fetch/text_resource_decoder_options.h"
#include "third_party/blink/renderer/platform/loader/fetch/url_loader/background_response_processor.h"
#include "third_party/blink/renderer/platform/loader/subresource_integrity.h"
#include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
namespace blink {
namespace {
bool IsRequestContextSupported(
mojom::blink::RequestContextType request_context) { … }
}
ScriptResource* ScriptResource::Fetch(
FetchParameters& params,
ResourceFetcher* fetcher,
ResourceClient* client,
v8::Isolate* isolate,
StreamingAllowed streaming_allowed,
v8_compile_hints::V8CrowdsourcedCompileHintsProducer*
v8_compile_hints_producer,
v8_compile_hints::V8CrowdsourcedCompileHintsConsumer*
v8_compile_hints_consumer,
bool v8_compile_hints_magic_comment_runtime_enabled) { … }
ScriptResource* ScriptResource::CreateForTest(
v8::Isolate* isolate,
const KURL& url,
const WTF::TextEncoding& encoding,
mojom::blink::ScriptType script_type) { … }
ScriptResource::ScriptResource(
const ResourceRequest& resource_request,
const ResourceLoaderOptions& options,
const TextResourceDecoderOptions& decoder_options,
v8::Isolate* isolate,
StreamingAllowed streaming_allowed,
v8_compile_hints::V8CrowdsourcedCompileHintsProducer*
v8_compile_hints_producer,
v8_compile_hints::V8CrowdsourcedCompileHintsConsumer*
v8_compile_hints_consumer,
bool v8_compile_hints_magic_comment_runtime_enabled,
mojom::blink::ScriptType initial_request_script_type)
: … { … }
ScriptResource::~ScriptResource() = default;
void ScriptResource::Trace(Visitor* visitor) const { … }
void ScriptResource::OnMemoryDump(WebMemoryDumpLevelOfDetail level_of_detail,
WebProcessMemoryDump* memory_dump) const { … }
const ParkableString& ScriptResource::SourceText() { … }
String ScriptResource::TextForInspector() const { … }
CachedMetadataHandler* ScriptResource::CacheHandler() { … }
void ScriptResource::SetSerializedCachedMetadata(mojo_base::BigBuffer data) { … }
void ScriptResource::DestroyDecodedDataIfPossible() { … }
void ScriptResource::DestroyDecodedDataForFailedRevalidation() { … }
void ScriptResource::SetRevalidatingRequest(
const ResourceRequestHead& request) { … }
bool ScriptResource::CanUseCacheValidator() const { … }
size_t ScriptResource::CodeCacheSize() const { … }
void ScriptResource::ResponseReceived(const ResourceResponse& response) { … }
void ScriptResource::ResponseBodyReceived(
ResponseBodyLoaderDrainableInterface& body_loader,
scoped_refptr<base::SingleThreadTaskRunner> loader_task_runner) { … }
void ScriptResource::DidReceiveDecodedData(
const String& data,
std::unique_ptr<ParkableStringImpl::SecureDigest> digest) { … }
void ScriptResource::NotifyFinished() { … }
void ScriptResource::SetEncoding(const String& chs) { … }
ScriptStreamer* ScriptResource::TakeStreamer() { … }
void ScriptResource::DisableStreaming(
ScriptStreamer::NotStreamingReason no_streamer_reason) { … }
void ScriptResource::AdvanceStreamingState(StreamingState new_state) { … }
void ScriptResource::CheckStreamingState() const { … }
ScriptCacheConsumer* ScriptResource::TakeCacheConsumer() { … }
void ScriptResource::DisableOffThreadConsumeCache() { … }
void ScriptResource::AdvanceConsumeCacheState(ConsumeCacheState new_state) { … }
void ScriptResource::CheckConsumeCacheState() const { … }
std::unique_ptr<BackgroundResponseProcessorFactory>
ScriptResource::MaybeCreateBackgroundResponseProcessorFactory() { … }
}