Bug 1466490 - Actually record non-main scalars on the main process after deserialization/recording. r?dexter
MozReview-Commit-ID: HNGq5kVVc3k
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -1115,35 +1115,37 @@ internal_CanRecordForScalarID(const Stat
}
/**
* Check if we are allowed to record the provided scalar.
*
* @param lock Instance of a lock locking gTelemetryHistogramMutex
* @param aId The scalar identifier.
* @param aKeyed Are we attempting to write a keyed scalar?
+ * @param aForce Whether to allow recording even if the probe is not allowed on the current process.
+ * This must only be true for GeckoView persistence and recorded actions.
* @return ScalarResult::Ok if we can record, an error code otherwise.
*/
ScalarResult
internal_CanRecordScalar(const StaticMutexAutoLock& lock, const ScalarKey& aId,
- bool aKeyed)
+ bool aKeyed, bool aForce = false)
{
// Make sure that we have a keyed scalar if we are trying to change one.
if (internal_IsKeyedScalar(lock, aId) != aKeyed) {
return ScalarResult::KeyedTypeMismatch;
}
// Are we allowed to record this scalar based on the current Telemetry
// settings?
if (!internal_CanRecordForScalarID(lock, aId)) {
return ScalarResult::CannotRecordDataset;
}
// Can we record in this process?
- if (!internal_CanRecordProcess(lock, aId)) {
+ if (!aForce && !internal_CanRecordProcess(lock, aId)) {
return ScalarResult::CannotRecordInProcess;
}
// Can we record on this product?
if (!internal_CanRecordProduct(lock, aId)) {
return ScalarResult::CannotRecordDataset;
}
@@ -1422,17 +1424,17 @@ internal_UpdateScalar(const StaticMutexA
{
ScalarKey uniqueId;
nsresult rv = internal_GetEnumByScalarName(lock, aName, &uniqueId);
if (NS_FAILED(rv)) {
return (rv == NS_ERROR_FAILURE) ?
ScalarResult::NotInitialized : ScalarResult::UnknownScalar;
}
- ScalarResult sr = internal_CanRecordScalar(lock, uniqueId, false);
+ ScalarResult sr = internal_CanRecordScalar(lock, uniqueId, false, aForce);
if (sr != ScalarResult::Ok) {
if (sr == ScalarResult::CannotRecordDataset) {
return ScalarResult::Ok;
}
return sr;
}
// Accumulate in the child process if needed.
@@ -1600,17 +1602,17 @@ internal_UpdateKeyedScalar(const StaticM
{
ScalarKey uniqueId;
nsresult rv = internal_GetEnumByScalarName(lock, aName, &uniqueId);
if (NS_FAILED(rv)) {
return (rv == NS_ERROR_FAILURE) ?
ScalarResult::NotInitialized : ScalarResult::UnknownScalar;
}
- ScalarResult sr = internal_CanRecordScalar(lock, uniqueId, true);
+ ScalarResult sr = internal_CanRecordScalar(lock, uniqueId, true, aForce);
if (sr != ScalarResult::Ok) {
if (sr == ScalarResult::CannotRecordDataset) {
return ScalarResult::Ok;
}
return sr;
}
// Accumulate in the child process if needed.