chromedp/cdp/serviceworker/serviceworker.go
2017-01-24 22:09:23 +07:00

565 lines
9.9 KiB
Go

// Package serviceworker provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome ServiceWorker domain.
//
// Generated by the chromedp-gen command.
package serviceworker
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EnableParams struct{}
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes ServiceWorker.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type DisableParams struct{}
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes ServiceWorker.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type UnregisterParams struct {
ScopeURL string `json:"scopeURL"`
}
// parameters:
// scopeURL
func Unregister(scopeURL string) *UnregisterParams {
return &UnregisterParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.unregister.
func (p *UnregisterParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerUnregister, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type UpdateRegistrationParams struct {
ScopeURL string `json:"scopeURL"`
}
// parameters:
// scopeURL
func UpdateRegistration(scopeURL string) *UpdateRegistrationParams {
return &UpdateRegistrationParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.updateRegistration.
func (p *UpdateRegistrationParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerUpdateRegistration, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StartWorkerParams struct {
ScopeURL string `json:"scopeURL"`
}
// parameters:
// scopeURL
func StartWorker(scopeURL string) *StartWorkerParams {
return &StartWorkerParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.startWorker.
func (p *StartWorkerParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerStartWorker, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type SkipWaitingParams struct {
ScopeURL string `json:"scopeURL"`
}
// parameters:
// scopeURL
func SkipWaiting(scopeURL string) *SkipWaitingParams {
return &SkipWaitingParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.skipWaiting.
func (p *SkipWaitingParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerSkipWaiting, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StopWorkerParams struct {
VersionID string `json:"versionId"`
}
// parameters:
// versionId
func StopWorker(versionId string) *StopWorkerParams {
return &StopWorkerParams{
VersionID: versionId,
}
}
// Do executes ServiceWorker.stopWorker.
func (p *StopWorkerParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerStopWorker, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type InspectWorkerParams struct {
VersionID string `json:"versionId"`
}
// parameters:
// versionId
func InspectWorker(versionId string) *InspectWorkerParams {
return &InspectWorkerParams{
VersionID: versionId,
}
}
// Do executes ServiceWorker.inspectWorker.
func (p *InspectWorkerParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerInspectWorker, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type SetForceUpdateOnPageLoadParams struct {
ForceUpdateOnPageLoad bool `json:"forceUpdateOnPageLoad"`
}
// parameters:
// forceUpdateOnPageLoad
func SetForceUpdateOnPageLoad(forceUpdateOnPageLoad bool) *SetForceUpdateOnPageLoadParams {
return &SetForceUpdateOnPageLoadParams{
ForceUpdateOnPageLoad: forceUpdateOnPageLoad,
}
}
// Do executes ServiceWorker.setForceUpdateOnPageLoad.
func (p *SetForceUpdateOnPageLoadParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerSetForceUpdateOnPageLoad, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type DeliverPushMessageParams struct {
Origin string `json:"origin"`
RegistrationID string `json:"registrationId"`
Data string `json:"data"`
}
// parameters:
// origin
// registrationId
// data
func DeliverPushMessage(origin string, registrationId string, data string) *DeliverPushMessageParams {
return &DeliverPushMessageParams{
Origin: origin,
RegistrationID: registrationId,
Data: data,
}
}
// Do executes ServiceWorker.deliverPushMessage.
func (p *DeliverPushMessageParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerDeliverPushMessage, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type DispatchSyncEventParams struct {
Origin string `json:"origin"`
RegistrationID string `json:"registrationId"`
Tag string `json:"tag"`
LastChance bool `json:"lastChance"`
}
// parameters:
// origin
// registrationId
// tag
// lastChance
func DispatchSyncEvent(origin string, registrationId string, tag string, lastChance bool) *DispatchSyncEventParams {
return &DispatchSyncEventParams{
Origin: origin,
RegistrationID: registrationId,
Tag: tag,
LastChance: lastChance,
}
}
// Do executes ServiceWorker.dispatchSyncEvent.
func (p *DispatchSyncEventParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandServiceWorkerDispatchSyncEvent, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}