/
types.go
95 lines (82 loc) · 3.62 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package backgroundservice
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"fmt"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/serviceworker"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// ServiceName the Background Service that will be associated with the
// commands/events. Every Background Service operates independently, but they
// share the same API.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#type-ServiceName
type ServiceName string
// String returns the ServiceName as string value.
func (t ServiceName) String() string {
return string(t)
}
// ServiceName values.
const (
ServiceNameBackgroundFetch ServiceName = "backgroundFetch"
ServiceNameBackgroundSync ServiceName = "backgroundSync"
ServiceNamePushMessaging ServiceName = "pushMessaging"
ServiceNameNotifications ServiceName = "notifications"
ServiceNamePaymentHandler ServiceName = "paymentHandler"
ServiceNamePeriodicBackgroundSync ServiceName = "periodicBackgroundSync"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ServiceName) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ServiceName) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ServiceName) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch ServiceName(v) {
case ServiceNameBackgroundFetch:
*t = ServiceNameBackgroundFetch
case ServiceNameBackgroundSync:
*t = ServiceNameBackgroundSync
case ServiceNamePushMessaging:
*t = ServiceNamePushMessaging
case ServiceNameNotifications:
*t = ServiceNameNotifications
case ServiceNamePaymentHandler:
*t = ServiceNamePaymentHandler
case ServiceNamePeriodicBackgroundSync:
*t = ServiceNamePeriodicBackgroundSync
default:
in.AddError(fmt.Errorf("unknown ServiceName value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ServiceName) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// EventMetadata a key-value pair for additional event information to pass
// along.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#type-EventMetadata
type EventMetadata struct {
Key string `json:"key"`
Value string `json:"value"`
}
// Event [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#type-BackgroundServiceEvent
type Event struct {
Timestamp *cdp.TimeSinceEpoch `json:"timestamp"` // Timestamp of the event (in seconds).
Origin string `json:"origin"` // The origin this event belongs to.
ServiceWorkerRegistrationID serviceworker.RegistrationID `json:"serviceWorkerRegistrationId"` // The Service Worker ID that initiated the event.
Service ServiceName `json:"service"` // The Background Service this event belongs to.
EventName string `json:"eventName"` // A description of the event.
InstanceID string `json:"instanceId"` // An identifier that groups related events together.
EventMetadata []*EventMetadata `json:"eventMetadata"` // A list of event-specific information.
StorageKey string `json:"storageKey"` // Storage key this event belongs to.
}