chromedp/cdp/profiler/profiler.go

240 lines
4.5 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// Package profiler provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Profiler domain.
//
// Generated by the chromedp-gen command.
package profiler
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
2017-01-26 07:28:34 +00:00
cdp "github.com/knq/chromedp/cdp"
2017-01-24 15:09:23 +00:00
"github.com/mailru/easyjson"
)
2017-01-26 07:28:34 +00:00
// EnableParams [no description].
2017-01-24 15:09:23 +00:00
type EnableParams struct{}
2017-01-26 07:28:34 +00:00
// Enable [no description].
2017-01-24 15:09:23 +00:00
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Profiler.enable.
2017-01-26 07:28:34 +00:00
func (p *EnableParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandProfilerEnable, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
// DisableParams [no description].
2017-01-24 15:09:23 +00:00
type DisableParams struct{}
2017-01-26 07:28:34 +00:00
// Disable [no description].
2017-01-24 15:09:23 +00:00
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Profiler.disable.
2017-01-26 07:28:34 +00:00
func (p *DisableParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandProfilerDisable, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *SetSamplingIntervalParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandProfilerSetSamplingInterval, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
// StartParams [no description].
2017-01-24 15:09:23 +00:00
type StartParams struct{}
2017-01-26 07:28:34 +00:00
// Start [no description].
2017-01-24 15:09:23 +00:00
func Start() *StartParams {
return &StartParams{}
}
// Do executes Profiler.start.
2017-01-26 07:28:34 +00:00
func (p *StartParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandProfilerStart, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
// StopParams [no description].
2017-01-24 15:09:23 +00:00
type StopParams struct{}
2017-01-26 07:28:34 +00:00
// Stop [no description].
2017-01-24 15:09:23 +00:00
func Stop() *StopParams {
return &StopParams{}
}
// StopReturns return values.
type StopReturns struct {
Profile *Profile `json:"profile,omitempty"` // Recorded profile.
}
// Do executes Profiler.stop.
//
// returns:
// profile - Recorded profile.
2017-01-26 07:28:34 +00:00
func (p *StopParams) Do(ctxt context.Context, h cdp.FrameHandler) (profile *Profile, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandProfilerStop, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r StopReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.Profile, nil
case error:
return nil, v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}