chromedp/cdp/domstorage/domstorage.go

331 lines
6.3 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// Package domstorage provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome DOMStorage domain.
//
// Query and modify DOM storage.
//
// Generated by the chromedp-gen command.
package domstorage
// 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"
)
// EnableParams enables storage tracking, storage events will now be
// delivered to the client.
type EnableParams struct{}
// Enable enables storage tracking, storage events will now be delivered to
// the client.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes DOMStorage.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.CommandDOMStorageEnable, 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
}
// DisableParams disables storage tracking, prevents storage events from
// being sent to the client.
type DisableParams struct{}
// Disable disables storage tracking, prevents storage events from being sent
// to the client.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes DOMStorage.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.CommandDOMStorageDisable, 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
// ClearParams [no description].
2017-01-24 15:09:23 +00:00
type ClearParams struct {
StorageID *StorageID `json:"storageId"`
}
2017-01-26 07:28:34 +00:00
// Clear [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// storageID
func Clear(storageID *StorageID) *ClearParams {
2017-01-24 15:09:23 +00:00
return &ClearParams{
2017-01-26 07:28:34 +00:00
StorageID: storageID,
2017-01-24 15:09:23 +00:00
}
}
// Do executes DOMStorage.clear.
2017-01-26 07:28:34 +00:00
func (p *ClearParams) 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.CommandDOMStorageClear, 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
// GetDOMStorageItemsParams [no description].
2017-01-24 15:09:23 +00:00
type GetDOMStorageItemsParams struct {
StorageID *StorageID `json:"storageId"`
}
2017-01-26 07:28:34 +00:00
// GetDOMStorageItems [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// storageID
func GetDOMStorageItems(storageID *StorageID) *GetDOMStorageItemsParams {
2017-01-24 15:09:23 +00:00
return &GetDOMStorageItemsParams{
2017-01-26 07:28:34 +00:00
StorageID: storageID,
2017-01-24 15:09:23 +00:00
}
}
// GetDOMStorageItemsReturns return values.
type GetDOMStorageItemsReturns struct {
Entries []Item `json:"entries,omitempty"`
}
// Do executes DOMStorage.getDOMStorageItems.
//
// returns:
// entries
2017-01-26 07:28:34 +00:00
func (p *GetDOMStorageItemsParams) Do(ctxt context.Context, h cdp.FrameHandler) (entries []Item, 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 nil, err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMStorageGetDOMStorageItems, 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 nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetDOMStorageItemsReturns
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.Entries, 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
}
2017-01-26 07:28:34 +00:00
// SetDOMStorageItemParams [no description].
2017-01-24 15:09:23 +00:00
type SetDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
Value string `json:"value"`
}
2017-01-26 07:28:34 +00:00
// SetDOMStorageItem [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// storageID
2017-01-24 15:09:23 +00:00
// key
// value
2017-01-26 07:28:34 +00:00
func SetDOMStorageItem(storageID *StorageID, key string, value string) *SetDOMStorageItemParams {
2017-01-24 15:09:23 +00:00
return &SetDOMStorageItemParams{
2017-01-26 07:28:34 +00:00
StorageID: storageID,
2017-01-24 15:09:23 +00:00
Key: key,
Value: value,
}
}
// Do executes DOMStorage.setDOMStorageItem.
2017-01-26 07:28:34 +00:00
func (p *SetDOMStorageItemParams) 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.CommandDOMStorageSetDOMStorageItem, 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
// RemoveDOMStorageItemParams [no description].
2017-01-24 15:09:23 +00:00
type RemoveDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
}
2017-01-26 07:28:34 +00:00
// RemoveDOMStorageItem [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// storageID
2017-01-24 15:09:23 +00:00
// key
2017-01-26 07:28:34 +00:00
func RemoveDOMStorageItem(storageID *StorageID, key string) *RemoveDOMStorageItemParams {
2017-01-24 15:09:23 +00:00
return &RemoveDOMStorageItemParams{
2017-01-26 07:28:34 +00:00
StorageID: storageID,
2017-01-24 15:09:23 +00:00
Key: key,
}
}
// Do executes DOMStorage.removeDOMStorageItem.
2017-01-26 07:28:34 +00:00
func (p *RemoveDOMStorageItemParams) 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.CommandDOMStorageRemoveDOMStorageItem, 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
}