Bug 1635253 - Pass the about:glean commands to the Glean SDK r=janerik

Differential Revision: https://phabricator.services.mozilla.com/D83980
This commit is contained in:
Chris H-C 2020-07-30 16:35:29 +00:00
Родитель cd15752878
Коммит 29137e4627
3 изменённых файлов: 58 добавлений и 4 удалений

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

@ -24,19 +24,25 @@ already_AddRefed<AboutGlean> AboutGlean::GetSingleton() {
return do_AddRef(gAboutGlean);
}
extern "C" {
nsresult fog_set_log_pings(bool aEnableLogPings);
nsresult fog_set_debug_view_tag(const nsACString* aDebugTag);
nsresult fog_submit_ping(const nsACString* aPingName);
}
NS_IMETHODIMP
AboutGlean::SetLogPings(bool aEnableLogPings) {
return NS_ERROR_NOT_IMPLEMENTED;
return fog_set_log_pings(aEnableLogPings);
}
NS_IMETHODIMP
AboutGlean::SetTagPings(const nsACString& aDebugTag) {
return NS_ERROR_NOT_IMPLEMENTED;
return fog_set_debug_view_tag(&aDebugTag);
}
NS_IMETHODIMP
AboutGlean::SendPing(const nsACString& aPingName) {
return NS_ERROR_NOT_IMPLEMENTED;
return fog_submit_ping(&aPingName);
}
NS_IMPL_ISUPPORTS(AboutGlean, nsIAboutGlean)

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

@ -185,3 +185,15 @@ fn register_uploader() {
);
}
}
pub fn set_debug_view_tag(value: &str) -> bool {
with_glean_mut(|glean| glean.set_debug_view_tag(value))
}
pub fn submit_ping(ping_name: &str) -> Result<bool> {
with_glean_mut(|glean| glean.submit_ping_by_name(ping_name, None))
}
pub fn set_log_pings(value: bool) -> bool {
with_glean_mut(|glean| glean.set_log_pings(value))
}

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

@ -29,7 +29,7 @@ extern crate xpcom;
use std::ffi::CStr;
use std::os::raw::c_char;
use nserror::{nsresult, NS_ERROR_FAILURE, NS_OK};
use nserror::{nsresult, NS_ERROR_FAILURE, NS_ERROR_NO_CONTENT, NS_OK};
use nsstring::{nsACString, nsCStr};
use xpcom::interfaces::{mozIViaduct, nsIObserver, nsIPrefBranch, nsISupports};
use xpcom::{RefPtr, XpCom};
@ -210,3 +210,39 @@ pub unsafe extern "C" fn fog_use_ipc_buf(buf: *const u8, buf_len: usize) {
// TODO: Record the error.
}*/
}
#[no_mangle]
/// Sets the debug tag for pings assembled in the future.
/// Returns an error result if the provided value is not a valid tag.
pub unsafe extern "C" fn fog_set_debug_view_tag(value: &nsACString) -> nsresult {
let result = api::set_debug_view_tag(&value.to_string());
if result {
return NS_OK;
} else {
return NS_ERROR_FAILURE;
}
}
#[no_mangle]
/// Submits a ping by name.
/// Returns NS_OK if the ping was successfully submitted, NS_ERROR_NO_CONTENT
/// if the ping wasn't sent, or NS_ERROR_FAILURE if some part of the ping
/// submission mechanism failed.
pub unsafe extern "C" fn fog_submit_ping(ping_name: &nsACString) -> nsresult {
match api::submit_ping(&ping_name.to_string()) {
Ok(true) => NS_OK,
Ok(false) => NS_ERROR_NO_CONTENT,
_ => NS_ERROR_FAILURE,
}
}
#[no_mangle]
/// Turns ping logging on or off.
/// Returns an error if the logging failed to be configured.
pub unsafe extern "C" fn fog_set_log_pings(value: bool) -> nsresult {
if api::set_log_pings(value) {
return NS_OK;
} else {
return NS_ERROR_FAILURE;
}
}