2017-01-24 15:09:23 +00:00
|
|
|
// Package cachestorage provides the Chrome Debugging Protocol
|
|
|
|
// commands, types, and events for the Chrome CacheStorage domain.
|
|
|
|
//
|
|
|
|
// Generated by the chromedp-gen command.
|
|
|
|
package cachestorage
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RequestCacheNamesParams requests cache names.
|
|
|
|
type RequestCacheNamesParams struct {
|
|
|
|
SecurityOrigin string `json:"securityOrigin"` // Security origin.
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestCacheNames requests cache names.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// securityOrigin - Security origin.
|
|
|
|
func RequestCacheNames(securityOrigin string) *RequestCacheNamesParams {
|
|
|
|
return &RequestCacheNamesParams{
|
|
|
|
SecurityOrigin: securityOrigin,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestCacheNamesReturns return values.
|
|
|
|
type RequestCacheNamesReturns struct {
|
|
|
|
Caches []*Cache `json:"caches,omitempty"` // Caches for the security origin.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes CacheStorage.requestCacheNames.
|
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// caches - Caches for the security origin.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *RequestCacheNamesParams) Do(ctxt context.Context, h cdp.FrameHandler) (caches []*Cache, 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.CommandCacheStorageRequestCacheNames, 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 RequestCacheNamesReturns
|
|
|
|
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.Caches, 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
|
|
|
}
|
|
|
|
|
|
|
|
// RequestEntriesParams requests data from cache.
|
|
|
|
type RequestEntriesParams struct {
|
|
|
|
CacheID CacheID `json:"cacheId"` // ID of cache to get entries from.
|
|
|
|
SkipCount int64 `json:"skipCount"` // Number of records to skip.
|
|
|
|
PageSize int64 `json:"pageSize"` // Number of records to fetch.
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestEntries requests data from cache.
|
|
|
|
//
|
|
|
|
// parameters:
|
2017-01-26 07:28:34 +00:00
|
|
|
// cacheID - ID of cache to get entries from.
|
2017-01-24 15:09:23 +00:00
|
|
|
// skipCount - Number of records to skip.
|
|
|
|
// pageSize - Number of records to fetch.
|
2017-01-26 07:28:34 +00:00
|
|
|
func RequestEntries(cacheID CacheID, skipCount int64, pageSize int64) *RequestEntriesParams {
|
2017-01-24 15:09:23 +00:00
|
|
|
return &RequestEntriesParams{
|
2017-01-26 07:28:34 +00:00
|
|
|
CacheID: cacheID,
|
2017-01-24 15:09:23 +00:00
|
|
|
SkipCount: skipCount,
|
|
|
|
PageSize: pageSize,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestEntriesReturns return values.
|
|
|
|
type RequestEntriesReturns struct {
|
|
|
|
CacheDataEntries []*DataEntry `json:"cacheDataEntries,omitempty"` // Array of object store data entries.
|
|
|
|
HasMore bool `json:"hasMore,omitempty"` // If true, there are more entries to fetch in the given range.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes CacheStorage.requestEntries.
|
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// cacheDataEntries - Array of object store data entries.
|
|
|
|
// hasMore - If true, there are more entries to fetch in the given range.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *RequestEntriesParams) Do(ctxt context.Context, h cdp.FrameHandler) (cacheDataEntries []*DataEntry, hasMore bool, 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, false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandCacheStorageRequestEntries, 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, false, cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
// unmarshal
|
|
|
|
var r RequestEntriesReturns
|
|
|
|
err = easyjson.Unmarshal(v, &r)
|
|
|
|
if err != nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, false, cdp.ErrInvalidResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r.CacheDataEntries, r.HasMore, nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return nil, false, v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, false, cdp.ErrContextDone
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, false, cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteCacheParams deletes a cache.
|
|
|
|
type DeleteCacheParams struct {
|
|
|
|
CacheID CacheID `json:"cacheId"` // Id of cache for deletion.
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteCache deletes a cache.
|
|
|
|
//
|
|
|
|
// parameters:
|
2017-01-26 07:28:34 +00:00
|
|
|
// cacheID - Id of cache for deletion.
|
|
|
|
func DeleteCache(cacheID CacheID) *DeleteCacheParams {
|
2017-01-24 15:09:23 +00:00
|
|
|
return &DeleteCacheParams{
|
2017-01-26 07:28:34 +00:00
|
|
|
CacheID: cacheID,
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes CacheStorage.deleteCache.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *DeleteCacheParams) 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.CommandCacheStorageDeleteCache, 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
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteEntryParams deletes a cache entry.
|
|
|
|
type DeleteEntryParams struct {
|
|
|
|
CacheID CacheID `json:"cacheId"` // Id of cache where the entry will be deleted.
|
|
|
|
Request string `json:"request"` // URL spec of the request.
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteEntry deletes a cache entry.
|
|
|
|
//
|
|
|
|
// parameters:
|
2017-01-26 07:28:34 +00:00
|
|
|
// cacheID - Id of cache where the entry will be deleted.
|
2017-01-24 15:09:23 +00:00
|
|
|
// request - URL spec of the request.
|
2017-01-26 07:28:34 +00:00
|
|
|
func DeleteEntry(cacheID CacheID, request string) *DeleteEntryParams {
|
2017-01-24 15:09:23 +00:00
|
|
|
return &DeleteEntryParams{
|
2017-01-26 07:28:34 +00:00
|
|
|
CacheID: cacheID,
|
2017-01-24 15:09:23 +00:00
|
|
|
Request: request,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes CacheStorage.deleteEntry.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *DeleteEntryParams) 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.CommandCacheStorageDeleteEntry, 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
|
|
|
}
|