Bug 1395838 - Rename nsITelemetry.SCALAR_* to nsITelemetry.SCALAR_TYPE_*. r=chutten
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Wed, 06 Sep 2017 12:35:44 +0200
changeset 660342 d297771c1ebe214c255644a8a813ce3742afac73
parent 660341 90099274b157b256b6af76d510ca2cc2796d4998
child 660343 9383659b5adc4342510710d4f104af8533670c99
push id78390
push userbmo:emilio@crisal.io
push dateWed, 06 Sep 2017 23:04:15 +0000
reviewerschutten
bugs1395838
milestone57.0a1
Bug 1395838 - Rename nsITelemetry.SCALAR_* to nsITelemetry.SCALAR_TYPE_*. r=chutten MozReview-Commit-ID: 6urKlSG0I6s
toolkit/components/telemetry/TelemetryScalar.cpp
toolkit/components/telemetry/ipc/TelemetryComms.h
toolkit/components/telemetry/nsITelemetry.idl
toolkit/components/telemetry/parse_scalars.py
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -124,37 +124,37 @@ IsValidEnumId(mozilla::Telemetry::Scalar
  * Convert a nsIVariant to a mozilla::Variant, which is used for
  * accumulating child process scalars.
  */
 ScalarResult
 GetVariantFromIVariant(nsIVariant* aInput, uint32_t aScalarKind,
                        mozilla::Maybe<ScalarVariant>& aOutput)
 {
   switch (aScalarKind) {
-    case nsITelemetry::SCALAR_COUNT:
+    case nsITelemetry::SCALAR_TYPE_COUNT:
       {
         uint32_t val = 0;
         nsresult rv = aInput->GetAsUint32(&val);
         if (NS_FAILED(rv)) {
           return ScalarResult::CannotUnpackVariant;
         }
         aOutput = mozilla::Some(mozilla::AsVariant(val));
         break;
       }
-    case nsITelemetry::SCALAR_STRING:
+    case nsITelemetry::SCALAR_TYPE_STRING:
       {
         nsString val;
         nsresult rv = aInput->GetAsAString(val);
         if (NS_FAILED(rv)) {
           return ScalarResult::CannotUnpackVariant;
         }
         aOutput = mozilla::Some(mozilla::AsVariant(val));
         break;
       }
-    case nsITelemetry::SCALAR_BOOLEAN:
+    case nsITelemetry::SCALAR_TYPE_BOOLEAN:
       {
         bool val = false;
         nsresult rv = aInput->GetAsBool(&val);
         if (NS_FAILED(rv)) {
           return ScalarResult::CannotUnpackVariant;
         }
         aOutput = mozilla::Some(mozilla::AsVariant(val));
         break;
@@ -517,23 +517,23 @@ ScalarBoolean::SizeOfIncludingThis(mozil
  * @return nullptr if the scalar type is unknown, otherwise a valid pointer to the
  *         scalar type.
  */
 ScalarBase*
 internal_ScalarAllocate(uint32_t aScalarKind)
 {
   ScalarBase* scalar = nullptr;
   switch (aScalarKind) {
-  case nsITelemetry::SCALAR_COUNT:
+  case nsITelemetry::SCALAR_TYPE_COUNT:
     scalar = new ScalarUnsigned();
     break;
-  case nsITelemetry::SCALAR_STRING:
+  case nsITelemetry::SCALAR_TYPE_STRING:
     scalar = new ScalarString();
     break;
-  case nsITelemetry::SCALAR_BOOLEAN:
+  case nsITelemetry::SCALAR_TYPE_BOOLEAN:
     scalar = new ScalarBoolean();
     break;
   default:
     MOZ_ASSERT(false, "Invalid scalar type");
   }
   return scalar;
 }
 
@@ -1169,17 +1169,17 @@ internal_GetKeyedScalarByEnum(mozilla::T
     return NS_OK;
   }
 
   if (IsExpiredVersion(info.expiration())) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // We don't currently support keyed string scalars. Disable them.
-  if (info.kind == nsITelemetry::SCALAR_STRING) {
+  if (info.kind == nsITelemetry::SCALAR_TYPE_STRING) {
     MOZ_ASSERT(false, "Keyed string scalars are not currently supported.");
     return NS_ERROR_INVALID_ARG;
   }
 
   scalar = new KeyedScalar(info.kind);
   if (!scalar) {
     return NS_ERROR_INVALID_ARG;
   }
@@ -2196,41 +2196,41 @@ TelemetryScalar::UpdateChildData(Process
 
     // Extract the data from the mozilla::Variant.
     switch (upd.mActionType)
     {
       case ScalarActionType::eSet:
         {
           switch (scalarType)
           {
-            case nsITelemetry::SCALAR_COUNT:
+            case nsITelemetry::SCALAR_TYPE_COUNT:
               scalar->SetValue(upd.mData->as<uint32_t>());
               break;
-            case nsITelemetry::SCALAR_BOOLEAN:
+            case nsITelemetry::SCALAR_TYPE_BOOLEAN:
               scalar->SetValue(upd.mData->as<bool>());
               break;
-            case nsITelemetry::SCALAR_STRING:
+            case nsITelemetry::SCALAR_TYPE_STRING:
               scalar->SetValue(upd.mData->as<nsString>());
               break;
           }
           break;
         }
       case ScalarActionType::eAdd:
         {
-          if (scalarType != nsITelemetry::SCALAR_COUNT) {
+          if (scalarType != nsITelemetry::SCALAR_TYPE_COUNT) {
             NS_WARNING("Attempting to add on a non count scalar.");
             continue;
           }
           // We only support adding uint32_t.
           scalar->AddValue(upd.mData->as<uint32_t>());
           break;
         }
       case ScalarActionType::eSetMaximum:
         {
-          if (scalarType != nsITelemetry::SCALAR_COUNT) {
+          if (scalarType != nsITelemetry::SCALAR_TYPE_COUNT) {
             NS_WARNING("Attempting to add on a non count scalar.");
             continue;
           }
           // We only support SetMaximum on uint32_t.
           scalar->SetMaximum(upd.mData->as<uint32_t>());
           break;
         }
       default:
@@ -2287,40 +2287,40 @@ TelemetryScalar::UpdateChildKeyedData(Pr
 
     // Extract the data from the mozilla::Variant.
     switch (upd.mActionType)
     {
       case ScalarActionType::eSet:
         {
           switch (scalarType)
           {
-            case nsITelemetry::SCALAR_COUNT:
+            case nsITelemetry::SCALAR_TYPE_COUNT:
               scalar->SetValue(NS_ConvertUTF8toUTF16(upd.mKey), upd.mData->as<uint32_t>());
               break;
-            case nsITelemetry::SCALAR_BOOLEAN:
+            case nsITelemetry::SCALAR_TYPE_BOOLEAN:
               scalar->SetValue(NS_ConvertUTF8toUTF16(upd.mKey), upd.mData->as<bool>());
               break;
             default:
               NS_WARNING("Unsupported type coming from scalar child updates.");
           }
           break;
         }
       case ScalarActionType::eAdd:
         {
-          if (scalarType != nsITelemetry::SCALAR_COUNT) {
+          if (scalarType != nsITelemetry::SCALAR_TYPE_COUNT) {
             NS_WARNING("Attempting to add on a non count scalar.");
             continue;
           }
           // We only support adding on uint32_t.
           scalar->AddValue(NS_ConvertUTF8toUTF16(upd.mKey), upd.mData->as<uint32_t>());
           break;
         }
       case ScalarActionType::eSetMaximum:
         {
-          if (scalarType != nsITelemetry::SCALAR_COUNT) {
+          if (scalarType != nsITelemetry::SCALAR_TYPE_COUNT) {
             NS_WARNING("Attempting to add on a non count scalar.");
             continue;
           }
           // We only support SetMaximum on uint32_t.
           scalar->SetMaximum(NS_ConvertUTF8toUTF16(upd.mKey), upd.mData->as<uint32_t>());
           break;
         }
       default:
--- a/toolkit/components/telemetry/ipc/TelemetryComms.h
+++ b/toolkit/components/telemetry/ipc/TelemetryComms.h
@@ -151,26 +151,26 @@ ParamTraits<mozilla::Telemetry::ScalarAc
     WriteParam(aMsg, static_cast<uint32_t>(aParam.mActionType));
 
     if (aParam.mData.isNothing()) {
       MOZ_CRASH("There is no data in the ScalarAction.");
       return;
     }
 
     if (aParam.mData->is<uint32_t>()) {
-      // That's a nsITelemetry::SCALAR_COUNT.
-      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_COUNT));
+      // That's a nsITelemetry::SCALAR_TYPE_COUNT.
+      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_TYPE_COUNT));
       WriteParam(aMsg, aParam.mData->as<uint32_t>());
     } else if (aParam.mData->is<nsString>()) {
-      // That's a nsITelemetry::SCALAR_STRING.
-      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_STRING));
+      // That's a nsITelemetry::SCALAR_TYPE_STRING.
+      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_TYPE_STRING));
       WriteParam(aMsg, aParam.mData->as<nsString>());
     } else if (aParam.mData->is<bool>()) {
-      // That's a nsITelemetry::SCALAR_BOOLEAN.
-      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_BOOLEAN));
+      // That's a nsITelemetry::SCALAR_TYPE_BOOLEAN.
+      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_TYPE_BOOLEAN));
       WriteParam(aMsg, aParam.mData->as<bool>());
     } else {
       MOZ_CRASH("Unknown scalar type.");
     }
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
@@ -180,37 +180,37 @@ ParamTraits<mozilla::Telemetry::ScalarAc
         !ReadParam(aMsg, aIter, reinterpret_cast<uint32_t*>(&(aResult->mActionType))) ||
         !ReadParam(aMsg, aIter, &scalarType)) {
       return false;
     }
 
     // De-serialize the data based on the scalar type.
     switch (scalarType)
     {
-      case nsITelemetry::SCALAR_COUNT:
+      case nsITelemetry::SCALAR_TYPE_COUNT:
         {
           uint32_t data = 0;
           // De-serialize the data.
           if (!ReadParam(aMsg, aIter, &data)) {
             return false;
           }
           aResult->mData = mozilla::Some(mozilla::AsVariant(data));
           break;
         }
-      case nsITelemetry::SCALAR_STRING:
+      case nsITelemetry::SCALAR_TYPE_STRING:
         {
           nsString data;
           // De-serialize the data.
           if (!ReadParam(aMsg, aIter, &data)) {
             return false;
           }
           aResult->mData = mozilla::Some(mozilla::AsVariant(data));
           break;
         }
-      case nsITelemetry::SCALAR_BOOLEAN:
+      case nsITelemetry::SCALAR_TYPE_BOOLEAN:
         {
           bool data = false;
           // De-serialize the data.
           if (!ReadParam(aMsg, aIter, &data)) {
             return false;
           }
           aResult->mData = mozilla::Some(mozilla::AsVariant(data));
           break;
@@ -241,26 +241,26 @@ ParamTraits<mozilla::Telemetry::KeyedSca
     WriteParam(aMsg, aParam.mKey);
 
     if (aParam.mData.isNothing()) {
       MOZ_CRASH("There is no data in the KeyedScalarAction.");
       return;
     }
 
     if (aParam.mData->is<uint32_t>()) {
-      // That's a nsITelemetry::SCALAR_COUNT.
-      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_COUNT));
+      // That's a nsITelemetry::SCALAR_TYPE_COUNT.
+      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_TYPE_COUNT));
       WriteParam(aMsg, aParam.mData->as<uint32_t>());
     } else if (aParam.mData->is<nsString>()) {
-      // That's a nsITelemetry::SCALAR_STRING.
+      // That's a nsITelemetry::SCALAR_TYPE_STRING.
       // Keyed string scalars are not supported.
       MOZ_ASSERT(false, "Keyed String Scalar unable to be write from child process. Not supported.");
     } else if (aParam.mData->is<bool>()) {
-      // That's a nsITelemetry::SCALAR_BOOLEAN.
-      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_BOOLEAN));
+      // That's a nsITelemetry::SCALAR_TYPE_BOOLEAN.
+      WriteParam(aMsg, static_cast<uint32_t>(nsITelemetry::SCALAR_TYPE_BOOLEAN));
       WriteParam(aMsg, aParam.mData->as<bool>());
     } else {
       MOZ_CRASH("Unknown keyed scalar type.");
     }
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
@@ -271,33 +271,33 @@ ParamTraits<mozilla::Telemetry::KeyedSca
         !ReadParam(aMsg, aIter, &(aResult->mKey)) ||
         !ReadParam(aMsg, aIter, &scalarType)) {
       return false;
     }
 
     // De-serialize the data based on the scalar type.
     switch (scalarType)
     {
-      case nsITelemetry::SCALAR_COUNT:
+      case nsITelemetry::SCALAR_TYPE_COUNT:
         {
           uint32_t data = 0;
           // De-serialize the data.
           if (!ReadParam(aMsg, aIter, &data)) {
             return false;
           }
           aResult->mData = mozilla::Some(mozilla::AsVariant(data));
           break;
         }
-      case nsITelemetry::SCALAR_STRING:
+      case nsITelemetry::SCALAR_TYPE_STRING:
         {
           // Keyed string scalars are not supported.
           MOZ_ASSERT(false, "Keyed String Scalar unable to be read from child process. Not supported.");
           return false;
         }
-      case nsITelemetry::SCALAR_BOOLEAN:
+      case nsITelemetry::SCALAR_TYPE_BOOLEAN:
         {
           bool data = false;
           // De-serialize the data.
           if (!ReadParam(aMsg, aIter, &data)) {
             return false;
           }
           aResult->mData = mozilla::Some(mozilla::AsVariant(data));
           break;
--- a/toolkit/components/telemetry/nsITelemetry.idl
+++ b/toolkit/components/telemetry/nsITelemetry.idl
@@ -28,23 +28,23 @@ interface nsITelemetry : nsISupports
   const unsigned long HISTOGRAM_LINEAR = 1;
   const unsigned long HISTOGRAM_BOOLEAN = 2;
   const unsigned long HISTOGRAM_FLAG = 3;
   const unsigned long HISTOGRAM_COUNT = 4;
   const unsigned long HISTOGRAM_CATEGORICAL = 5;
 
   /**
    * Scalar types:
-   * SCALAR_COUNT - for storing a numeric value
-   * SCALAR_STRING - for storing a string value
-   * SCALAR_BOOLEAN - for storing a boolean value
+   * SCALAR_TYPE_COUNT - for storing a numeric value
+   * SCALAR_TYPE_STRING - for storing a string value
+   * SCALAR_TYPE_BOOLEAN - for storing a boolean value
    */
-  const unsigned long SCALAR_COUNT = 0;
-  const unsigned long SCALAR_STRING = 1;
-  const unsigned long SCALAR_BOOLEAN = 2;
+  const unsigned long SCALAR_TYPE_COUNT = 0;
+  const unsigned long SCALAR_TYPE_STRING = 1;
+  const unsigned long SCALAR_TYPE_BOOLEAN = 2;
 
   /**
    * Dataset types:
    * DATASET_RELEASE_CHANNEL_OPTOUT - the basic dataset that is on-by-default on all channels
    * DATASET_RELEASE_CHANNEL_OPTIN - the extended dataset that is opt-in on release,
    *                                 opt-out on pre-release channels.
    */
   const unsigned long DATASET_RELEASE_CHANNEL_OPTOUT = 0;
--- a/toolkit/components/telemetry/parse_scalars.py
+++ b/toolkit/components/telemetry/parse_scalars.py
@@ -4,25 +4,25 @@
 
 import re
 import yaml
 import shared_telemetry_utils as utils
 
 from shared_telemetry_utils import ParserError
 
 # The map of containing the allowed scalar types and their mapping to
-# nsITelemetry::SCALAR_* type constants.
+# nsITelemetry::SCALAR_TYPE_* type constants.
 
 BASE_DOC_URL = 'https://firefox-source-docs.mozilla.org/toolkit/components/' + \
                'telemetry/telemetry/collection/scalars.html'
 
 SCALAR_TYPES_MAP = {
-    'uint': 'nsITelemetry::SCALAR_COUNT',
-    'string': 'nsITelemetry::SCALAR_STRING',
-    'boolean': 'nsITelemetry::SCALAR_BOOLEAN'
+    'uint': 'nsITelemetry::SCALAR_TYPE_COUNT',
+    'string': 'nsITelemetry::SCALAR_TYPE_STRING',
+    'boolean': 'nsITelemetry::SCALAR_TYPE_BOOLEAN'
 }
 
 
 class ScalarType:
     """A class for representing a scalar definition."""
 
     def __init__(self, group_name, probe_name, definition, strict_type_checks):
         # Validate and set the name, so we don't need to pass it to the other