Skip to content

Truly independent web browser

1.1 KB
Raw Blame
/*
 * Copyright (c) 2026-present, the Ladybird developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/NonnullRefPtr.h>
#include <LibWeb/Export.h>
#include <LibWeb/Fetch/Engine/EngineCommandSink.h>
#include <LibWeb/Fetch/Engine/FetchEngineRecord.h>
#include <LibWeb/Fetch/Engine/FetchExecutor.h>
#include <LibWeb/Fetch/Engine/NetworkActivityObservers.h>

namespace Web::Fetch::Fetching {

// Handles the commands posted for the fetches of the agent on whose thread it runs.
class FetchEngine final : public Engine::EngineCommandSink {
public:
    FetchEngine(NonnullRefPtr<Engine::NetworkActivityObservers const>, NonnullOwnPtr<Engine::FetchEngineRecords::Agent>);

    virtual void handle_command(Engine::EngineCommand) override;

private:
    NonnullRefPtr<Engine::NetworkActivityObservers const> m_network_activity_observers;
    Engine::FetchEngineRecords m_records;
};

// Creates an executor that runs a fetch engine on the current thread's event loop.
WEB_API NonnullRefPtr<Engine::FetchExecutor> create_inline_fetch_executor(NonnullRefPtr<Engine::NetworkActivityObservers const>);

}