chromedp/cdp/schema/schema.go
2017-01-26 14:28:34 +07:00

71 lines
1.4 KiB
Go

// Package schema provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Schema domain.
//
// Provides information about the protocol schema.
//
// Generated by the chromedp-gen command.
package schema
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
// GetDomainsParams returns supported domains.
type GetDomainsParams struct{}
// GetDomains returns supported domains.
func GetDomains() *GetDomainsParams {
return &GetDomainsParams{}
}
// GetDomainsReturns return values.
type GetDomainsReturns struct {
Domains []*Domain `json:"domains,omitempty"` // List of supported domains.
}
// Do executes Schema.getDomains.
//
// returns:
// domains - List of supported domains.
func (p *GetDomainsParams) Do(ctxt context.Context, h cdp.FrameHandler) (domains []*Domain, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, cdp.CommandSchemaGetDomains, 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 GetDomainsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, cdp.ErrInvalidResult
}
return r.Domains, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, cdp.ErrContextDone
}
return nil, cdp.ErrUnknownResult
}