-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public abstract class PrivacyManager implements AutoCloseable
-
-
Field Summary
Fields Modifier and Type Field Description private final ConcurrentHashMap<PrivacyAgent, PrivacyContext>permanentContextsprivate final ConcurrentHashMap<PrivacyAgent, PrivacyContext>temporaryContextsprivate final Map<PrivacyAgent, PrivacyContext>activeContextsprivate final ConcurrentLinkedDeque<PrivacyContext>zombieContextsprivate final ObjectcontextLifeCycleMonitorprivate final PrivacyContextIdGeneratorprivacyContextIdGeneratorprivate final BooleanisClosedprivate final BooleanisActiveprivate final ImmutableConfigconf
-
Constructor Summary
Constructors Constructor Description PrivacyManager(ImmutableConfig conf)
-
Method Summary
Modifier and Type Method Description final ConcurrentHashMap<PrivacyAgent, PrivacyContext>getPermanentContexts()final ConcurrentHashMap<PrivacyAgent, PrivacyContext>getTemporaryContexts()NOTE: we can use a priority queue and every time we need a context, take the top one final Map<PrivacyAgent, PrivacyContext>getActiveContexts()final ConcurrentLinkedDeque<PrivacyContext>getZombieContexts()final ObjectgetContextLifeCycleMonitor()PrivacyContextIdGeneratorgetPrivacyContextIdGenerator()final BooleangetIsClosed()final BooleangetIsActive()final ImmutableConfiggetConf()abstract FetchResultrun(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun)Run a task in a privacy context. abstract PrivacyContextcomputeNextContext(Fingerprint fingerprint)Create a new context or return an existing one. abstract PrivacyContextcomputeNextContext(WebPage page, Fingerprint fingerprint, FetchTask task)Create a new context or return an existing one. abstract PrivacyContextcomputeIfNecessary(Fingerprint fingerprint)Create a new context or return an existing one abstract PrivacyContextcomputeIfNecessary(WebPage page, Fingerprint fingerprint, FetchTask task)Create a new context or return an existing one abstract PrivacyContextcomputeIfAbsent(PrivacyAgent privacyAgent)Create a context with privacyAgent and add it to active context list if not absent abstract PrivacyContextcreateUnmanagedContext(PrivacyAgent privacyAgent)Create a context and do not add to active context list StringtakeSnapshot()Unitclose(PrivacyContext privacyContext)Close a given privacy context, remove it from the active list and add it to the zombie list. Unitclose()Closing call stack:PrivacyManager.close -> PrivacyContext.close -> WebDriverContext.close -> WebDriverPoolManager.close -> BrowserManager.close -> Browser.close -> WebDriver.close |-> LoadingWebDriverPool. Unitmaintain()-
-
Method Detail
-
getPermanentContexts
final ConcurrentHashMap<PrivacyAgent, PrivacyContext> getPermanentContexts()
-
getTemporaryContexts
final ConcurrentHashMap<PrivacyAgent, PrivacyContext> getTemporaryContexts()
NOTE: we can use a priority queue and every time we need a context, take the top one
-
getActiveContexts
final Map<PrivacyAgent, PrivacyContext> getActiveContexts()
-
getZombieContexts
final ConcurrentLinkedDeque<PrivacyContext> getZombieContexts()
-
getContextLifeCycleMonitor
final Object getContextLifeCycleMonitor()
-
getPrivacyContextIdGenerator
PrivacyContextIdGenerator getPrivacyContextIdGenerator()
-
getIsClosed
final Boolean getIsClosed()
-
getIsActive
final Boolean getIsActive()
-
getConf
final ImmutableConfig getConf()
-
run
abstract FetchResult run(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun)
Run a task in 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 privacy context chosen is not ready to serve, especially, it has no any ready web driver, the task will be canceled.
- Parameters:
task- the fetch taskfetchFun- the fetch function
-
computeNextContext
@Deprecated(message = Use computeNextContext(task, fingerprint), replaceWith = @ReplaceWith(imports = {}, expression = computeNextContext(FetchTask, Fingerprint))) abstract PrivacyContext computeNextContext(Fingerprint fingerprint)Create a new context or return an existing one.
-
computeNextContext
abstract PrivacyContext computeNextContext(WebPage page, Fingerprint fingerprint, FetchTask task)
Create a new context or return an existing one.
-
computeIfNecessary
@Deprecated(message = Use computeIfNecessary(task, fingerprint), replaceWith = @ReplaceWith(imports = {}, expression = computeIfNecessary(FetchTask, Fingerprint))) abstract PrivacyContext computeIfNecessary(Fingerprint fingerprint)Create a new context or return an existing one
-
computeIfNecessary
abstract PrivacyContext computeIfNecessary(WebPage page, Fingerprint fingerprint, FetchTask task)
Create a new context or return an existing one
-
computeIfAbsent
abstract PrivacyContext computeIfAbsent(PrivacyAgent privacyAgent)
Create a context with privacyAgent and add it to active context list if not absent
-
createUnmanagedContext
abstract PrivacyContext createUnmanagedContext(PrivacyAgent privacyAgent)
Create a context and do not add to active context list
-
takeSnapshot
String takeSnapshot()
-
close
Unit close(PrivacyContext privacyContext)
Close a given privacy context, remove it from the active list and add it to the zombie list. No exception.
-
close
Unit close()
Closing call stack:
PrivacyManager.close -> PrivacyContext.close -> WebDriverContext.close -> WebDriverPoolManager.close -> BrowserManager.close -> Browser.close -> WebDriver.close |-> LoadingWebDriverPool.close
-
maintain
Unit maintain()
-
-
-
-