chromium/third_party/blink/renderer/core/loader/resource/script_resource.cc

/*
    Copyright (C) 1998 Lars Knoll ([email protected])
    Copyright (C) 2001 Dirk Mueller ([email protected])
    Copyright (C) 2002 Waldo Bastian ([email protected])
    Copyright (C) 2006 Samuel Weinig ([email protected])
    Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

    This class provides all functionality needed for loading images, style
    sheets and html pages from the web. It has a memory cache for these objects.
*/

#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 {

// Returns true if the given request context is a valid destination for
// scripts or modules. This includes:
// - script-like https://fetch.spec.whatwg.org/#request-destination-script-like
// - json
// - style
// These contextes to the destinations that the request performed by
// https://html.spec.whatwg.org/#fetch-a-single-module-script can have.
bool IsRequestContextSupported(
    mojom::blink::RequestContextType request_context) {}

}  // namespace

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() {}

}  // namespace blink