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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
// -*- mode: Rust -*-
// AUTOGENERATED BY glean_parser. DO NOT EDIT.
{# The rendered source is autogenerated, but this
Jinja2 template is not. Please file bugs! #}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::private::Ping;
use once_cell::sync::Lazy;
{% for obj in all_objs['pings'].values() %}
#[allow(non_upper_case_globals)]
/// {{ obj.description|trim | replace('\n', '\n/// ') }}
pub static {{ obj.name|snake_case }}: Lazy<Ping> = Lazy::new(|| {
Ping::new(
"{{ obj.name }}",
{{ obj.include_client_id|rust }},
{{ obj.send_if_empty|rust }},
{{ obj.precise_timestamps|rust }},
{{ obj.include_info_sections|rust }},
{{ obj.enabled|rust }},
{{ obj.schedules_pings|rust }},
{{ obj.reason_codes|rust }},
{{ obj.follows_collection_enabled|rust }},
{{ obj.uploader_capabilities|rust }},
)
});
{% endfor %}
/// Instantiate custom pings once to trigger registration.
///
/// # Arguments
///
/// application_id: If present, limit to only registering custom pings
/// assigned to the identified application.
#[doc(hidden)]
pub fn register_pings(application_id: Option<&str>) {
match application_id {
{% for id, ping_names in ping_names_by_app_id.items() %}
Some("{{id}}") => {
log::info!("Registering pings {{ ping_names|join(', ') }} for {{id}}");
{% for ping_name in ping_names %}
let _ = &*{{ ping_name|snake_case }};
{% endfor %}
},
{% endfor %}
_ => {
{% for obj in all_objs['pings'].values() %}
let _ = &*{{ obj.name|snake_case }};
{% endfor %}
}
}
extern "C" {
fn JOG_MaybeReload();
}
unsafe {
JOG_MaybeReload();
}
}
/// Map from pings to the pings scheduled along with them.
///
#[doc(hidden)]
pub fn ping_schedule() -> std::collections::HashMap<String, Vec<String>> {
std::collections::HashMap::from([
{% for ping, schedule in ping_schedule_reverse_map.items() %}
(
{{ ping|rust }},
{{ schedule|rust }}
),
{% endfor %}
])
}
#[cfg(feature = "with_gecko")]
pub(crate) fn submit_ping_by_id(id: u32, reason: Option<&str>) {
if id & (1 << crate::factory::DYNAMIC_PING_BIT) > 0 {
let map = crate::factory::__jog_metric_maps::PING_MAP
.read()
.expect("Read lock for dynamic ping map was poisoned!");
if let Some(ping) = map.get(&id) {
ping.submit(reason);
} else {
// TODO: instrument this error.
log::error!("Cannot submit unknown dynamic ping {} by id.", id);
}
return;
}
match id {
{% for obj in all_objs['pings'].values() %}
{{ obj.name|ping_id }} => {{ obj.name | snake_case }}.submit(reason),
{% endfor %}
_ => {
// TODO: instrument this error.
log::error!("Cannot submit unknown ping {} by id.", id);
}
}
}
#[cfg(feature = "with_gecko")]
pub(crate) fn set_ping_enabled_by_id(id: u32, enabled: bool) {
if id & (1 << crate::factory::DYNAMIC_PING_BIT) > 0 {
let map = crate::factory::__jog_metric_maps::PING_MAP
.read()
.expect("Read lock for dynamic ping map was poisoned!");
if let Some(ping) = map.get(&id) {
ping.set_enabled(enabled);
} else {
// TODO: instrument this error.
log::error!("Cannot set_enabled on unknown dynamic ping {} by id.", id);
}
return;
}
match id {
{% for obj in all_objs['pings'].values() %}
{{ obj.name|ping_id }} => {{ obj.name | snake_case }}.set_enabled(enabled),
{% endfor %}
_ => {
// TODO: instrument this error.
log::error!("Cannot set_enabled on unknown ping {} by id.", id);
}
}
}
/// Measure the allocation size of all known pings.
#[doc(hidden)]
pub fn fog_ping_alloc_size(ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
use malloc_size_of::MallocSizeOf;
let mut n = 0;
{% for obj in all_objs['pings'].values() %}
n += {{ obj.name|snake_case }}.size_of(ops);
{% endfor %}
n
}
|