mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 07:24:47 +00:00
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:
parent
ebfadd018a
commit
a0c9e18a50
@ -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();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user