All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.wendigo.chrome.domain.performance.PerformanceDomain.kt Maven / Gradle / Ivy

There is a newer version: 0.7.4
Show newest version
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")





© 2015 - 2024 Weber Informatics LLC | Privacy Policy