chromedp/cdp/serviceworker/serviceworker.go

576 lines
11 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// 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"
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 ServiceWorker.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.CommandServiceWorkerEnable, 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 ServiceWorker.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.CommandServiceWorkerDisable, 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
// UnregisterParams [no description].
2017-01-24 15:09:23 +00:00
type UnregisterParams struct {
ScopeURL string `json:"scopeURL"`
}
2017-01-26 07:28:34 +00:00
// Unregister [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// scopeURL
func Unregister(scopeURL string) *UnregisterParams {
return &UnregisterParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.unregister.
2017-01-26 07:28:34 +00:00
func (p *UnregisterParams) 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.CommandServiceWorkerUnregister, 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
// UpdateRegistrationParams [no description].
2017-01-24 15:09:23 +00:00
type UpdateRegistrationParams struct {
ScopeURL string `json:"scopeURL"`
}
2017-01-26 07:28:34 +00:00
// UpdateRegistration [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// scopeURL
func UpdateRegistration(scopeURL string) *UpdateRegistrationParams {
return &UpdateRegistrationParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.updateRegistration.
2017-01-26 07:28:34 +00:00
func (p *UpdateRegistrationParams) 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.CommandServiceWorkerUpdateRegistration, 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
// StartWorkerParams [no description].
2017-01-24 15:09:23 +00:00
type StartWorkerParams struct {
ScopeURL string `json:"scopeURL"`
}
2017-01-26 07:28:34 +00:00
// StartWorker [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// scopeURL
func StartWorker(scopeURL string) *StartWorkerParams {
return &StartWorkerParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.startWorker.
2017-01-26 07:28:34 +00:00
func (p *StartWorkerParams) 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.CommandServiceWorkerStartWorker, 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
// SkipWaitingParams [no description].
2017-01-24 15:09:23 +00:00
type SkipWaitingParams struct {
ScopeURL string `json:"scopeURL"`
}
2017-01-26 07:28:34 +00:00
// SkipWaiting [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// scopeURL
func SkipWaiting(scopeURL string) *SkipWaitingParams {
return &SkipWaitingParams{
ScopeURL: scopeURL,
}
}
// Do executes ServiceWorker.skipWaiting.
2017-01-26 07:28:34 +00:00
func (p *SkipWaitingParams) 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.CommandServiceWorkerSkipWaiting, 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
// StopWorkerParams [no description].
2017-01-24 15:09:23 +00:00
type StopWorkerParams struct {
VersionID string `json:"versionId"`
}
2017-01-26 07:28:34 +00:00
// StopWorker [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// versionID
func StopWorker(versionID string) *StopWorkerParams {
2017-01-24 15:09:23 +00:00
return &StopWorkerParams{
2017-01-26 07:28:34 +00:00
VersionID: versionID,
2017-01-24 15:09:23 +00:00
}
}
// Do executes ServiceWorker.stopWorker.
2017-01-26 07:28:34 +00:00
func (p *StopWorkerParams) 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.CommandServiceWorkerStopWorker, 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
// InspectWorkerParams [no description].
2017-01-24 15:09:23 +00:00
type InspectWorkerParams struct {
VersionID string `json:"versionId"`
}
2017-01-26 07:28:34 +00:00
// InspectWorker [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// versionID
func InspectWorker(versionID string) *InspectWorkerParams {
2017-01-24 15:09:23 +00:00
return &InspectWorkerParams{
2017-01-26 07:28:34 +00:00
VersionID: versionID,
2017-01-24 15:09:23 +00:00
}
}
// Do executes ServiceWorker.inspectWorker.
2017-01-26 07:28:34 +00:00
func (p *InspectWorkerParams) 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.CommandServiceWorkerInspectWorker, 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
// SetForceUpdateOnPageLoadParams [no description].
2017-01-24 15:09:23 +00:00
type SetForceUpdateOnPageLoadParams struct {
ForceUpdateOnPageLoad bool `json:"forceUpdateOnPageLoad"`
}
2017-01-26 07:28:34 +00:00
// SetForceUpdateOnPageLoad [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// forceUpdateOnPageLoad
func SetForceUpdateOnPageLoad(forceUpdateOnPageLoad bool) *SetForceUpdateOnPageLoadParams {
return &SetForceUpdateOnPageLoadParams{
ForceUpdateOnPageLoad: forceUpdateOnPageLoad,
}
}
// Do executes ServiceWorker.setForceUpdateOnPageLoad.
2017-01-26 07:28:34 +00:00
func (p *SetForceUpdateOnPageLoadParams) 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.CommandServiceWorkerSetForceUpdateOnPageLoad, 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
// DeliverPushMessageParams [no description].
2017-01-24 15:09:23 +00:00
type DeliverPushMessageParams struct {
Origin string `json:"origin"`
RegistrationID string `json:"registrationId"`
Data string `json:"data"`
}
2017-01-26 07:28:34 +00:00
// DeliverPushMessage [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// origin
2017-01-26 07:28:34 +00:00
// registrationID
2017-01-24 15:09:23 +00:00
// data
2017-01-26 07:28:34 +00:00
func DeliverPushMessage(origin string, registrationID string, data string) *DeliverPushMessageParams {
2017-01-24 15:09:23 +00:00
return &DeliverPushMessageParams{
Origin: origin,
2017-01-26 07:28:34 +00:00
RegistrationID: registrationID,
2017-01-24 15:09:23 +00:00
Data: data,
}
}
// Do executes ServiceWorker.deliverPushMessage.
2017-01-26 07:28:34 +00:00
func (p *DeliverPushMessageParams) 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.CommandServiceWorkerDeliverPushMessage, 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
// DispatchSyncEventParams [no description].
2017-01-24 15:09:23 +00:00
type DispatchSyncEventParams struct {
Origin string `json:"origin"`
RegistrationID string `json:"registrationId"`
Tag string `json:"tag"`
LastChance bool `json:"lastChance"`
}
2017-01-26 07:28:34 +00:00
// DispatchSyncEvent [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
// origin
2017-01-26 07:28:34 +00:00
// registrationID
2017-01-24 15:09:23 +00:00
// tag
// lastChance
2017-01-26 07:28:34 +00:00
func DispatchSyncEvent(origin string, registrationID string, tag string, lastChance bool) *DispatchSyncEventParams {
2017-01-24 15:09:23 +00:00
return &DispatchSyncEventParams{
Origin: origin,
2017-01-26 07:28:34 +00:00
RegistrationID: registrationID,
2017-01-24 15:09:23 +00:00
Tag: tag,
LastChance: lastChance,
}
}
// Do executes ServiceWorker.dispatchSyncEvent.
2017-01-26 07:28:34 +00:00
func (p *DispatchSyncEventParams) 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.CommandServiceWorkerDispatchSyncEvent, 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
}