Skip to main content

cdp_driver/protocol/
memory.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `Memory` domain.
5//!
6//! Types, command parameters and event payloads for the `Memory`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9//!
10//! This domain is experimental and may change without notice.
11
12use serde::{Deserialize, Serialize};
13
14/// Memory pressure level.
15#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
16pub enum PressureLevel {
17    /// `moderate`
18    #[serde(rename = "moderate")]
19    Moderate,
20    /// `critical`
21    #[serde(rename = "critical")]
22    Critical,
23    /// A value this vendored schema does not list. Chrome adds values ahead of
24    /// the published protocol, so an unrecognised one is kept as it arrived
25    /// rather than failing the payload it came in.
26    #[serde(untagged)]
27    Unrecognized(String),
28}
29
30/// Heap profile sample.
31#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
32pub struct SamplingProfileNode {
33    /// Size of the sampled allocation.
34    pub size: f64,
35    /// Total bytes attributed to this sample.
36    pub total: f64,
37    /// Execution stack at the point of allocation.
38    pub stack: Vec<String>,
39}
40
41/// Array of heap profile samples.
42#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
43pub struct SamplingProfile {
44    pub samples: Vec<SamplingProfileNode>,
45    pub modules: Vec<Module>,
46}
47
48/// Executable module information
49#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
50pub struct Module {
51    /// Name of the module.
52    pub name: String,
53    /// UUID of the module.
54    pub uuid: String,
55    /// Base address where the module is loaded into memory. Encoded as a decimal
56    /// or hexadecimal (0x prefixed) string.
57    #[serde(rename = "baseAddress")]
58    pub base_address: String,
59    /// Size of the module in bytes.
60    pub size: f64,
61}
62
63/// DOM object counter data.
64#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
65pub struct DomCounter {
66    /// Object name. Note: object names should be presumed volatile and clients
67    /// should not expect the returned names to be consistent across runs.
68    pub name: String,
69    /// Object count.
70    pub count: i64,
71}
72
73/// Retruns current DOM object counters.
74///
75/// Parameters of `Memory.getDOMCounters`.
76#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
77pub struct GetDomCountersParams {}
78
79/// What `Memory.getDOMCounters` answers with.
80#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
81pub struct GetDomCountersReturns {
82    pub documents: i64,
83    pub nodes: i64,
84    #[serde(rename = "jsEventListeners")]
85    pub js_event_listeners: i64,
86}
87
88impl crate::typed::Command for GetDomCountersParams {
89    const METHOD: &'static str = "Memory.getDOMCounters";
90    type Returns = GetDomCountersReturns;
91}
92
93/// Retruns DOM object counters after preparing renderer for leak detection.
94///
95/// Parameters of `Memory.getDOMCountersForLeakDetection`.
96#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
97pub struct GetDomCountersForLeakDetectionParams {}
98
99/// What `Memory.getDOMCountersForLeakDetection` answers with.
100#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
101pub struct GetDomCountersForLeakDetectionReturns {
102    /// DOM object counters.
103    pub counters: Vec<DomCounter>,
104}
105
106impl crate::typed::Command for GetDomCountersForLeakDetectionParams {
107    const METHOD: &'static str = "Memory.getDOMCountersForLeakDetection";
108    type Returns = GetDomCountersForLeakDetectionReturns;
109}
110
111/// Prepares for leak detection by terminating workers, stopping
112/// spellcheckers, dropping non-essential internal caches, running garbage
113/// collections, etc.
114///
115/// Parameters of `Memory.prepareForLeakDetection`.
116#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
117pub struct PrepareForLeakDetectionParams {}
118
119impl crate::typed::Command for PrepareForLeakDetectionParams {
120    const METHOD: &'static str = "Memory.prepareForLeakDetection";
121    type Returns = crate::typed::NoReturns;
122}
123
124/// Simulate OomIntervention by purging V8 memory.
125///
126/// Parameters of `Memory.forciblyPurgeJavaScriptMemory`.
127#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
128pub struct ForciblyPurgeJavaScriptMemoryParams {}
129
130impl crate::typed::Command for ForciblyPurgeJavaScriptMemoryParams {
131    const METHOD: &'static str = "Memory.forciblyPurgeJavaScriptMemory";
132    type Returns = crate::typed::NoReturns;
133}
134
135/// Enable/disable suppressing memory pressure notifications in all processes.
136///
137/// Parameters of `Memory.setPressureNotificationsSuppressed`.
138#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
139pub struct SetPressureNotificationsSuppressedParams {
140    /// If true, memory pressure notifications will be suppressed.
141    pub suppressed: bool,
142}
143
144impl crate::typed::Command for SetPressureNotificationsSuppressedParams {
145    const METHOD: &'static str = "Memory.setPressureNotificationsSuppressed";
146    type Returns = crate::typed::NoReturns;
147}
148
149/// Simulate a memory pressure notification in all processes.
150///
151/// Parameters of `Memory.simulatePressureNotification`.
152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
153pub struct SimulatePressureNotificationParams {
154    /// Memory pressure level of the notification.
155    pub level: PressureLevel,
156}
157
158impl crate::typed::Command for SimulatePressureNotificationParams {
159    const METHOD: &'static str = "Memory.simulatePressureNotification";
160    type Returns = crate::typed::NoReturns;
161}
162
163/// Start collecting native memory profile.
164///
165/// Parameters of `Memory.startSampling`.
166#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
167pub struct StartSamplingParams {
168    /// Average number of bytes between samples.
169    #[serde(
170        rename = "samplingInterval",
171        default,
172        skip_serializing_if = "Option::is_none"
173    )]
174    pub sampling_interval: Option<i64>,
175    /// Do not randomize intervals between samples.
176    #[serde(
177        rename = "suppressRandomness",
178        default,
179        skip_serializing_if = "Option::is_none"
180    )]
181    pub suppress_randomness: Option<bool>,
182}
183
184impl crate::typed::Command for StartSamplingParams {
185    const METHOD: &'static str = "Memory.startSampling";
186    type Returns = crate::typed::NoReturns;
187}
188
189/// Stop collecting native memory profile.
190///
191/// Parameters of `Memory.stopSampling`.
192#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
193pub struct StopSamplingParams {}
194
195impl crate::typed::Command for StopSamplingParams {
196    const METHOD: &'static str = "Memory.stopSampling";
197    type Returns = crate::typed::NoReturns;
198}
199
200/// Retrieve native memory allocations profile collected since renderer
201/// process startup.
202///
203/// Parameters of `Memory.getAllTimeSamplingProfile`.
204#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
205pub struct GetAllTimeSamplingProfileParams {}
206
207/// What `Memory.getAllTimeSamplingProfile` answers with.
208#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
209pub struct GetAllTimeSamplingProfileReturns {
210    pub profile: SamplingProfile,
211}
212
213impl crate::typed::Command for GetAllTimeSamplingProfileParams {
214    const METHOD: &'static str = "Memory.getAllTimeSamplingProfile";
215    type Returns = GetAllTimeSamplingProfileReturns;
216}
217
218/// Retrieve native memory allocations profile collected since browser process
219/// startup.
220///
221/// Parameters of `Memory.getBrowserSamplingProfile`.
222#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
223pub struct GetBrowserSamplingProfileParams {}
224
225/// What `Memory.getBrowserSamplingProfile` answers with.
226#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
227pub struct GetBrowserSamplingProfileReturns {
228    pub profile: SamplingProfile,
229}
230
231impl crate::typed::Command for GetBrowserSamplingProfileParams {
232    const METHOD: &'static str = "Memory.getBrowserSamplingProfile";
233    type Returns = GetBrowserSamplingProfileReturns;
234}
235
236/// Retrieve native memory allocations profile collected since last
237/// `startSampling` call.
238///
239/// Parameters of `Memory.getSamplingProfile`.
240#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
241pub struct GetSamplingProfileParams {}
242
243/// What `Memory.getSamplingProfile` answers with.
244#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
245pub struct GetSamplingProfileReturns {
246    pub profile: SamplingProfile,
247}
248
249impl crate::typed::Command for GetSamplingProfileParams {
250    const METHOD: &'static str = "Memory.getSamplingProfile";
251    type Returns = GetSamplingProfileReturns;
252}