pl.wendigo.chrome.domain.performance.PerformanceDomain.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chrome-reactive-kotlin Show documentation
Show all versions of chrome-reactive-kotlin Show documentation
Chrome Reactive - low level, remote chrome debugger protocol client (DevTools)
package pl.wendigo.chrome.domain.performance
/**
* PerformanceDomain represents remote debugger protocol domain.
*/
class PerformanceDomain internal constructor(private val connectionRemote : pl.wendigo.chrome.DebuggerProtocol) {
/**
* Enable collecting and reporting metrics.
*/
fun enable() : io.reactivex.Single {
return connectionRemote.runAndCaptureResponse("Performance.enable", null, pl.wendigo.chrome.ResponseFrame::class.java).map {
it.value()
}
}
/**
* Disable collecting and reporting metrics.
*/
fun disable() : io.reactivex.Single {
return connectionRemote.runAndCaptureResponse("Performance.disable", null, pl.wendigo.chrome.ResponseFrame::class.java).map {
it.value()
}
}
/**
* Retrieve current values of run-time metrics.
*/
fun getMetrics() : io.reactivex.Single {
return connectionRemote.runAndCaptureResponse("Performance.getMetrics", null, GetMetricsResponse::class.java).map {
it.value()
}
}
/**
* Current values of the metrics.
*/
fun metrics() : io.reactivex.Flowable {
return metricsTimed().map {
it.value()
}
}
/**
* Current values of the metrics.
*/
fun metricsTimed() : io.reactivex.Flowable> {
return connectionRemote.captureEvents("Performance.metrics", MetricsEvent::class.java)
}
/**
* Returns flowable capturing all Performance domains events.
*/
fun events() : io.reactivex.Flowable {
return connectionRemote.captureAllEvents().map { it.value() }.filter {
it.protocolDomain() == "Performance"
}
}
}
/**
* Represents response frame for Performance.getMetrics method call.
*
* Retrieve current values of run-time metrics.
*/
data class GetMetricsResponse(
/**
* Current values for run-time metrics.
*/
val metrics : List
)
/**
* Represents event frames for Performance.metrics
*
* Current values of the metrics.
*/
data class MetricsEvent(
/**
* Current values of the metrics.
*/
val metrics : List,
/**
* Timestamp title.
*/
val title : String
) : pl.wendigo.chrome.ProtocolEvent(domain = "Performance", name = "metrics")