diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/glean-core/src/lib.rs | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/glean-core/src/lib.rs')
-rw-r--r-- | third_party/rust/glean-core/src/lib.rs | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/third_party/rust/glean-core/src/lib.rs b/third_party/rust/glean-core/src/lib.rs index af68fde264..c79fa1e226 100644 --- a/third_party/rust/glean-core/src/lib.rs +++ b/third_party/rust/glean-core/src/lib.rs @@ -28,7 +28,7 @@ use log::LevelFilter; use once_cell::sync::{Lazy, OnceCell}; use uuid::Uuid; -use metrics::MetricsEnabledConfig; +use metrics::RemoteSettingsConfig; mod common_metric_data; mod core; @@ -68,9 +68,9 @@ pub use crate::metrics::labeled::{ pub use crate::metrics::{ BooleanMetric, CounterMetric, CustomDistributionMetric, Datetime, DatetimeMetric, DenominatorMetric, DistributionData, EventMetric, MemoryDistributionMetric, MemoryUnit, - NumeratorMetric, PingType, QuantityMetric, Rate, RateMetric, RecordedEvent, RecordedExperiment, - StringListMetric, StringMetric, TextMetric, TimeUnit, TimerId, TimespanMetric, - TimingDistributionMetric, UrlMetric, UuidMetric, + NumeratorMetric, ObjectMetric, PingType, QuantityMetric, Rate, RateMetric, RecordedEvent, + RecordedExperiment, StringListMetric, StringMetric, TextMetric, TimeUnit, TimerId, + TimespanMetric, TimingDistributionMetric, UrlMetric, UuidMetric, }; pub use crate::upload::{PingRequest, PingUploadTask, UploadResult, UploadTaskAction}; @@ -693,7 +693,7 @@ pub fn shutdown() { /// Only has effect when Glean is configured with `delay_ping_lifetime_io: true`. /// If Glean hasn't been initialized this will dispatch and return Ok(()), /// otherwise it will block until the persist is done and return its Result. -pub fn persist_ping_lifetime_data() { +pub fn glean_persist_ping_lifetime_data() { // This is async, we can't get the Error back to the caller. crate::launch_with_glean(|glean| { let _ = glean.persist_ping_lifetime_data(); @@ -910,17 +910,17 @@ pub fn glean_test_get_experimentation_id() -> Option<String> { /// Sets a remote configuration to override metrics' default enabled/disabled /// state /// -/// See [`core::Glean::set_metrics_enabled_config`]. -pub fn glean_set_metrics_enabled_config(json: String) { +/// See [`core::Glean::apply_server_knobs_config`]. +pub fn glean_apply_server_knobs_config(json: String) { // An empty config means it is not set, // so we avoid logging an error about it. if json.is_empty() { return; } - match MetricsEnabledConfig::try_from(json) { + match RemoteSettingsConfig::try_from(json) { Ok(cfg) => launch_with_glean(|glean| { - glean.set_metrics_enabled_config(cfg); + glean.apply_server_knobs_config(cfg); }), Err(e) => { log::error!("Error setting metrics feature config: {:?}", e); @@ -1125,8 +1125,14 @@ pub fn glean_test_destroy_glean(clear_stores: bool, data_path: Option<String>) { // Only useful if Glean initialization finished successfully // and set up the storage. - let has_storage = - core::with_opt_glean(|glean| glean.storage_opt().is_some()).unwrap_or(false); + let has_storage = core::with_opt_glean(|glean| { + // We need to flush the ping lifetime data before a full shutdown. + glean + .storage_opt() + .map(|storage| storage.persist_ping_lifetime_data()) + .is_some() + }) + .unwrap_or(false); if has_storage { uploader_shutdown(); } @@ -1229,6 +1235,20 @@ mod ffi { obj.into_owned() } } + + type JsonValue = serde_json::Value; + + impl UniffiCustomTypeConverter for JsonValue { + type Builtin = String; + + fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> { + Ok(serde_json::from_str(&val)?) + } + + fn from_custom(obj: Self) -> Self::Builtin { + serde_json::to_string(&obj).unwrap() + } + } } pub use ffi::*; |