Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-06-23 09:00:24 +07:00
parent 4cc4ba1ca2
commit 3d87ff99bf
4 changed files with 194 additions and 24 deletions

View File

@ -17,7 +17,86 @@ var (
_ easyjson.Marshaler _ easyjson.Marshaler
) )
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(in *jlexer.Lexer, out *GetUsageAndQuotaReturns) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(in *jlexer.Lexer, out *UsageForType) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "storageType":
(out.StorageType).UnmarshalEasyJSON(in)
case "usage":
out.Usage = float64(in.Float64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(out *jwriter.Writer, in UsageForType) {
out.RawByte('{')
first := true
_ = first
if in.StorageType != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"storageType\":")
(in.StorageType).MarshalEasyJSON(out)
}
if in.Usage != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"usage\":")
out.Float64(float64(in.Usage))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v UsageForType) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v UsageForType) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *UsageForType) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *UsageForType) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(in *jlexer.Lexer, out *GetUsageAndQuotaReturns) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -40,6 +119,37 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(in *jlexer.Lexer, out
out.Usage = float64(in.Float64()) out.Usage = float64(in.Float64())
case "quota": case "quota":
out.Quota = float64(in.Float64()) out.Quota = float64(in.Float64())
case "usageBreakdown":
if in.IsNull() {
in.Skip()
out.UsageBreakdown = nil
} else {
in.Delim('[')
if out.UsageBreakdown == nil {
if !in.IsDelim(']') {
out.UsageBreakdown = make([]*UsageForType, 0, 8)
} else {
out.UsageBreakdown = []*UsageForType{}
}
} else {
out.UsageBreakdown = (out.UsageBreakdown)[:0]
}
for !in.IsDelim(']') {
var v1 *UsageForType
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(UsageForType)
}
(*v1).UnmarshalEasyJSON(in)
}
out.UsageBreakdown = append(out.UsageBreakdown, v1)
in.WantComma()
}
in.Delim(']')
}
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -50,7 +160,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(in *jlexer.Lexer, out
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(out *jwriter.Writer, in GetUsageAndQuotaReturns) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(out *jwriter.Writer, in GetUsageAndQuotaReturns) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -70,33 +180,56 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(out *jwriter.Writer, i
out.RawString("\"quota\":") out.RawString("\"quota\":")
out.Float64(float64(in.Quota)) out.Float64(float64(in.Quota))
} }
if len(in.UsageBreakdown) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"usageBreakdown\":")
if in.UsageBreakdown == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.UsageBreakdown {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
out.RawByte('}') out.RawByte('}')
} }
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v GetUsageAndQuotaReturns) MarshalJSON() ([]byte, error) { func (v GetUsageAndQuotaReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(&w, v)
return w.Buffer.BuildBytes(), w.Error return w.Buffer.BuildBytes(), w.Error
} }
// MarshalEasyJSON supports easyjson.Marshaler interface // MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetUsageAndQuotaReturns) MarshalEasyJSON(w *jwriter.Writer) { func (v GetUsageAndQuotaReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *GetUsageAndQuotaReturns) UnmarshalJSON(data []byte) error { func (v *GetUsageAndQuotaReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetUsageAndQuotaReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *GetUsageAndQuotaReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(in *jlexer.Lexer, out *GetUsageAndQuotaParams) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(in *jlexer.Lexer, out *GetUsageAndQuotaParams) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -127,7 +260,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(in *jlexer.Lexer, out
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(out *jwriter.Writer, in GetUsageAndQuotaParams) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(out *jwriter.Writer, in GetUsageAndQuotaParams) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -143,27 +276,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(out *jwriter.Writer,
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v GetUsageAndQuotaParams) MarshalJSON() ([]byte, error) { func (v GetUsageAndQuotaParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(&w, v)
return w.Buffer.BuildBytes(), w.Error return w.Buffer.BuildBytes(), w.Error
} }
// MarshalEasyJSON supports easyjson.Marshaler interface // MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetUsageAndQuotaParams) MarshalEasyJSON(w *jwriter.Writer) { func (v GetUsageAndQuotaParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage1(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *GetUsageAndQuotaParams) UnmarshalJSON(data []byte) error { func (v *GetUsageAndQuotaParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetUsageAndQuotaParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *GetUsageAndQuotaParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage1(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(in *jlexer.Lexer, out *ClearDataForOriginParams) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage3(in *jlexer.Lexer, out *ClearDataForOriginParams) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -196,7 +329,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(in *jlexer.Lexer, out
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(out *jwriter.Writer, in ClearDataForOriginParams) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage3(out *jwriter.Writer, in ClearDataForOriginParams) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -218,23 +351,23 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(out *jwriter.Writer,
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v ClearDataForOriginParams) MarshalJSON() ([]byte, error) { func (v ClearDataForOriginParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage3(&w, v)
return w.Buffer.BuildBytes(), w.Error return w.Buffer.BuildBytes(), w.Error
} }
// MarshalEasyJSON supports easyjson.Marshaler interface // MarshalEasyJSON supports easyjson.Marshaler interface
func (v ClearDataForOriginParams) MarshalEasyJSON(w *jwriter.Writer) { func (v ClearDataForOriginParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage2(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpStorage3(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *ClearDataForOriginParams) UnmarshalJSON(data []byte) error { func (v *ClearDataForOriginParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage3(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ClearDataForOriginParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *ClearDataForOriginParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage2(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpStorage3(l, v)
} }

View File

@ -53,8 +53,9 @@ func GetUsageAndQuota(origin string) *GetUsageAndQuotaParams {
// GetUsageAndQuotaReturns return values. // GetUsageAndQuotaReturns return values.
type GetUsageAndQuotaReturns struct { type GetUsageAndQuotaReturns struct {
Usage float64 `json:"usage,omitempty"` // Storage usage (bytes). Usage float64 `json:"usage,omitempty"` // Storage usage (bytes).
Quota float64 `json:"quota,omitempty"` // Storage quota (bytes). Quota float64 `json:"quota,omitempty"` // Storage quota (bytes).
UsageBreakdown []*UsageForType `json:"usageBreakdown,omitempty"` // Storage usage per type (bytes).
} }
// Do executes Storage.getUsageAndQuota against the provided context and // Do executes Storage.getUsageAndQuota against the provided context and
@ -63,13 +64,14 @@ type GetUsageAndQuotaReturns struct {
// returns: // returns:
// usage - Storage usage (bytes). // usage - Storage usage (bytes).
// quota - Storage quota (bytes). // quota - Storage quota (bytes).
func (p *GetUsageAndQuotaParams) Do(ctxt context.Context, h cdp.Handler) (usage float64, quota float64, err error) { // usageBreakdown - Storage usage per type (bytes).
func (p *GetUsageAndQuotaParams) Do(ctxt context.Context, h cdp.Handler) (usage float64, quota float64, usageBreakdown []*UsageForType, err error) {
// execute // execute
var res GetUsageAndQuotaReturns var res GetUsageAndQuotaReturns
err = h.Execute(ctxt, cdp.CommandStorageGetUsageAndQuota, p, &res) err = h.Execute(ctxt, cdp.CommandStorageGetUsageAndQuota, p, &res)
if err != nil { if err != nil {
return 0, 0, err return 0, 0, nil, err
} }
return res.Usage, res.Quota, nil return res.Usage, res.Quota, res.UsageBreakdown, nil
} }

View File

@ -30,6 +30,7 @@ const (
TypeServiceWorkers Type = "service_workers" TypeServiceWorkers Type = "service_workers"
TypeCacheStorage Type = "cache_storage" TypeCacheStorage Type = "cache_storage"
TypeAll Type = "all" TypeAll Type = "all"
TypeOther Type = "other"
) )
// MarshalEasyJSON satisfies easyjson.Marshaler. // MarshalEasyJSON satisfies easyjson.Marshaler.
@ -65,6 +66,8 @@ func (t *Type) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = TypeCacheStorage *t = TypeCacheStorage
case TypeAll: case TypeAll:
*t = TypeAll *t = TypeAll
case TypeOther:
*t = TypeOther
default: default:
in.AddError(errors.New("unknown Type value")) in.AddError(errors.New("unknown Type value"))
@ -75,3 +78,9 @@ func (t *Type) UnmarshalEasyJSON(in *jlexer.Lexer) {
func (t *Type) UnmarshalJSON(buf []byte) error { func (t *Type) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t) return easyjson.Unmarshal(buf, t)
} }
// UsageForType usage for a storage type.
type UsageForType struct {
StorageType Type `json:"storageType,omitempty"` // Name of storage type.
Usage float64 `json:"usage,omitempty"` // Storage usage (bytes).
}

View File

@ -10390,9 +10390,27 @@
"websql", "websql",
"service_workers", "service_workers",
"cache_storage", "cache_storage",
"all" "all",
"other"
], ],
"description": "Enum of possible storage types." "description": "Enum of possible storage types."
},
{
"id": "UsageForType",
"type": "object",
"description": "Usage for a storage type.",
"properties": [
{
"name": "storageType",
"$ref": "StorageType",
"description": "Name of storage type."
},
{
"name": "usage",
"type": "number",
"description": "Storage usage (bytes)."
}
]
} }
], ],
"commands": [ "commands": [
@ -10431,6 +10449,14 @@
"name": "quota", "name": "quota",
"type": "number", "type": "number",
"description": "Storage quota (bytes)." "description": "Storage quota (bytes)."
},
{
"name": "usageBreakdown",
"type": "array",
"items": {
"$ref": "UsageForType"
},
"description": "Storage usage per type (bytes)."
} }
], ],
"description": "Returns usage and quota in bytes." "description": "Returns usage and quota in bytes."