chromium/content/browser/service_worker/service_worker_updated_script_loader.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/342213636): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "content/browser/service_worker/service_worker_updated_script_loader.h"

#include <memory>
#include <vector>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "content/browser/service_worker/service_worker_cache_writer.h"
#include "content/browser/service_worker/service_worker_consts.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_loader_helpers.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
#include "net/base/ip_endpoint.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/cert/cert_status_flags.h"
#include "services/network/public/mojom/early_hints.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/loader/throttling_url_loader.h"

namespace content {

// We chose this size because the AppCache uses this.
const size_t ServiceWorkerUpdatedScriptLoader::kReadBufferSize =;

// This is for debugging https://crbug.com/959627.
// The purpose is to see where the IOBuffer comes from by checking |__vfptr|.
class ServiceWorkerUpdatedScriptLoader::WrappedIOBuffer
    : public net::WrappedIOBuffer {};

std::unique_ptr<ServiceWorkerUpdatedScriptLoader>
ServiceWorkerUpdatedScriptLoader::CreateAndStart(
    uint32_t options,
    const network::ResourceRequest& original_request,
    mojo::PendingRemote<network::mojom::URLLoaderClient> client,
    scoped_refptr<ServiceWorkerVersion> version) {}

ServiceWorkerUpdatedScriptLoader::ServiceWorkerUpdatedScriptLoader(
    uint32_t options,
    const network::ResourceRequest& original_request,
    mojo::PendingRemote<network::mojom::URLLoaderClient> client,
    scoped_refptr<ServiceWorkerVersion> version)
    :{}

ServiceWorkerUpdatedScriptLoader::~ServiceWorkerUpdatedScriptLoader() = default;

void ServiceWorkerUpdatedScriptLoader::FollowRedirect(
    const std::vector<std::string>& removed_headers,
    const net::HttpRequestHeaders& modified_headers,
    const net::HttpRequestHeaders& modified_cors_exempt_headers,
    const std::optional<GURL>& new_url) {}

void ServiceWorkerUpdatedScriptLoader::SetPriority(
    net::RequestPriority priority,
    int32_t intra_priority_value) {}

void ServiceWorkerUpdatedScriptLoader::PauseReadingBodyFromNet() {}

void ServiceWorkerUpdatedScriptLoader::ResumeReadingBodyFromNet() {}

// URLLoaderClient for network loader ------------------------------------------

void ServiceWorkerUpdatedScriptLoader::OnReceiveEarlyHints(
    network::mojom::EarlyHintsPtr early_hints) {}

void ServiceWorkerUpdatedScriptLoader::OnReceiveResponse(
    network::mojom::URLResponseHeadPtr response_head,
    mojo::ScopedDataPipeConsumerHandle body,
    std::optional<mojo_base::BigBuffer> cached_metadata) {}

void ServiceWorkerUpdatedScriptLoader::OnReceiveRedirect(
    const net::RedirectInfo& redirect_info,
    network::mojom::URLResponseHeadPtr response_head) {}

void ServiceWorkerUpdatedScriptLoader::OnUploadProgress(
    int64_t current_position,
    int64_t total_size,
    OnUploadProgressCallback ack_callback) {}

void ServiceWorkerUpdatedScriptLoader::OnTransferSizeUpdated(
    int32_t transfer_size_diff) {}

void ServiceWorkerUpdatedScriptLoader::OnComplete(
    const network::URLLoaderCompletionStatus& status) {}

// End of URLLoaderClient ------------------------------------------------------

int ServiceWorkerUpdatedScriptLoader::WillWriteResponseHead(
    const network::mojom::URLResponseHead& response_head) {}

void ServiceWorkerUpdatedScriptLoader::OnClientWritable(MojoResult) {}

int ServiceWorkerUpdatedScriptLoader::WillWriteData(
    scoped_refptr<net::IOBuffer> data,
    int length,
    base::OnceCallback<void(net::Error)> callback) {}

void ServiceWorkerUpdatedScriptLoader::OnCacheWriterResumed(
    scoped_refptr<network::MojoToNetPendingBuffer> pending_network_buffer,
    uint32_t consumed_bytes,
    net::Error error) {}

void ServiceWorkerUpdatedScriptLoader::OnNetworkDataAvailable(MojoResult) {}

void ServiceWorkerUpdatedScriptLoader::WriteData(
    scoped_refptr<network::MojoToNetPendingBuffer> pending_buffer,
    uint32_t bytes_available) {}

void ServiceWorkerUpdatedScriptLoader::OnWriteDataComplete(
    scoped_refptr<network::MojoToNetPendingBuffer> pending_buffer,
    size_t bytes_written,
    net::Error error) {}

void ServiceWorkerUpdatedScriptLoader::CommitCompleted(
    const network::URLLoaderCompletionStatus& status,
    const std::string& status_message) {}

}  // namespace content