#include "content/services/auction_worklet/auction_worklet_service_impl.h"
#include <memory>
#include <string>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
#include "base/synchronization/waitable_event.h"
#include "content/common/features.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/bidder_worklet.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom-forward.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom.h"
#include "content/services/auction_worklet/seller_worklet.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom.h"
namespace auction_worklet {
namespace {
static size_t g_next_seller_worklet_thread_index = …;
}
class AuctionWorkletServiceImpl::V8HelperHolder
: public base::RefCounted<V8HelperHolder> { … };
std::vector<AuctionWorkletServiceImpl::V8HelperHolder*>*
AuctionWorkletServiceImpl::V8HelperHolder::g_bidder_instances = …;
std::vector<AuctionWorkletServiceImpl::V8HelperHolder*>*
AuctionWorkletServiceImpl::V8HelperHolder::g_seller_instances = …;
void AuctionWorkletServiceImpl::CreateForRenderer(
mojo::PendingReceiver<mojom::AuctionWorkletService> receiver) { … }
std::unique_ptr<AuctionWorkletServiceImpl>
AuctionWorkletServiceImpl::CreateForService(
mojo::PendingReceiver<mojom::AuctionWorkletService> receiver) { … }
AuctionWorkletServiceImpl::AuctionWorkletServiceImpl(
ProcessModel process_model,
mojo::PendingReceiver<mojom::AuctionWorkletService> receiver)
: … { … }
AuctionWorkletServiceImpl::~AuctionWorkletServiceImpl() = default;
std::vector<scoped_refptr<AuctionV8Helper>>
AuctionWorkletServiceImpl::AuctionV8HelpersForTesting() { … }
void AuctionWorkletServiceImpl::LoadBidderWorklet(
mojo::PendingReceiver<mojom::BidderWorklet> bidder_worklet_receiver,
std::vector<mojo::PendingRemote<mojom::AuctionSharedStorageHost>>
shared_storage_hosts,
bool pause_for_debugger_on_start,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
pending_url_loader_factory,
mojo::PendingRemote<auction_worklet::mojom::AuctionNetworkEventsHandler>
auction_network_events_handler,
const GURL& script_source_url,
const std::optional<GURL>& wasm_helper_url,
const std::optional<GURL>& trusted_bidding_signals_url,
const std::string& trusted_bidding_signals_slot_size_param,
const url::Origin& top_window_origin,
mojom::AuctionWorkletPermissionsPolicyStatePtr permissions_policy_state,
std::optional<uint16_t> experiment_group_id,
mojom::TrustedSignalsPublicKeyPtr public_key) { … }
void AuctionWorkletServiceImpl::LoadSellerWorklet(
mojo::PendingReceiver<mojom::SellerWorklet> seller_worklet_receiver,
std::vector<mojo::PendingRemote<mojom::AuctionSharedStorageHost>>
shared_storage_hosts,
bool pause_for_debugger_on_start,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
pending_url_loader_factory,
mojo::PendingRemote<auction_worklet::mojom::AuctionNetworkEventsHandler>
auction_network_events_handler,
const GURL& decision_logic_url,
const std::optional<GURL>& trusted_scoring_signals_url,
const url::Origin& top_window_origin,
mojom::AuctionWorkletPermissionsPolicyStatePtr permissions_policy_state,
std::optional<uint16_t> experiment_group_id) { … }
size_t AuctionWorkletServiceImpl::GetNextSellerWorkletThreadIndex() { … }
void AuctionWorkletServiceImpl::DisconnectSellerWorklet(
mojo::ReceiverId receiver_id,
const std::string& reason) { … }
void AuctionWorkletServiceImpl::DisconnectBidderWorklet(
mojo::ReceiverId receiver_id,
const std::string& reason) { … }
}