Bug 1466490 - Actually record non-main scalars on the main process after deserialization/recording. r?dexter draft
authorJan-Erik Rediger <jrediger@mozilla.com>
Thu, 14 Jun 2018 16:03:33 -0700
changeset 807566 8cd0c760bc208adb689c9e0d4ae597b600be8f0d
parent 807395 91db0c695f0272f00bf92c81c471a85101056d96
child 807567 8eefda574fb7d04fd187fe9ae4c2e5f1d74a43d1
child 807568 3a0cb4372a7cdaa5a3efbf2efee379592f7f0337
child 807569 aa243cb8c5a057edc6fbaa782fde9d1fd89f5b57
child 807765 4a193f7f3c29449c9536b86a4c9b81de3297240e
push id113161
push userbmo:jrediger@mozilla.com
push dateThu, 14 Jun 2018 23:37:30 +0000
reviewersdexter
bugs1466490
milestone62.0a1
Bug 1466490 - Actually record non-main scalars on the main process after deserialization/recording. r?dexter MozReview-Commit-ID: HNGq5kVVc3k
toolkit/components/telemetry/TelemetryScalar.cpp
--- 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.