2017-01-24 15:09:23 +00:00
|
|
|
// Package memory provides the Chrome Debugging Protocol
|
2017-02-12 04:59:33 +00:00
|
|
|
// commands, types, and events for the Memory domain.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// Generated by the chromedp-gen command.
|
|
|
|
package memory
|
|
|
|
|
|
|
|
// 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
|
|
|
// GetDOMCountersParams [no description].
|
2017-01-24 15:09:23 +00:00
|
|
|
type GetDOMCountersParams struct{}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
// GetDOMCounters [no description].
|
2017-01-24 15:09:23 +00:00
|
|
|
func GetDOMCounters() *GetDOMCountersParams {
|
|
|
|
return &GetDOMCountersParams{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetDOMCountersReturns return values.
|
|
|
|
type GetDOMCountersReturns struct {
|
|
|
|
Documents int64 `json:"documents,omitempty"`
|
|
|
|
Nodes int64 `json:"nodes,omitempty"`
|
|
|
|
JsEventListeners int64 `json:"jsEventListeners,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Memory.getDOMCounters against the provided context and
|
|
|
|
// target handler.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// documents
|
|
|
|
// nodes
|
|
|
|
// jsEventListeners
|
2017-02-12 04:59:33 +00:00
|
|
|
func (p *GetDOMCountersParams) Do(ctxt context.Context, h cdp.Handler) (documents int64, nodes int64, jsEventListeners int64, 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.CommandMemoryGetDOMCounters, 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 0, 0, 0, cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
// unmarshal
|
|
|
|
var r GetDOMCountersReturns
|
|
|
|
err = easyjson.Unmarshal(v, &r)
|
|
|
|
if err != nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return 0, 0, 0, cdp.ErrInvalidResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r.Documents, r.Nodes, r.JsEventListeners, nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return 0, 0, 0, v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return 0, 0, 0, ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return 0, 0, 0, cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetPressureNotificationsSuppressedParams enable/disable suppressing memory
|
|
|
|
// pressure notifications in all processes.
|
|
|
|
type SetPressureNotificationsSuppressedParams struct {
|
|
|
|
Suppressed bool `json:"suppressed"` // If true, memory pressure notifications will be suppressed.
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPressureNotificationsSuppressed enable/disable suppressing memory
|
|
|
|
// pressure notifications in all processes.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// suppressed - If true, memory pressure notifications will be suppressed.
|
|
|
|
func SetPressureNotificationsSuppressed(suppressed bool) *SetPressureNotificationsSuppressedParams {
|
|
|
|
return &SetPressureNotificationsSuppressedParams{
|
|
|
|
Suppressed: suppressed,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Memory.setPressureNotificationsSuppressed against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *SetPressureNotificationsSuppressedParams) Do(ctxt context.Context, h cdp.Handler) (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.CommandMemorySetPressureNotificationsSuppressed, 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-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// SimulatePressureNotificationParams simulate a memory pressure notification
|
|
|
|
// in all processes.
|
|
|
|
type SimulatePressureNotificationParams struct {
|
|
|
|
Level PressureLevel `json:"level"` // Memory pressure level of the notification.
|
|
|
|
}
|
|
|
|
|
|
|
|
// SimulatePressureNotification simulate a memory pressure notification in
|
|
|
|
// all processes.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// level - Memory pressure level of the notification.
|
|
|
|
func SimulatePressureNotification(level PressureLevel) *SimulatePressureNotificationParams {
|
|
|
|
return &SimulatePressureNotificationParams{
|
|
|
|
Level: level,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Memory.simulatePressureNotification against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *SimulatePressureNotificationParams) Do(ctxt context.Context, h cdp.Handler) (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.CommandMemorySimulatePressureNotification, 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-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
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
|
|
|
}
|