com.hubspot.chrome.devtools.client.core.memory.Memory Maven / Gradle / Ivy
package com.hubspot.chrome.devtools.client.core.memory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.chrome.devtools.base.ChromeRequest;
import com.hubspot.chrome.devtools.base.ChromeSessionCore;
import java.util.concurrent.CompletableFuture;
public final class Memory {
ChromeSessionCore chromeSession;
ObjectMapper objectMapper;
public Memory(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
this.chromeSession = chromeSession;
this.objectMapper = objectMapper;
}
public GetDOMCountersResult getDOMCounters() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getDOMCounters");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
public CompletableFuture getDOMCountersAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getDOMCounters");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
public void prepareForLeakDetection() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.prepareForLeakDetection");
chromeSession.send(chromeRequest);
}
public void prepareForLeakDetectionAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.prepareForLeakDetection");
chromeSession.sendAsync(chromeRequest);
}
/**
* Enable/disable suppressing memory pressure notifications in all processes.
*
* @param suppressed If true, memory pressure notifications will be suppressed.
*/
public void setPressureNotificationsSuppressed(Boolean suppressed) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.setPressureNotificationsSuppressed");
chromeRequest
.putParams("suppressed", suppressed);
chromeSession.send(chromeRequest);
}
/**
* Enable/disable suppressing memory pressure notifications in all processes.
*
* @param suppressed If true, memory pressure notifications will be suppressed.
*/
public void setPressureNotificationsSuppressedAsync(Boolean suppressed) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.setPressureNotificationsSuppressed");
chromeRequest
.putParams("suppressed", suppressed);
chromeSession.sendAsync(chromeRequest);
}
/**
* Simulate a memory pressure notification in all processes.
*
* @param level Memory pressure level of the notification.
*/
public void simulatePressureNotification(PressureLevel level) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.simulatePressureNotification");
chromeRequest
.putParams("level", level);
chromeSession.send(chromeRequest);
}
/**
* Simulate a memory pressure notification in all processes.
*
* @param level Memory pressure level of the notification.
*/
public void simulatePressureNotificationAsync(PressureLevel level) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.simulatePressureNotification");
chromeRequest
.putParams("level", level);
chromeSession.sendAsync(chromeRequest);
}
/**
* Start collecting native memory profile.
*
* @param samplingInterval [Optional] Average number of bytes between samples.
* @param suppressRandomness [Optional] Do not randomize intervals between samples.
*/
public void startSampling(Integer samplingInterval, Boolean suppressRandomness) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.startSampling");
chromeRequest
.putParams("samplingInterval", samplingInterval)
.putParams("suppressRandomness", suppressRandomness);
chromeSession.send(chromeRequest);
}
/**
* Start collecting native memory profile.
*
* @param samplingInterval [Optional] Average number of bytes between samples.
* @param suppressRandomness [Optional] Do not randomize intervals between samples.
*/
public void startSamplingAsync(Integer samplingInterval, Boolean suppressRandomness) {
ChromeRequest chromeRequest = new ChromeRequest("Memory.startSampling");
chromeRequest
.putParams("samplingInterval", samplingInterval)
.putParams("suppressRandomness", suppressRandomness);
chromeSession.sendAsync(chromeRequest);
}
/**
* Stop collecting native memory profile.
*/
public void stopSampling() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.stopSampling");
chromeSession.send(chromeRequest);
}
/**
* Stop collecting native memory profile.
*/
public void stopSamplingAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.stopSampling");
chromeSession.sendAsync(chromeRequest);
}
/**
* Retrieve native memory allocations profile
* collected since renderer process startup.
*/
public SamplingProfile getAllTimeSamplingProfile() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getAllTimeSamplingProfile");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
/**
* Retrieve native memory allocations profile
* collected since renderer process startup.
*/
public CompletableFuture getAllTimeSamplingProfileAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getAllTimeSamplingProfile");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
/**
* Retrieve native memory allocations profile
* collected since browser process startup.
*/
public SamplingProfile getBrowserSamplingProfile() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getBrowserSamplingProfile");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
/**
* Retrieve native memory allocations profile
* collected since browser process startup.
*/
public CompletableFuture getBrowserSamplingProfileAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getBrowserSamplingProfile");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
/**
* Retrieve native memory allocations profile collected since last
* `startSampling` call.
*/
public SamplingProfile getSamplingProfile() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getSamplingProfile");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
/**
* Retrieve native memory allocations profile collected since last
* `startSampling` call.
*/
public CompletableFuture getSamplingProfileAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Memory.getSamplingProfile");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
}