chromium/content/services/auction_worklet/worklet_loader.cc

// 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.

#include "content/services/auction_worklet/worklet_loader.h"

#include <stddef.h>

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/task/sequenced_task_runner.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/public/cpp/auction_downloader.h"
#include "content/services/auction_worklet/public/cpp/auction_network_events_delegate.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/http/structured_headers.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-forward.h"
#include "v8/include/v8-wasm.h"

namespace auction_worklet {

namespace {

const char kAllowTrustedScoringSignalsHeader[] =;

}  // namespace

WorkletLoaderBase::Result::Result()
    :{}

WorkletLoaderBase::Result::Result(Result&&) = default;
WorkletLoaderBase::Result::~Result() = default;
WorkletLoaderBase::Result& WorkletLoaderBase::Result::operator=(Result&&) =
    default;

void WorkletLoaderBase::Result::DownloadReady(
    scoped_refptr<AuctionV8Helper> v8_helper,
    size_t original_size_bytes,
    base::TimeDelta download_time) {}

WorkletLoaderBase::Result::V8Data::V8Data(
    scoped_refptr<AuctionV8Helper> v8_helper)
    :{}

WorkletLoaderBase::Result::V8Data::~V8Data() = default;

void WorkletLoaderBase::Result::V8Data::SetScript(
    v8::Global<v8::UnboundScript> in_script) {}

void WorkletLoaderBase::Result::V8Data::SetModule(
    v8::Global<v8::WasmModuleObject> in_module) {}

WorkletLoaderBase::WorkletLoaderBase(
    network::mojom::URLLoaderFactory* url_loader_factory,
    mojo::PendingRemote<auction_worklet::mojom::AuctionNetworkEventsHandler>
        auction_network_events_handler,
    const GURL& source_url,
    AuctionDownloader::MimeType mime_type,
    std::vector<scoped_refptr<AuctionV8Helper>> v8_helpers,
    std::vector<scoped_refptr<AuctionV8Helper::DebugId>> debug_ids,
    AuctionDownloader::ResponseStartedCallback response_started_callback,
    LoadWorkletCallback load_worklet_callback)
    :{}

WorkletLoaderBase::~WorkletLoaderBase() = default;

void WorkletLoaderBase::OnDownloadComplete(
    std::unique_ptr<std::string> body,
    scoped_refptr<net::HttpResponseHeaders> headers,
    std::optional<std::string> error_msg) {}

// static
void WorkletLoaderBase::HandleDownloadResultOnV8Thread(
    GURL source_url,
    AuctionDownloader::MimeType mime_type,
    scoped_refptr<AuctionV8Helper> v8_helper,
    scoped_refptr<AuctionV8Helper::DebugId> debug_id,
    std::unique_ptr<std::string> body,
    std::optional<std::string> error_msg,
    WorkletLoaderBase::Result::V8Data* out_data,
    scoped_refptr<base::SequencedTaskRunner> user_thread_task_runner,
    base::WeakPtr<WorkletLoaderBase> weak_instance) {}

// static
bool WorkletLoaderBase::CompileJs(const std::string& body,
                                  scoped_refptr<AuctionV8Helper> v8_helper,
                                  const GURL& source_url,
                                  AuctionV8Helper::DebugId* debug_id,
                                  std::optional<std::string>& error_msg,
                                  WorkletLoaderBase::Result::V8Data* out_data) {}

// static
bool WorkletLoaderBase::CompileWasm(
    const std::string& body,
    scoped_refptr<AuctionV8Helper> v8_helper,
    const GURL& source_url,
    AuctionV8Helper::DebugId* debug_id,
    std::optional<std::string>& error_msg,
    WorkletLoaderBase::Result::V8Data* out_data) {}

void WorkletLoaderBase::DeliverCallbackOnUserThread(
    bool success,
    std::optional<std::string> error_msg,
    bool download_success) {}

WorkletLoader::WorkletLoader(
    network::mojom::URLLoaderFactory* url_loader_factory,
    mojo::PendingRemote<auction_worklet::mojom::AuctionNetworkEventsHandler>
        auction_network_events_handler,
    const GURL& source_url,
    std::vector<scoped_refptr<AuctionV8Helper>> v8_helpers,
    std::vector<scoped_refptr<AuctionV8Helper::DebugId>> debug_ids,
    AllowTrustedScoringSignalsCallback allow_trusted_scoring_signals_callback,
    LoadWorkletCallback load_worklet_callback)
    :{}

WorkletLoader::~WorkletLoader() = default;

// static
v8::Global<v8::UnboundScript> WorkletLoader::TakeScript(Result&& result) {}

// static
std::vector<url::Origin>
WorkletLoader::ParseAllowTrustedScoringSignalsFromHeader(
    const std::string& allow_trusted_scoring_signals_from_header) {}

void WorkletLoader::OnResponseStarted(
    const network::mojom::URLResponseHead& head) {}

WorkletWasmLoader::WorkletWasmLoader(
    network::mojom::URLLoaderFactory* url_loader_factory,
    mojo::PendingRemote<auction_worklet::mojom::AuctionNetworkEventsHandler>
        auction_network_events_handler,
    const GURL& source_url,
    std::vector<scoped_refptr<AuctionV8Helper>> v8_helpers,
    std::vector<scoped_refptr<AuctionV8Helper::DebugId>> debug_ids,
    LoadWorkletCallback load_worklet_callback)
    :{}

// static
v8::MaybeLocal<v8::WasmModuleObject> WorkletWasmLoader::MakeModule(
    const Result& result) {}

}  // namespace auction_worklet