зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1708669 - Register FOG custom pings on Android builds to enable Glean functionality. r=chutten,geckoview-reviewers,agi
This instantiates the FOG service, which in turn registers an idle observer, which is required for FOG IPC to be triggered occasionally. Glean itself will be controlled by the surrounding Android application. Glean symbols are shipped in this GeckoView build. Any metrics recorded in Gecko will be passed through to the Android application, e.g. Fenix. This also re-exports `rlb_flush_dispatcher` to be called by Glean Core from the Kotlin side. Currently this does not support sending custom pings inside Gecko. Testing Glean metrics in an Android build will be enabled in subsequent commits. Differential Revision: https://phabricator.services.mozilla.com/D126799
This commit is contained in:
Родитель
fd5b205acc
Коммит
ba5c77a572
|
@ -774,6 +774,13 @@ function startup() {
|
|||
SafeBrowsing.init();
|
||||
});
|
||||
|
||||
InitLater(() => {
|
||||
// It's enough to run this once to set up FOG.
|
||||
// (See also bug 1730026.)
|
||||
const FOG = Cc["@mozilla.org/toolkit/glean;1"].createInstance(Ci.nsIFOG);
|
||||
FOG.registerCustomPings();
|
||||
});
|
||||
|
||||
// This should always go last, since the idle tasks (except for the ones with
|
||||
// timeouts) should execute in order. Note that this observer notification is
|
||||
// not guaranteed to fire, since the window could close before we get here.
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace glean {
|
|||
* serialized payload that the Rust impl hands you.
|
||||
*/
|
||||
void FlushFOGData(std::function<void(ipc::ByteBuf&&)>&& aResolver) {
|
||||
#ifndef MOZ_GLEAN_ANDROID
|
||||
ByteBuf buf;
|
||||
uint32_t ipcBufferSize = impl::fog_serialize_ipc_buf();
|
||||
bool ok = buf.Allocate(ipcBufferSize);
|
||||
|
@ -39,7 +38,6 @@ void FlushFOGData(std::function<void(ipc::ByteBuf&&)>&& aResolver) {
|
|||
return;
|
||||
}
|
||||
aResolver(std::move(buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +47,6 @@ void FlushFOGData(std::function<void(ipc::ByteBuf&&)>&& aResolver) {
|
|||
*/
|
||||
void FlushAllChildData(
|
||||
std::function<void(nsTArray<ipc::ByteBuf>&&)>&& aResolver) {
|
||||
#ifndef MOZ_GLEAN_ANDROID
|
||||
nsTArray<ContentParent*> parents;
|
||||
ContentParent::GetAll(parents);
|
||||
if (parents.Length() == 0) {
|
||||
|
@ -79,7 +76,6 @@ void FlushAllChildData(
|
|||
aResolver(std::move(results));
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,10 +83,8 @@ void FlushAllChildData(
|
|||
* @param buf - a bincoded serialized payload that the Rust impl understands.
|
||||
*/
|
||||
void FOGData(ipc::ByteBuf&& buf) {
|
||||
#ifndef MOZ_GLEAN_ANDROID
|
||||
fog_ipc::buffer_sizes.Accumulate(buf.mLen);
|
||||
impl::fog_use_ipc_buf(buf.mData, buf.mLen);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +92,6 @@ void FOGData(ipc::ByteBuf&& buf) {
|
|||
* @param buf - a bincoded serialized payload that the Rust impl understands.
|
||||
*/
|
||||
void SendFOGData(ipc::ByteBuf&& buf) {
|
||||
#ifndef MOZ_GLEAN_ANDROID
|
||||
switch (XRE_GetProcessType()) {
|
||||
case GeckoProcessType_Content:
|
||||
mozilla::dom::ContentChild::GetSingleton()->SendFOGData(std::move(buf));
|
||||
|
@ -106,7 +99,6 @@ void SendFOGData(ipc::ByteBuf&& buf) {
|
|||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unsuppored process type");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,11 @@ pub extern "C" fn fog_shutdown() {
|
|||
glean::shutdown();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn fog_register_pings() {
|
||||
fog::pings::register_pings();
|
||||
}
|
||||
|
||||
static mut PENDING_BUF: Vec<u8> = Vec::new();
|
||||
|
||||
// IPC serialization/deserialization methods
|
||||
|
|
|
@ -28,6 +28,9 @@ using glean::LogToBrowserConsole;
|
|||
// Defined by `glean_ffi`. We reexport it here for later use.
|
||||
extern "C" NS_EXPORT void glean_enable_logging(void);
|
||||
|
||||
// Defined by `glean`. We reexport it here for use by the Glean Core SDK.
|
||||
extern "C" NS_EXPORT void rlb_flush_dispatcher(void);
|
||||
|
||||
// Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi`
|
||||
//
|
||||
// Due to how linking works and hides symbols the symbols from `glean_ffi` might
|
||||
|
@ -80,20 +83,18 @@ already_AddRefed<FOG> FOG::GetSingleton() {
|
|||
return do_AddRef(gFOG);
|
||||
}
|
||||
|
||||
void FOG::Shutdown() {
|
||||
#ifndef MOZ_GLEAN_ANDROID
|
||||
glean::impl::fog_shutdown();
|
||||
#endif
|
||||
}
|
||||
void FOG::Shutdown() { glean::impl::fog_shutdown(); }
|
||||
|
||||
NS_IMETHODIMP
|
||||
FOG::InitializeFOG(const nsACString& aDataPathOverride,
|
||||
const nsACString& aAppIdOverride) {
|
||||
#ifdef MOZ_GLEAN_ANDROID
|
||||
return NS_OK;
|
||||
#else
|
||||
return glean::impl::fog_init(&aDataPathOverride, &aAppIdOverride);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FOG::RegisterCustomPings() {
|
||||
glean::impl::fog_register_pings();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -22,6 +22,13 @@ interface nsIFOG : nsISupports
|
|||
*/
|
||||
void initializeFOG([optional] in AUTF8String aDataPathOverride, [optional] in AUTF8String aAppIdOverride);
|
||||
|
||||
/**
|
||||
* Register custom pings.
|
||||
*
|
||||
* Ensure all custom pings are registered with Glean.
|
||||
*/
|
||||
void registerCustomPings();
|
||||
|
||||
/**
|
||||
* Enable or Disable the logging of pings in the Glean SDK.
|
||||
* See https://firefox-source-docs.mozilla.org/toolkit/components/glean/testing.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче