Interface PrivacyManager

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public interface PrivacyManager
     implements AutoCloseable
                        

    Manages the lifecycle of privacy contexts, including permanent and temporary contexts. Permanent contexts have a long lifecycle and are never deleted, while temporary contexts are short-lived and discarded if a privacy leak is detected.

    • Constructor Detail

    • Method Detail

      • buildStatusString

         abstract String buildStatusString()

        Builds a status string summarizing the current state of active contexts.

        Returns:

        A string representation of the active contexts' status.

      • maintain

         abstract Unit maintain(Boolean force)

        Performs maintenance tasks on the privacy manager.

        Parameters:
        force - If true, forces maintenance tasks to run.
      • reset

         abstract Unit reset(String reason)

        Resets the privacy environment by closing all privacy contexts.

        Parameters:
        reason - The reason for resetting the privacy environment.
      • run

         abstract FetchResult run(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun)

        Runs a fetch task within a privacy context.

        The privacy context is selected from the active privacy context pool, and it is supposed to have at least one ready web driver to run the task. If the chosen context is not ready to serve, the task will be canceled.

        Parameters:
        task - The fetch task to execute.
        fetchFun - The function to execute the fetch task.
        Returns:

        The result of the fetch task.

      • tryGetNextReadyPrivacyContext

         abstract PrivacyContext tryGetNextReadyPrivacyContext(WebPage page, Fingerprint fingerprint, FetchTask task)

        Attempts to get the next ready privacy context for a given page, fingerprint, and task.

        Parameters:
        page - The web page associated with the context.
        fingerprint - The fingerprint used to identify the context.
        task - The fetch task associated with the context.
        Returns:

        The next ready privacy context.

      • tryGetNextReadyPrivacyContext

         abstract PrivacyContext tryGetNextReadyPrivacyContext(Fingerprint fingerprint)

        Attempts to get the next ready privacy context for a given fingerprint.

        Parameters:
        fingerprint - The fingerprint used to identify the context.
        Returns:

        The next ready privacy context.

      • tryGetNextUnderLoadedPrivacyContext

         abstract PrivacyContext tryGetNextUnderLoadedPrivacyContext(WebPage page, Fingerprint fingerprint, FetchTask task)

        Attempts to get the next under-loaded privacy context for a given page, fingerprint, and task.

        Parameters:
        page - The web page associated with the context.
        fingerprint - The fingerprint used to identify the context.
        task - The fetch task associated with the context.
        Returns:

        The next under-loaded privacy context, or null if none is available.

      • getOrCreate

         abstract PrivacyContext getOrCreate(PrivacyAgent privacyAgent)

        Gets or creates a privacy context for the given privacy agent.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        Returns:

        The privacy context.

      • createUnmanagedContext

         abstract PrivacyContext createUnmanagedContext(PrivacyAgent privacyAgent)

        Creates an unmanaged privacy context for the given privacy agent.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        Returns:

        The unmanaged privacy context.

      • createUnmanagedContext

         abstract PrivacyContext createUnmanagedContext(PrivacyAgent privacyAgent, WebDriverFetcher fetcher)

        Creates an unmanaged privacy context for the given privacy agent and fetcher.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        fetcher - The web driver fetcher used to create the context.
        Returns:

        The unmanaged privacy context.

      • close

         abstract Unit close(PrivacyContext privacyContext)

        Closes a given privacy context, moving it from the active list to the zombie list.

        Parameters:
        privacyContext - The privacy context to close.
      • isActive

         abstract Boolean isActive()

        Indicates whether the privacy manager is active.

      • isClosed

         abstract Boolean isClosed()

        Indicates whether the privacy manager is closed.

      • getConf

         abstract ImmutableConfig getConf()

        The immutable configuration used by the privacy manager.