"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.


https://chromedevtools.github.io/devtools-protocol/tot/Memory/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    Memory,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class GetDOMCountersOutput(OutputModel):

    documents: int
    nodes: int
    jsEventListeners: int


class GetDOMCounters(CDPMethod[GetDOMCountersOutput]):
    """ Retruns current DOM object counters. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetDOMCountersOutput


class GetDOMCountersForLeakDetectionOutput(OutputModel):

    counters: list[Memory.DOMCounter]


class GetDOMCountersForLeakDetection(CDPMethod[GetDOMCountersForLeakDetectionOutput]):
    """ Retruns DOM object counters after preparing renderer for leak detection. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetDOMCountersForLeakDetectionOutput


class PrepareForLeakDetection(CDPMethod[None]):
    """ Prepares for leak detection by terminating workers, stopping spellcheckers,
    dropping non-essential internal caches, running garbage collections, etc. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class ForciblyPurgeJavaScriptMemory(CDPMethod[None]):
    """ Simulate OomIntervention by purging V8 memory. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class SetPressureNotificationsSuppressedInput(InputModel):

    suppressed: bool


class SetPressureNotificationsSuppressed(CDPMethod[None]):
    """ Enable/disable suppressing memory pressure notifications in all processes. """

    INPUT_VALIDATOR = SetPressureNotificationsSuppressedInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        suppressed: bool
    ):
        super().__init__(
            suppressed=suppressed
        )


class SimulatePressureNotificationInput(InputModel):

    level: Memory.PressureLevel


class SimulatePressureNotification(CDPMethod[None]):
    """ Simulate a memory pressure notification in all processes. """

    INPUT_VALIDATOR = SimulatePressureNotificationInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        level: Memory.PressureLevel
    ):
        super().__init__(
            level=level
        )


class StartSamplingInput(InputModel):

    samplingInterval: int | None = None
    suppressRandomness: bool | None = None


class StartSampling(CDPMethod[None]):
    """ Start collecting native memory profile. """

    INPUT_VALIDATOR = StartSamplingInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        sampling_interval: int | None = None,
        suppress_randomness: bool | None = None
    ):
        super().__init__(
            samplingInterval=sampling_interval,
            suppressRandomness=suppress_randomness
        )


class StopSampling(CDPMethod[None]):
    """ Stop collecting native memory profile. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class GetAllTimeSamplingProfileOutput(OutputModel):

    profile: Memory.SamplingProfile


class GetAllTimeSamplingProfile(CDPMethod[GetAllTimeSamplingProfileOutput]):
    """ Retrieve native memory allocations profile
    collected since renderer process startup. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetAllTimeSamplingProfileOutput


class GetBrowserSamplingProfileOutput(OutputModel):

    profile: Memory.SamplingProfile


class GetBrowserSamplingProfile(CDPMethod[GetBrowserSamplingProfileOutput]):
    """ Retrieve native memory allocations profile
    collected since browser process startup. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetBrowserSamplingProfileOutput


class GetSamplingProfileOutput(OutputModel):

    profile: Memory.SamplingProfile


class GetSamplingProfile(CDPMethod[GetSamplingProfileOutput]):
    """ Retrieve native memory allocations profile collected since last
    `startSampling` call. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetSamplingProfileOutput
