chromedp/cdp/profiler/profiler.go

245 lines
4.6 KiB
Go

// Package profiler provides the Chrome Debugging Protocol
// commands, types, and events for the Profiler domain.
//
// Generated by the chromedp-gen command.
package profiler
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
// EnableParams [no description].
type EnableParams struct{}
// Enable [no description].
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Profiler.enable against the provided context and
// target handler.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, cdp.CommandProfilerEnable, cdp.Empty)
// read response
select {
case res := <-ch:
if res == nil {
return cdp.ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
}
return cdp.ErrUnknownResult
}
// DisableParams [no description].
type DisableParams struct{}
// Disable [no description].
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Profiler.disable against the provided context and
// target handler.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, cdp.CommandProfilerDisable, cdp.Empty)
// read response
select {
case res := <-ch:
if res == nil {
return cdp.ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
}
return cdp.ErrUnknownResult
}
// SetSamplingIntervalParams changes CPU profiler sampling interval. Must be
// called before CPU profiles recording started.
type SetSamplingIntervalParams struct {
Interval int64 `json:"interval"` // New sampling interval in microseconds.
}
// SetSamplingInterval changes CPU profiler sampling interval. Must be called
// before CPU profiles recording started.
//
// parameters:
// interval - New sampling interval in microseconds.
func SetSamplingInterval(interval int64) *SetSamplingIntervalParams {
return &SetSamplingIntervalParams{
Interval: interval,
}
}
// Do executes Profiler.setSamplingInterval against the provided context and
// target handler.
func (p *SetSamplingIntervalParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, cdp.CommandProfilerSetSamplingInterval, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return cdp.ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
}
return cdp.ErrUnknownResult
}
// StartParams [no description].
type StartParams struct{}
// Start [no description].
func Start() *StartParams {
return &StartParams{}
}
// Do executes Profiler.start against the provided context and
// target handler.
func (p *StartParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, cdp.CommandProfilerStart, cdp.Empty)
// read response
select {
case res := <-ch:
if res == nil {
return cdp.ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
}
return cdp.ErrUnknownResult
}
// StopParams [no description].
type StopParams struct{}
// Stop [no description].
func Stop() *StopParams {
return &StopParams{}
}
// StopReturns return values.
type StopReturns struct {
Profile *Profile `json:"profile,omitempty"` // Recorded profile.
}
// Do executes Profiler.stop against the provided context and
// target handler.
//
// returns:
// profile - Recorded profile.
func (p *StopParams) Do(ctxt context.Context, h cdp.Handler) (profile *Profile, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, cdp.CommandProfilerStop, cdp.Empty)
// read response
select {
case res := <-ch:
if res == nil {
return nil, cdp.ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r StopReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, cdp.ErrInvalidResult
}
return r.Profile, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ctxt.Err()
}
return nil, cdp.ErrUnknownResult
}