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
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

//! Generic implementation of product specific functions that are called on child process
//! initialization.

#[cfg(feature = "crash-report")]
pub use crash_report::CrashReportAttributes;
use serde::Deserialize;
use serde::Serialize;

#[derive(Serialize, Deserialize)]
pub struct ProductAttributes {}

impl ProductAttributes {
    #[allow(clippy::new_without_default)]
    pub fn new(
        #[cfg(feature = "crash-report")] _crash_attrs: CrashReportAttributes,
        #[cfg(feature = "process-invariants")] _process_invariants: EmulatorProcessInvariants,
    ) -> Self {
        Self {}
    }
}

pub fn init_child_crash_reporting(_attrs: &ProductAttributes) {
    // Do nothing. Crash reporting is implemented by a specific product.
}

pub fn product_child_setup(_attrs: &ProductAttributes) -> anyhow::Result<()> {
    Ok(())
}

#[cfg(feature = "process-invariants")]
#[derive(Debug, Clone)]
pub struct EmulatorProcessInvariants {}

#[cfg(feature = "process-invariants")]
pub fn init_broker_process_invariants(
    _data_handle: &Option<u64>,
    _data_size: &Option<usize>,
) -> anyhow::Result<EmulatorProcessInvariants> {
    Ok(EmulatorProcessInvariants {})
}