Bug 1694505 - Add an optional data path override to FOG init r=janerik

Differential Revision: https://phabricator.services.mozilla.com/D106192
This commit is contained in:
Chris H-C 2021-02-24 16:33:58 +00:00
Родитель d079588fd9
Коммит 6932f969a5
4 изменённых файлов: 17 добавлений и 7 удалений

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

@ -34,7 +34,8 @@ void GTest_FOG_ExpectFailure(const char* aMessage) {
TEST(FOG, FogInitDoesntCrash)
{
Preferences::SetInt("telemetry.fog.test.localhost_port", -1);
ASSERT_EQ(NS_OK, fog_init());
const nsCString empty;
ASSERT_EQ(NS_OK, fog_init(&empty));
}
extern "C" void Rust_MeasureInitializeTime();

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

@ -49,14 +49,18 @@ use crate::viaduct_uploader::ViaductUploader;
/// This assembles client information and the Glean configuration and then initializes the global
/// Glean instance.
#[no_mangle]
pub unsafe extern "C" fn fog_init() -> nsresult {
pub unsafe extern "C" fn fog_init(data_path_override: &nsACString) -> nsresult {
fog::metrics::fog::initialization.start();
log::debug!("Initializing FOG.");
let data_path = match get_data_path() {
let data_path = if data_path_override.is_empty() {
match get_data_path() {
Ok(dp) => dp,
Err(e) => return e,
}
} else {
data_path_override.to_utf8().to_string()
};
let (app_build, app_display_version, channel) = match get_app_info() {

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

@ -31,7 +31,9 @@ already_AddRefed<FOG> FOG::GetSingleton() {
void FOG::Shutdown() { glean::impl::fog_shutdown(); }
NS_IMETHODIMP
FOG::InitializeFOG() { return glean::impl::fog_init(); }
FOG::InitializeFOG(const nsACString& aDataPathOverride) {
return glean::impl::fog_init(&aDataPathOverride);
}
NS_IMETHODIMP
FOG::SetLogPings(bool aEnableLogPings) {

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

@ -14,8 +14,11 @@ interface nsIFOG : nsISupports
*
* To be scheduled at some opportune time after the bulk of Firefox startup
* has completed.
*
* @param aDataPathOverride - The path of a custom Glean data path to use
* instead of the profile dir.
*/
void initializeFOG();
void initializeFOG([optional] in AUTF8String aDataPathOverride);
/**
* Enable or Disable the logging of pings in the Glean SDK.