com.hubspot.chrome.devtools.client.core.audits.Audits Maven / Gradle / Ivy
package com.hubspot.chrome.devtools.client.core.audits;
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 com.hubspot.chrome.devtools.client.core.network.RequestId;
import java.util.concurrent.CompletableFuture;
/**
* Audits domain allows investigation of page violations and possible improvements.
*/
public final class Audits {
ChromeSessionCore chromeSession;
ObjectMapper objectMapper;
public Audits(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
this.chromeSession = chromeSession;
this.objectMapper = objectMapper;
}
/**
* Returns the response body and size if it were re-encoded with the specified settings. Only
* applies to images.
*
* @param requestId Identifier of the network request to get content for.
* @param encoding The encoding to use.
* @param quality [Optional] The quality of the encoding (0-1). (defaults to 1)
* @param sizeOnly [Optional] Whether to only return the size information (defaults to false).
*/
public GetEncodedResponseResult getEncodedResponse(RequestId requestId, String encoding,
Number quality, Boolean sizeOnly) {
ChromeRequest chromeRequest = new ChromeRequest("Audits.getEncodedResponse");
chromeRequest
.putParams("requestId", requestId)
.putParams("encoding", encoding)
.putParams("quality", quality)
.putParams("sizeOnly", sizeOnly);
return chromeSession.send(chromeRequest, new TypeReference(){});
}
/**
* Returns the response body and size if it were re-encoded with the specified settings. Only
* applies to images.
*
* @param requestId Identifier of the network request to get content for.
* @param encoding The encoding to use.
* @param quality [Optional] The quality of the encoding (0-1). (defaults to 1)
* @param sizeOnly [Optional] Whether to only return the size information (defaults to false).
*/
public CompletableFuture getEncodedResponseAsync(RequestId requestId,
String encoding, Number quality, Boolean sizeOnly) {
ChromeRequest chromeRequest = new ChromeRequest("Audits.getEncodedResponse");
chromeRequest
.putParams("requestId", requestId)
.putParams("encoding", encoding)
.putParams("quality", quality)
.putParams("sizeOnly", sizeOnly);
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
}