Bug 1591564 - Assemble a 'prototype' ping every hour. r=janerik

Differential Revision: https://phabricator.services.mozilla.com/D57106

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris H-C 2020-01-10 16:18:05 +00:00
Родитель 702a2d59a2
Коммит fa1be025f2
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -3,8 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use glean_preview::Configuration;
use glean_preview::metrics::PingType;
use nserror::{nsresult, NS_ERROR_FAILURE, NS_OK};
use nsstring::nsAString;
use std::{thread, time};
use std::io::Error;
use std::thread::JoinHandle;
#[no_mangle]
pub unsafe extern "C" fn fog_init(upload_enabled: bool, data_dir: &nsAString) -> nsresult {
@ -20,5 +24,24 @@ pub unsafe extern "C" fn fog_init(upload_enabled: bool, data_dir: &nsAString) ->
return NS_ERROR_FAILURE
}
// We ignore the returned JoinHandle for the nonce.
// The detached thread will live until this process (the main process) dies.
if prototype_ping_init().is_err() {
return NS_ERROR_FAILURE
}
NS_OK
}
fn prototype_ping_init() -> Result<JoinHandle<()>, Error> {
thread::Builder::new().name("fogotype_ping".to_owned()).spawn(|| {
let prototype_ping = PingType::new("prototype", true, true);
glean_preview::register_ping_type(&prototype_ping);
let an_hour = time::Duration::from_secs(60 * 60);
loop {
thread::sleep(an_hour);
prototype_ping.send();
}
})
}