Bug 1913624 - Remove expired telemetry histograms PRINT_BACKGROUND_TASK_TIME_MS and PRINT_BACKGROUND_TASK_ROUND_TRIP_TIME_MS, r=win-reviewers,gstoll,TravisLong.

Depends on D219462

Differential Revision: https://phabricator.services.mozilla.com/D219463
This commit is contained in:
Florian Quèze
2024-08-20 20:56:46 +00:00
parent e4a4abb344
commit 04035737a3
5 changed files with 19 additions and 62 deletions

View File

@@ -10032,32 +10032,6 @@
"n_buckets": 50, "n_buckets": 50,
"description": "(Bug 1207089) Time in ms between displaying a popup notification and dismissing it without an action the first time, keyed by ID" "description": "(Bug 1207089) Time in ms between displaying a popup notification and dismissing it without an action the first time, keyed by ID"
}, },
"PRINT_BACKGROUND_TASK_TIME_MS": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["jwatt@jwatt.org"],
"expires_in_version": "95",
"description": "Milliseconds taken on the background thread only for print background tasks. Keys describe the task, usually the information being retrieved, current possible keys are: DefaultSettings, MarginsForPaper, Printers, NamedPrinter, NamedOrDefaultPrinter, SupportsDuplex, SupportsColor, SupportsCollation, PaperList.",
"keyed": true,
"kind": "exponential",
"high": 10000,
"n_buckets": 50,
"releaseChannelCollection": "opt-out",
"bug_numbers": [1660686]
},
"PRINT_BACKGROUND_TASK_ROUND_TRIP_TIME_MS": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["jwatt@jwatt.org"],
"expires_in_version": "95",
"description": "Milliseconds taken for print background tasks from spawning to background thread back to before resolving or rejecting on the main thread. See PRINT_BACKGROUND_TASK_TIME_MS for key description.",
"keyed": true,
"kind": "exponential",
"high": 10000,
"n_buckets": 50,
"releaseChannelCollection": "opt-out",
"bug_numbers": [1660686]
},
"PRINT_INIT_TO_PLATFORM_SENT_SETTINGS_MS": { "PRINT_INIT_TO_PLATFORM_SENT_SETTINGS_MS": {
"record_in_processes": ["main"], "record_in_processes": ["main"],
"products": ["firefox"], "products": ["firefox"],

View File

@@ -8,7 +8,6 @@
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/Telemetry.h"
#include <tuple> #include <tuple>
#include <utility> #include <utility>
@@ -30,7 +29,7 @@ using PrintBackgroundTask = Result (T::*)(Args...) const;
template <typename T, typename Result, typename... Args> template <typename T, typename Result, typename... Args>
void SpawnPrintBackgroundTask( void SpawnPrintBackgroundTask(
T& aReceiver, dom::Promise& aPromise, const nsCString& aTelemetryKey, T& aReceiver, dom::Promise& aPromise,
PrintBackgroundTask<T, Result, Args...> aBackgroundTask, Args... aArgs) { PrintBackgroundTask<T, Result, Args...> aBackgroundTask, Args... aArgs) {
auto promiseHolder = MakeRefPtr<nsMainThreadPtrHolder<dom::Promise>>( auto promiseHolder = MakeRefPtr<nsMainThreadPtrHolder<dom::Promise>>(
"nsPrinterBase::SpawnBackgroundTaskPromise", &aPromise); "nsPrinterBase::SpawnBackgroundTaskPromise", &aPromise);
@@ -47,26 +46,18 @@ void SpawnPrintBackgroundTask(
NS_NewRunnableFunction( NS_NewRunnableFunction(
"SpawnPrintBackgroundTask", "SpawnPrintBackgroundTask",
[holder = std::move(holder), promiseHolder = std::move(promiseHolder), [holder = std::move(holder), promiseHolder = std::move(promiseHolder),
aTelemetryKey, startRoundTrip = TimeStamp::Now(),
backgroundTask = aBackgroundTask, backgroundTask = aBackgroundTask,
aArgs = std::make_tuple(std::forward<Args>(aArgs)...)] { aArgs = std::make_tuple(std::forward<Args>(aArgs)...)] {
auto start = TimeStamp::Now();
Result result = std::apply( Result result = std::apply(
[&](auto&&... args) { [&](auto&&... args) {
return (holder->get()->*backgroundTask)(args...); return (holder->get()->*backgroundTask)(args...);
}, },
std::move(aArgs)); std::move(aArgs));
Telemetry::AccumulateTimeDelta(
Telemetry::PRINT_BACKGROUND_TASK_TIME_MS, aTelemetryKey, start);
NS_DispatchToMainThread(NS_NewRunnableFunction( NS_DispatchToMainThread(NS_NewRunnableFunction(
"SpawnPrintBackgroundTaskResolution", "SpawnPrintBackgroundTaskResolution",
[holder = std::move(holder), [holder = std::move(holder),
promiseHolder = std::move(promiseHolder), promiseHolder = std::move(promiseHolder),
telemetryKey = std::move(aTelemetryKey), startRoundTrip,
result = std::move(result)] { result = std::move(result)] {
Telemetry::AccumulateTimeDelta(
Telemetry::PRINT_BACKGROUND_TASK_ROUND_TRIP_TIME_MS,
telemetryKey, startRoundTrip);
ResolveOrReject(*promiseHolder->get(), *holder->get(), ResolveOrReject(*promiseHolder->get(), *holder->get(),
result); result);
})); }));
@@ -79,7 +70,6 @@ void SpawnPrintBackgroundTask(
template <typename T, typename Result, typename... Args> template <typename T, typename Result, typename... Args>
nsresult PrintBackgroundTaskPromise( nsresult PrintBackgroundTaskPromise(
T& aReceiver, JSContext* aCx, dom::Promise** aResultPromise, T& aReceiver, JSContext* aCx, dom::Promise** aResultPromise,
const nsCString& aTelemetryKey,
PrintBackgroundTask<T, Result, Args...> aTask, Args... aArgs) { PrintBackgroundTask<T, Result, Args...> aTask, Args... aArgs) {
ErrorResult rv; ErrorResult rv;
RefPtr<dom::Promise> promise = RefPtr<dom::Promise> promise =
@@ -88,7 +78,7 @@ nsresult PrintBackgroundTaskPromise(
return rv.StealNSResult(); return rv.StealNSResult();
} }
SpawnPrintBackgroundTask(aReceiver, *promise, aTelemetryKey, aTask, SpawnPrintBackgroundTask(aReceiver, *promise, aTask,
std::forward<Args>(aArgs)...); std::forward<Args>(aArgs)...);
promise.forget(aResultPromise); promise.forget(aResultPromise);
@@ -100,16 +90,15 @@ nsresult PrintBackgroundTaskPromise(
template <typename T, typename Result, typename... Args> template <typename T, typename Result, typename... Args>
nsresult AsyncPromiseAttributeGetter( nsresult AsyncPromiseAttributeGetter(
T& aReceiver, RefPtr<dom::Promise>& aPromiseSlot, JSContext* aCx, T& aReceiver, RefPtr<dom::Promise>& aPromiseSlot, JSContext* aCx,
dom::Promise** aResultPromise, const nsCString& aTelemetryKey, dom::Promise** aResultPromise,
PrintBackgroundTask<T, Result, Args...> aTask, Args... aArgs) { PrintBackgroundTask<T, Result, Args...> aTask, Args... aArgs) {
if (RefPtr<dom::Promise> existing = aPromiseSlot) { if (RefPtr<dom::Promise> existing = aPromiseSlot) {
existing.forget(aResultPromise); existing.forget(aResultPromise);
return NS_OK; return NS_OK;
} }
nsresult rv = nsresult rv = PrintBackgroundTaskPromise(aReceiver, aCx, aResultPromise,
PrintBackgroundTaskPromise(aReceiver, aCx, aResultPromise, aTelemetryKey, aTask, std::forward<Args>(aArgs)...);
aTask, std::forward<Args>(aArgs)...);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
aPromiseSlot = *aResultPromise; aPromiseSlot = *aResultPromise;

View File

@@ -125,14 +125,9 @@ nsresult nsPrinterBase::AsyncPromiseAttributeGetter(
BackgroundTask<T, Args...> aBackgroundTask, Args... aArgs) { BackgroundTask<T, Args...> aBackgroundTask, Args... aArgs) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
static constexpr EnumeratedArray<AsyncAttribute, nsLiteralCString,
size_t(AsyncAttribute::Last)>
attributeKeys{"SupportsDuplex"_ns, "SupportsColor"_ns,
"SupportsMonochrome"_ns, "SupportsCollation"_ns,
"PrinterInfo"_ns};
return mozilla::AsyncPromiseAttributeGetter( return mozilla::AsyncPromiseAttributeGetter(
*this, mAsyncAttributePromises[aAttribute], aCx, aResultPromise, *this, mAsyncAttributePromises[aAttribute], aCx, aResultPromise,
attributeKeys[aAttribute], aBackgroundTask, std::forward<Args>(aArgs)...); aBackgroundTask, std::forward<Args>(aArgs)...);
} }
NS_IMETHODIMP nsPrinterBase::CopyFromWithValidation( NS_IMETHODIMP nsPrinterBase::CopyFromWithValidation(
@@ -196,7 +191,7 @@ NS_IMETHODIMP nsPrinterBase::GetPrinterInfo(JSContext* aCx,
void nsPrinterBase::QueryMarginsForPaper(Promise& aPromise, void nsPrinterBase::QueryMarginsForPaper(Promise& aPromise,
const nsString& aPaperId) { const nsString& aPaperId) {
return SpawnPrintBackgroundTask(*this, aPromise, "MarginsForPaper"_ns, return SpawnPrintBackgroundTask(*this, aPromise,
&nsPrinterBase::GetMarginsForPaper, aPaperId); &nsPrinterBase::GetMarginsForPaper, aPaperId);
} }

View File

@@ -61,16 +61,15 @@ void ResolveOrReject(dom::Promise& aPromise, nsPrinterListBase& aList,
NS_IMETHODIMP nsPrinterListBase::GetPrinters(JSContext* aCx, NS_IMETHODIMP nsPrinterListBase::GetPrinters(JSContext* aCx,
Promise** aResult) { Promise** aResult) {
EnsureCommonPaperInfo(aCx); EnsureCommonPaperInfo(aCx);
return mozilla::AsyncPromiseAttributeGetter(*this, mPrintersPromise, aCx, return mozilla::AsyncPromiseAttributeGetter(
aResult, "Printers"_ns, *this, mPrintersPromise, aCx, aResult, &nsPrinterListBase::Printers);
&nsPrinterListBase::Printers);
} }
NS_IMETHODIMP nsPrinterListBase::GetPrinterByName(const nsAString& aPrinterName, NS_IMETHODIMP nsPrinterListBase::GetPrinterByName(const nsAString& aPrinterName,
JSContext* aCx, JSContext* aCx,
Promise** aResult) { Promise** aResult) {
EnsureCommonPaperInfo(aCx); EnsureCommonPaperInfo(aCx);
return PrintBackgroundTaskPromise(*this, aCx, aResult, "PrinterByName"_ns, return PrintBackgroundTaskPromise(*this, aCx, aResult,
&nsPrinterListBase::PrinterByName, &nsPrinterListBase::PrinterByName,
nsString{aPrinterName}); nsString{aPrinterName});
} }
@@ -78,17 +77,17 @@ NS_IMETHODIMP nsPrinterListBase::GetPrinterByName(const nsAString& aPrinterName,
NS_IMETHODIMP nsPrinterListBase::GetPrinterBySystemName( NS_IMETHODIMP nsPrinterListBase::GetPrinterBySystemName(
const nsAString& aPrinterName, JSContext* aCx, Promise** aResult) { const nsAString& aPrinterName, JSContext* aCx, Promise** aResult) {
EnsureCommonPaperInfo(aCx); EnsureCommonPaperInfo(aCx);
return PrintBackgroundTaskPromise( return PrintBackgroundTaskPromise(*this, aCx, aResult,
*this, aCx, aResult, "PrinterBySystemName"_ns, &nsPrinterListBase::PrinterBySystemName,
&nsPrinterListBase::PrinterBySystemName, nsString{aPrinterName}); nsString{aPrinterName});
} }
NS_IMETHODIMP nsPrinterListBase::GetNamedOrDefaultPrinter( NS_IMETHODIMP nsPrinterListBase::GetNamedOrDefaultPrinter(
const nsAString& aPrinterName, JSContext* aCx, Promise** aResult) { const nsAString& aPrinterName, JSContext* aCx, Promise** aResult) {
EnsureCommonPaperInfo(aCx); EnsureCommonPaperInfo(aCx);
return PrintBackgroundTaskPromise( return PrintBackgroundTaskPromise(*this, aCx, aResult,
*this, aCx, aResult, "NamedOrDefaultPrinter"_ns, &nsPrinterListBase::NamedOrDefaultPrinter,
&nsPrinterListBase::NamedOrDefaultPrinter, nsString{aPrinterName}); nsString{aPrinterName});
} }
Maybe<PrinterInfo> nsPrinterListBase::NamedOrDefaultPrinter( Maybe<PrinterInfo> nsPrinterListBase::NamedOrDefaultPrinter(

View File

@@ -204,9 +204,9 @@ NS_IMETHODIMP nsPrinterWin::CopyFromWithValidation(
PrintSettingsInitializer settingsInitializer = PrintSettingsInitializer settingsInitializer =
aSettingsToCopyFrom->GetSettingsInitializer(); aSettingsToCopyFrom->GetSettingsInitializer();
return PrintBackgroundTaskPromise( return PrintBackgroundTaskPromise(*this, aCx, aResultPromise,
*this, aCx, aResultPromise, "CopyFromWithValidation"_ns, &nsPrinterWin::GetValidatedSettings,
&nsPrinterWin::GetValidatedSettings, settingsInitializer); settingsInitializer);
} }
bool nsPrinterWin::SupportsDuplex() const { bool nsPrinterWin::SupportsDuplex() const {