/*
 * SPDX-FileCopyrightText: Copyright 2025 Open Mobile Platform LLC <community@omp.ru>
 * SPDX-License-Identifier: Proprietary
 */

#pragma once

#include <QObject>

class QQmlEngine;
class QJSEngine;

namespace Cef {
class BrowserApp;
}

namespace Aurora {
namespace WebView {

/**
 * @class MemoryPressureHandler
 * @brief To provide notifications on system memory pressure conditions.
 *
 */
class MemoryPressureHandler : public QObject
{
    Q_OBJECT
public:
    /// @brief default destructor
    ~MemoryPressureHandler();

    /// @brief creates (if doesn't exist) and returns an instance of MemoryPressureHandler
    /// @return MemoryPressureHandler instance
    static QSharedPointer<MemoryPressureHandler> GetInstance(
        QQmlEngine *qmlEngine = nullptr, QJSEngine *jsEngine = nullptr);

    /// @brief Notifies in case of moderate or critical system memory pressure
    ///        conditions.
    /// @param isCritical reflects whether a system memory pressure is moderate or critical
    void notifyMemoryPressure(bool isCritical);

signals:
    /// @brief emitted on detected system memory pressure conditions
    /// @param isCritical reflects whether a system memory pressure is moderate or critical
    void memoryPressure(bool isCritical);

private:
    MemoryPressureHandler();
};

} // namespace WebView
} // namespace Aurora
