browser_protocol/backgroundservice/
mod.rs1use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
10pub enum ServiceName {
11 #[default]
12 BackgroundFetch,
13 BackgroundSync,
14 PushMessaging,
15 Notifications,
16 PaymentHandler,
17 PeriodicBackgroundSync,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize, Default)]
23#[serde(rename_all = "camelCase")]
24pub struct EventMetadata {
25
26 pub key: String,
27
28 pub value: String,
29}
30
31
32#[derive(Debug, Clone, Serialize, Deserialize, Default)]
33#[serde(rename_all = "camelCase")]
34pub struct BackgroundServiceEvent {
35 pub timestamp: crate::network::TimeSinceEpoch,
38 pub origin: String,
41 pub serviceWorkerRegistrationId: crate::serviceworker::RegistrationID,
44 pub service: ServiceName,
47 pub eventName: String,
50 pub instanceId: String,
53 pub eventMetadata: Vec<EventMetadata>,
56 pub storageKey: String,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize, Default)]
64#[serde(rename_all = "camelCase")]
65pub struct StartObservingParams {
66
67 pub service: ServiceName,
68}
69
70impl StartObservingParams { pub const METHOD: &'static str = "BackgroundService.startObserving"; }
71
72impl crate::CdpCommand for StartObservingParams {
73 const METHOD: &'static str = "BackgroundService.startObserving";
74 type Response = crate::EmptyReturns;
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, Default)]
80#[serde(rename_all = "camelCase")]
81pub struct StopObservingParams {
82
83 pub service: ServiceName,
84}
85
86impl StopObservingParams { pub const METHOD: &'static str = "BackgroundService.stopObserving"; }
87
88impl crate::CdpCommand for StopObservingParams {
89 const METHOD: &'static str = "BackgroundService.stopObserving";
90 type Response = crate::EmptyReturns;
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize, Default)]
96#[serde(rename_all = "camelCase")]
97pub struct SetRecordingParams {
98
99 pub shouldRecord: bool,
100
101 pub service: ServiceName,
102}
103
104impl SetRecordingParams { pub const METHOD: &'static str = "BackgroundService.setRecording"; }
105
106impl crate::CdpCommand for SetRecordingParams {
107 const METHOD: &'static str = "BackgroundService.setRecording";
108 type Response = crate::EmptyReturns;
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize, Default)]
114#[serde(rename_all = "camelCase")]
115pub struct ClearEventsParams {
116
117 pub service: ServiceName,
118}
119
120impl ClearEventsParams { pub const METHOD: &'static str = "BackgroundService.clearEvents"; }
121
122impl crate::CdpCommand for ClearEventsParams {
123 const METHOD: &'static str = "BackgroundService.clearEvents";
124 type Response = crate::EmptyReturns;
125}