Bug 1507540 part 6. Make nsIVariant's "type" a notxpcom attribute. r=froydnj
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 19 Nov 2018 20:20:05 -0500
changeset 447118 6b60870ec6f8473b578be250179840c5316f0444
parent 447117 f50e3a884aa8bfc672952a93cbafe02f376292bd
child 447119 d583bf98a4b2086c0e016de10bebc871c35a3361
push id109983
push userbzbarsky@mozilla.com
push dateTue, 20 Nov 2018 01:21:04 +0000
treeherdermozilla-inbound@60639eb34a6d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1507540
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507540 part 6. Make nsIVariant's "type" a notxpcom attribute. r=froydnj
dom/events/DataTransfer.cpp
dom/media/MediaDevices.cpp
dom/quota/StorageManager.cpp
dom/xslt/xslt/txMozillaXSLTProcessor.cpp
js/xpconnect/src/XPCVariant.cpp
storage/Variant.h
storage/Variant_inl.h
storage/mozStoragePrivateHelpers.cpp
storage/mozStorageRow.cpp
storage/variantToSQLiteT_impl.h
toolkit/components/places/nsAnnotationService.cpp
toolkit/components/places/nsNavHistoryQuery.cpp
toolkit/components/telemetry/core/TelemetryScalar.cpp
widget/android/PrefsHelper.h
xpcom/ds/nsIVariant.idl
xpcom/ds/nsVariant.cpp
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -1141,18 +1141,17 @@ DataTransfer::GetTransferable(uint32_t a
 bool
 DataTransfer::ConvertFromVariant(nsIVariant* aVariant,
                                  nsISupports** aSupports,
                                  uint32_t* aLength) const
 {
   *aSupports = nullptr;
   *aLength = 0;
 
-  uint16_t type;
-  aVariant->GetDataType(&type);
+  uint16_t type = aVariant->GetDataType();
   if (type == nsIDataType::VTYPE_INTERFACE ||
       type == nsIDataType::VTYPE_INTERFACE_IS) {
     nsCOMPtr<nsISupports> data;
     if (NS_FAILED(aVariant->GetAsISupports(getter_AddRefs(data)))) {
       return false;
     }
 
     nsCOMPtr<nsIFlavorDataProvider> fdp = do_QueryInterface(data);
--- a/dom/media/MediaDevices.cpp
+++ b/dom/media/MediaDevices.cpp
@@ -78,26 +78,24 @@ class MediaDevices::EnumDevResolver
       : mPromise(aPromise), mWindowId(aWindowId) {}
 
   NS_IMETHOD
   OnSuccess(nsIVariant* aDevices) override {
     // Create array for nsIMediaDevice
     nsTArray<nsCOMPtr<nsIMediaDevice>> devices;
     // Contain the fumes
     {
-      uint16_t vtype;
-      nsresult rv = aDevices->GetDataType(&vtype);
-      NS_ENSURE_SUCCESS(rv, rv);
+      uint16_t vtype = aDevices->GetDataType();
       if (vtype != nsIDataType::VTYPE_EMPTY_ARRAY) {
         nsIID elementIID;
         uint16_t elementType;
         void* rawArray;
         uint32_t arrayLen;
-        rv = aDevices->GetAsArray(&elementType, &elementIID, &arrayLen,
-                                  &rawArray);
+        nsresult rv = aDevices->GetAsArray(&elementType, &elementIID, &arrayLen,
+                                           &rawArray);
         NS_ENSURE_SUCCESS(rv, rv);
         if (elementType != nsIDataType::VTYPE_INTERFACE) {
           free(rawArray);
           return NS_ERROR_FAILURE;
         }
 
         nsISupports** supportsArray = reinterpret_cast<nsISupports**>(rawArray);
         for (uint32_t i = 0; i < arrayLen; ++i) {
--- a/dom/quota/StorageManager.cpp
+++ b/dom/quota/StorageManager.cpp
@@ -447,21 +447,17 @@ RequestResolver::ResolveOrReject()
 NS_IMPL_ISUPPORTS(RequestResolver, nsIQuotaUsageCallback, nsIQuotaCallback)
 
 nsresult
 RequestResolver::GetStorageEstimate(nsIVariant* aResult)
 {
   MOZ_ASSERT(aResult);
   MOZ_ASSERT(mType == Type::Estimate);
 
-#ifdef DEBUG
-  uint16_t dataType;
-  MOZ_ALWAYS_SUCCEEDS(aResult->GetDataType(&dataType));
-  MOZ_ASSERT(dataType == nsIDataType::VTYPE_INTERFACE_IS);
-#endif
+  MOZ_ASSERT(aResult->GetDataType() == nsIDataType::VTYPE_INTERFACE_IS);
 
   nsID* iid;
   nsCOMPtr<nsISupports> supports;
   nsresult rv = aResult->GetAsInterface(&iid, getter_AddRefs(supports));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
@@ -482,18 +478,17 @@ RequestResolver::GetStorageEstimate(nsIV
 
 nsresult
 RequestResolver::GetPersisted(nsIVariant* aResult)
 {
   MOZ_ASSERT(aResult);
   MOZ_ASSERT(mType == Type::Persist || mType == Type::Persisted);
 
 #ifdef DEBUG
-  uint16_t dataType;
-  MOZ_ALWAYS_SUCCEEDS(aResult->GetDataType(&dataType));
+  uint16_t dataType = aResult->GetDataType();
 #endif
 
   if (mType == Type::Persist) {
     MOZ_ASSERT(dataType == nsIDataType::VTYPE_VOID);
 
     mPersisted = true;
     return NS_OK;
   }
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -752,18 +752,17 @@ nsresult
 txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
                                      nsIVariant* aValue)
 {
     NS_ENSURE_ARG(aValue);
 
     nsCOMPtr<nsIVariant> value = aValue;
 
-    uint16_t dataType;
-    value->GetDataType(&dataType);
+    uint16_t dataType = value->GetDataType();
     switch (dataType) {
         // Number
         case nsIDataType::VTYPE_INT8:
         case nsIDataType::VTYPE_INT16:
         case nsIDataType::VTYPE_INT32:
         case nsIDataType::VTYPE_INT64:
         case nsIDataType::VTYPE_UINT8:
         case nsIDataType::VTYPE_UINT16:
@@ -1308,18 +1307,17 @@ txMozillaXSLTProcessor::Shutdown()
 }
 
 /* static*/
 nsresult
 txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
 {
     *aResult = nullptr;
 
-    uint16_t dataType;
-    aValue->GetDataType(&dataType);
+    uint16_t dataType = aValue->GetDataType();
     switch (dataType) {
         // Number
         case nsIDataType::VTYPE_INT8:
         case nsIDataType::VTYPE_INT16:
         case nsIDataType::VTYPE_INT32:
         case nsIDataType::VTYPE_INT64:
         case nsIDataType::VTYPE_UINT8:
         case nsIDataType::VTYPE_UINT16:
--- a/js/xpconnect/src/XPCVariant.cpp
+++ b/js/xpconnect/src/XPCVariant.cpp
@@ -383,20 +383,17 @@ XPCVariant::GetAsJSVal(MutableHandleValu
 }
 
 // static
 bool
 XPCVariant::VariantDataToJS(nsIVariant* variant,
                             nsresult* pErr, MutableHandleValue pJSVal)
 {
     // Get the type early because we might need to spoof it below.
-    uint16_t type;
-    if (NS_FAILED(variant->GetDataType(&type))) {
-        return false;
-    }
+    uint16_t type = variant->GetDataType();
 
     AutoJSContext cx;
     RootedValue realVal(cx);
     nsresult rv = variant->GetAsJSVal(&realVal);
 
     if (NS_SUCCEEDED(rv) &&
         (realVal.isPrimitive() ||
          type == nsIDataType::VTYPE_ARRAY ||
@@ -700,20 +697,19 @@ XPCVariant::VariantDataToJS(nsIVariant* 
 }
 
 /***************************************************************************/
 /***************************************************************************/
 // XXX These default implementations need to be improved to allow for
 // some more interesting conversions.
 
 
-NS_IMETHODIMP XPCVariant::GetDataType(uint16_t* aDataType)
+uint16_t XPCVariant::GetDataType()
 {
-    *aDataType = mData.GetType();
-    return NS_OK;
+    return mData.GetType();
 }
 
 NS_IMETHODIMP XPCVariant::GetAsInt8(uint8_t* _retval)
 {
     return mData.ConvertToInt8(_retval);
 }
 
 NS_IMETHODIMP XPCVariant::GetAsInt16(int16_t* _retval)
--- a/storage/Variant.h
+++ b/storage/Variant.h
@@ -342,21 +342,19 @@ struct variant_blob_traits<uint8_t[], tr
 
 /**
  * nullptr type
  */
 
 class NullVariant : public Variant_base
 {
 public:
-  NS_IMETHOD GetDataType(uint16_t *_type) override
+  uint16_t GetDataType() override
   {
-    NS_ENSURE_ARG_POINTER(_type);
-    *_type = nsIDataType::VTYPE_EMPTY;
-    return NS_OK;
+    return nsIDataType::VTYPE_EMPTY;
   }
 
   NS_IMETHOD GetAsAUTF8String(nsACString &_str) override
   {
     // Return a void string.
     _str.SetIsVoid(true);
     return NS_OK;
   }
@@ -381,20 +379,19 @@ class Variant final : public Variant_bas
   }
 
 public:
   explicit Variant(const typename variant_storage_traits<DataType, Adopting>::ConstructorType aData)
   {
     variant_storage_traits<DataType, Adopting>::storage_conversion(aData, &mData);
   }
 
-  NS_IMETHOD GetDataType(uint16_t *_type) override
+  uint16_t GetDataType() override
   {
-    *_type = variant_traits<DataType>::type();
-    return NS_OK;
+    return variant_traits<DataType>::type();
   }
   NS_IMETHOD GetAsInt32(int32_t *_integer) override
   {
     return variant_integer_traits<DataType, Adopting>::asInt32(mData, _integer);
   }
 
   NS_IMETHOD GetAsInt64(int64_t *_integer) override
   {
--- a/storage/Variant_inl.h
+++ b/storage/Variant_inl.h
@@ -24,22 +24,20 @@ inline NS_IMPL_QUERY_INTERFACE(
   Variant_base,
   nsIVariant
 )
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIVariant
 
 inline
-NS_IMETHODIMP
-Variant_base::GetDataType(uint16_t *_type)
+uint16_t
+Variant_base::GetDataType()
 {
-  NS_ENSURE_ARG_POINTER(_type);
-  *_type = nsIDataType::VTYPE_VOID;
-  return NS_OK;
+  return nsIDataType::VTYPE_VOID;
 }
 
 inline
 NS_IMETHODIMP
 Variant_base::GetAsInt32(int32_t *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
--- a/storage/mozStoragePrivateHelpers.cpp
+++ b/storage/mozStoragePrivateHelpers.cpp
@@ -166,68 +166,66 @@ convertVariantToStorageVariant(nsIVarian
     // JS helpers already convert the JS representation to a Storage Variant,
     // in such a case there's nothing left to do here, so just pass-through.
     return variant;
   }
 
   if (!aVariant)
     return new NullVariant();
 
-  uint16_t dataType;
-  nsresult rv = aVariant->GetDataType(&dataType);
-  NS_ENSURE_SUCCESS(rv, nullptr);
+  uint16_t dataType = aVariant->GetDataType();
 
   switch (dataType) {
     case nsIDataType::VTYPE_BOOL:
     case nsIDataType::VTYPE_INT8:
     case nsIDataType::VTYPE_INT16:
     case nsIDataType::VTYPE_INT32:
     case nsIDataType::VTYPE_UINT8:
     case nsIDataType::VTYPE_UINT16:
     case nsIDataType::VTYPE_UINT32:
     case nsIDataType::VTYPE_INT64:
     case nsIDataType::VTYPE_UINT64: {
       int64_t v;
-      rv = aVariant->GetAsInt64(&v);
+      nsresult rv = aVariant->GetAsInt64(&v);
       NS_ENSURE_SUCCESS(rv, nullptr);
       return new IntegerVariant(v);
     }
     case nsIDataType::VTYPE_FLOAT:
     case nsIDataType::VTYPE_DOUBLE: {
       double v;
-      rv = aVariant->GetAsDouble(&v);
+      nsresult rv = aVariant->GetAsDouble(&v);
       NS_ENSURE_SUCCESS(rv, nullptr);
       return new FloatVariant(v);
     }
     case nsIDataType::VTYPE_CHAR:
     case nsIDataType::VTYPE_CHAR_STR:
     case nsIDataType::VTYPE_STRING_SIZE_IS:
     case nsIDataType::VTYPE_UTF8STRING:
     case nsIDataType::VTYPE_CSTRING: {
       nsCString v;
-      rv = aVariant->GetAsAUTF8String(v);
+      nsresult rv = aVariant->GetAsAUTF8String(v);
       NS_ENSURE_SUCCESS(rv, nullptr);
       return new UTF8TextVariant(v);
     }
     case nsIDataType::VTYPE_WCHAR:
     case nsIDataType::VTYPE_WCHAR_STR:
     case nsIDataType::VTYPE_WSTRING_SIZE_IS:
     case nsIDataType::VTYPE_ASTRING: {
       nsString v;
-      rv = aVariant->GetAsAString(v);
+      nsresult rv = aVariant->GetAsAString(v);
       NS_ENSURE_SUCCESS(rv, nullptr);
       return new TextVariant(v);
     }
     case nsIDataType::VTYPE_ARRAY: {
       uint16_t type;
       nsIID iid;
       uint32_t len;
       void *rawArray;
       // Note this copies the array data.
-      rv = aVariant->GetAsArray(&type, &iid, &len, &rawArray);
+      nsresult rv = aVariant->GetAsArray(&type, &iid, &len, &rawArray);
       NS_ENSURE_SUCCESS(rv, nullptr);
       if (type == nsIDataType::VTYPE_UINT8) {
         std::pair<uint8_t *, int> v(static_cast<uint8_t *>(rawArray), len);
         // Take ownership of the data avoiding a further copy.
         return new AdoptedBlobVariant(v);
       }
       MOZ_FALLTHROUGH;
     }
--- a/storage/mozStorageRow.cpp
+++ b/storage/mozStorageRow.cpp
@@ -113,18 +113,17 @@ Row::GetNumEntries(uint32_t *_entries)
 }
 
 NS_IMETHODIMP
 Row::GetTypeOfIndex(uint32_t aIndex,
                     int32_t *_type)
 {
   ENSURE_INDEX_VALUE(aIndex, mNumCols);
 
-  uint16_t type;
-  (void)mData.ObjectAt(aIndex)->GetDataType(&type);
+  uint16_t type = mData.ObjectAt(aIndex)->GetDataType();
   switch (type) {
     case nsIDataType::VTYPE_INT32:
     case nsIDataType::VTYPE_INT64:
       *_type = mozIStorageValueArray::VALUE_TYPE_INTEGER;
       break;
     case nsIDataType::VTYPE_DOUBLE:
       *_type = mozIStorageValueArray::VALUE_TYPE_FLOAT;
       break;
@@ -208,18 +207,17 @@ Row::GetBlobAsUTF8String(uint32_t aIndex
 
 NS_IMETHODIMP
 Row::GetIsNull(uint32_t aIndex,
                bool *_isNull)
 {
   ENSURE_INDEX_VALUE(aIndex, mNumCols);
   NS_ENSURE_ARG_POINTER(_isNull);
 
-  uint16_t type;
-  (void)mData.ObjectAt(aIndex)->GetDataType(&type);
+  uint16_t type = mData.ObjectAt(aIndex)->GetDataType();
   *_isNull = type == nsIDataType::VTYPE_EMPTY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Row::GetSharedUTF8String(uint32_t,
                          uint32_t *,
                          char const **)
--- a/storage/variantToSQLiteT_impl.h
+++ b/storage/variantToSQLiteT_impl.h
@@ -16,18 +16,17 @@ template <typename T>
 int
 variantToSQLiteT(T aObj,
                  nsIVariant *aValue)
 {
   // Allow to return nullptr not wrapped to nsIVariant for speed.
   if (!aValue)
     return sqlite3_T_null(aObj);
 
-  uint16_t valueType;
-  aValue->GetDataType(&valueType);
+  uint16_t valueType = aValue->GetDataType();
   switch (valueType) {
     case nsIDataType::VTYPE_INT8:
     case nsIDataType::VTYPE_INT16:
     case nsIDataType::VTYPE_INT32:
     case nsIDataType::VTYPE_UINT8:
     case nsIDataType::VTYPE_UINT16:
     {
       int32_t value;
--- a/toolkit/components/places/nsAnnotationService.cpp
+++ b/toolkit/components/places/nsAnnotationService.cpp
@@ -136,76 +136,74 @@ nsAnnotationService::SetItemAnnotation(i
                                        uint16_t aSource,
                                        bool aDontUpdateLastModified)
 {
   AUTO_PROFILER_LABEL("nsAnnotationService::SetItemAnnotation", OTHER);
 
   NS_ENSURE_ARG_MIN(aItemId, 1);
   NS_ENSURE_ARG(aValue);
 
-  uint16_t dataType;
-  nsresult rv = aValue->GetDataType(&dataType);
-  NS_ENSURE_SUCCESS(rv, rv);
+  uint16_t dataType = aValue->GetDataType();
   BookmarkData bookmark;
 
   switch (dataType) {
     case nsIDataType::VTYPE_INT8:
     case nsIDataType::VTYPE_UINT8:
     case nsIDataType::VTYPE_INT16:
     case nsIDataType::VTYPE_UINT16:
     case nsIDataType::VTYPE_INT32:
     case nsIDataType::VTYPE_UINT32:
     case nsIDataType::VTYPE_BOOL: {
       int32_t valueInt;
-      rv = aValue->GetAsInt32(&valueInt);
+      nsresult rv = aValue->GetAsInt32(&valueInt);
       if (NS_SUCCEEDED(rv)) {
         NS_ENSURE_SUCCESS(rv, rv);
         rv = SetAnnotationInt32Internal(aItemId, &bookmark, aName,
                                         valueInt, aFlags, aExpiration);
         NS_ENSURE_SUCCESS(rv, rv);
         break;
       }
       // Fall through int64_t case otherwise.
       MOZ_FALLTHROUGH;
     }
     case nsIDataType::VTYPE_INT64:
     case nsIDataType::VTYPE_UINT64: {
       int64_t valueLong;
-      rv = aValue->GetAsInt64(&valueLong);
+      nsresult rv = aValue->GetAsInt64(&valueLong);
       if (NS_SUCCEEDED(rv)) {
         NS_ENSURE_SUCCESS(rv, rv);
         rv = SetAnnotationInt64Internal(aItemId, &bookmark, aName,
                                         valueLong, aFlags, aExpiration);
         NS_ENSURE_SUCCESS(rv, rv);
         break;
       }
       // Fall through double case otherwise.
       MOZ_FALLTHROUGH;
     }
     case nsIDataType::VTYPE_FLOAT:
     case nsIDataType::VTYPE_DOUBLE: {
       double valueDouble;
-      rv = aValue->GetAsDouble(&valueDouble);
+      nsresult rv = aValue->GetAsDouble(&valueDouble);
       NS_ENSURE_SUCCESS(rv, rv);
       rv = SetAnnotationDoubleInternal(aItemId, &bookmark,
                                        aName, valueDouble, aFlags, aExpiration);
       NS_ENSURE_SUCCESS(rv, rv);
       break;
     }
     case nsIDataType::VTYPE_CHAR:
     case nsIDataType::VTYPE_WCHAR:
     case nsIDataType::VTYPE_CHAR_STR:
     case nsIDataType::VTYPE_WCHAR_STR:
     case nsIDataType::VTYPE_STRING_SIZE_IS:
     case nsIDataType::VTYPE_WSTRING_SIZE_IS:
     case nsIDataType::VTYPE_UTF8STRING:
     case nsIDataType::VTYPE_CSTRING:
     case nsIDataType::VTYPE_ASTRING: {
       nsAutoString stringValue;
-      rv = aValue->GetAsAString(stringValue);
+      nsresult rv = aValue->GetAsAString(stringValue);
       NS_ENSURE_SUCCESS(rv, rv);
       rv = SetAnnotationStringInternal(aItemId, &bookmark, aName,
                                        stringValue, aFlags, aExpiration);
       NS_ENSURE_SUCCESS(rv, rv);
       break;
     }
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
--- a/toolkit/components/places/nsNavHistoryQuery.cpp
+++ b/toolkit/components/places/nsNavHistoryQuery.cpp
@@ -845,18 +845,17 @@ NS_IMETHODIMP nsNavHistoryQuery::GetTags
   out.forget(aTags);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsNavHistoryQuery::SetTags(nsIVariant *aTags)
 {
   NS_ENSURE_ARG(aTags);
 
-  uint16_t dataType;
-  aTags->GetDataType(&dataType);
+  uint16_t dataType = aTags->GetDataType();
 
   // Caller passed in empty array.  Easy -- clear our mTags array and return.
   if (dataType == nsIDataType::VTYPE_EMPTY_ARRAY) {
     mTags.Clear();
     return NS_OK;
   }
 
   // Before we go any further, make sure caller passed in an array.
--- a/toolkit/components/telemetry/core/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/core/TelemetryScalar.cpp
@@ -479,18 +479,17 @@ ScalarUnsigned::SizeOfIncludingThis(mozi
 {
   return aMallocSizeOf(this);
 }
 
 ScalarResult
 ScalarUnsigned::CheckInput(nsIVariant* aValue)
 {
   // If this is a floating point value/double, we will probably get truncated.
-  uint16_t type;
-  aValue->GetDataType(&type);
+  uint16_t type = aValue->GetDataType();
   if (type == nsIDataType::VTYPE_FLOAT ||
       type == nsIDataType::VTYPE_DOUBLE) {
     return ScalarResult::UnsignedTruncatedValue;
   }
 
   int32_t signedTest;
   // If we're able to cast the number to an int, check its sign.
   // Warn the user if he's trying to set the unsigned scalar to a negative
@@ -525,18 +524,17 @@ private:
   ScalarString(const ScalarString& aOther) = delete;
   void operator=(const ScalarString& aOther) = delete;
 };
 
 ScalarResult
 ScalarString::SetValue(nsIVariant* aValue)
 {
   // Check that we got the correct data type.
-  uint16_t type;
-  aValue->GetDataType(&type);
+  uint16_t type = aValue->GetDataType();
   if (type != nsIDataType::VTYPE_CHAR &&
       type != nsIDataType::VTYPE_WCHAR &&
       type != nsIDataType::VTYPE_CHAR_STR &&
       type != nsIDataType::VTYPE_WCHAR_STR &&
       type != nsIDataType::VTYPE_STRING_SIZE_IS &&
       type != nsIDataType::VTYPE_WSTRING_SIZE_IS &&
       type != nsIDataType::VTYPE_UTF8STRING &&
       type != nsIDataType::VTYPE_CSTRING &&
@@ -605,18 +603,17 @@ private:
   ScalarBoolean(const ScalarBoolean& aOther) = delete;
   void operator=(const ScalarBoolean& aOther) = delete;
 };
 
 ScalarResult
 ScalarBoolean::SetValue(nsIVariant* aValue)
 {
   // Check that we got the correct data type.
-  uint16_t type;
-  aValue->GetDataType(&type);
+  uint16_t type = aValue->GetDataType();
   if (type != nsIDataType::VTYPE_BOOL &&
       type != nsIDataType::VTYPE_INT8 &&
       type != nsIDataType::VTYPE_INT16 &&
       type != nsIDataType::VTYPE_INT32 &&
       type != nsIDataType::VTYPE_INT64 &&
       type != nsIDataType::VTYPE_UINT8 &&
       type != nsIDataType::VTYPE_UINT16 &&
       type != nsIDataType::VTYPE_UINT32 &&
--- a/widget/android/PrefsHelper.h
+++ b/widget/android/PrefsHelper.h
@@ -27,20 +27,17 @@ class PrefsHelper
                                jni::Object::Param aPrefHandler,
                                const jni::String::LocalRef& aPrefName)
     {
         if (NS_FAILED(aObsServ->NotifyObservers(aVariant, "android-get-pref",
                                                 aPrefName->ToString().get()))) {
             return false;
         }
 
-        uint16_t varType = nsIDataType::VTYPE_EMPTY;
-        if (NS_FAILED(aVariant->GetDataType(&varType))) {
-            return false;
-        }
+        uint16_t varType = aVariant->GetDataType();
 
         int32_t type = java::PrefsHelper::PREF_INVALID;
         bool boolVal = false;
         int32_t intVal = 0;
         nsAutoString strVal;
 
         switch (varType) {
             case nsIDataType::VTYPE_BOOL:
@@ -105,17 +102,17 @@ class PrefsHelper
 
         if (NS_SUCCEEDED(rv)) {
             rv = aObsServ->NotifyObservers(aVariant, "android-set-pref",
                                            aPrefName->ToString().get());
         }
 
         uint16_t varType = nsIDataType::VTYPE_EMPTY;
         if (NS_SUCCEEDED(rv)) {
-            rv = aVariant->GetDataType(&varType);
+            varType = aVariant->GetDataType();
         }
 
         // We use set-to-empty to signal the pref was handled.
         const bool handled = varType == nsIDataType::VTYPE_EMPTY;
 
         if (NS_SUCCEEDED(rv) && handled && aFlush) {
             rv = Preferences::GetService()->SavePrefFile(nullptr);
         }
--- a/xpcom/ds/nsIVariant.idl
+++ b/xpcom/ds/nsIVariant.idl
@@ -59,17 +59,17 @@ struct nsIDataType
  * that refer to this interface. But we mark all the methods and attributes
  * [noscript] since any nsIVariant object will be automatically converted to a
  * JS type anyway.
  */
 
 [scriptable, uuid(81e4c2de-acac-4ad6-901a-b5fb1b851a0d)]
 interface nsIVariant : nsISupports
 {
-    [noscript] readonly attribute uint16_t     dataType;
+    [notxpcom,nostdcall] readonly attribute uint16_t     dataType;
 
     [noscript] uint8_t      getAsInt8();
     [noscript] int16_t      getAsInt16();
     [noscript] int32_t      getAsInt32();
     [noscript] int64_t      getAsInt64();
     [noscript] uint8_t      getAsUint8();
     [noscript] uint16_t     getAsUint16();
     [noscript] uint32_t     getAsUint32();
--- a/xpcom/ds/nsVariant.cpp
+++ b/xpcom/ds/nsVariant.cpp
@@ -1203,25 +1203,21 @@ nsDiscriminatedUnion::ConvertToArray(uin
         CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(type_)                          \
         CASE__SET_FROM_VARIANT_VTYPE__GETTER_CAST(cast_, member_, name_)      \
         CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(type_)
 
 
 nsresult
 nsDiscriminatedUnion::SetFromVariant(nsIVariant* aValue)
 {
-  uint16_t type;
-  nsresult rv;
+  nsresult rv = NS_OK;
 
   Cleanup();
 
-  rv = aValue->GetDataType(&type);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
+  uint16_t type = aValue->GetDataType();
 
   switch (type) {
     CASE__SET_FROM_VARIANT_VTYPE_CAST(VTYPE_INT8, (uint8_t*), mInt8Value,
                                       Int8)
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_INT16,  mInt16Value,  Int16)
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_INT32,  mInt32Value,  Int32)
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_UINT8,  mUint8Value,  Uint8)
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_UINT16, mUint16Value, Uint16)
@@ -1612,21 +1608,20 @@ nsDiscriminatedUnion::Traverse(nsCycleCo
 nsVariantBase::nsVariantBase()
   : mWritable(true)
 {
 }
 
 // For all the data getters we just forward to the static (and sharable)
 // 'ConvertTo' functions.
 
-NS_IMETHODIMP
-nsVariantBase::GetDataType(uint16_t* aDataType)
+uint16_t
+nsVariantBase::GetDataType()
 {
-  *aDataType = mData.GetType();
-  return NS_OK;
+  return mData.GetType();
 }
 
 NS_IMETHODIMP
 nsVariantBase::GetAsInt8(uint8_t* aResult)
 {
   return mData.ConvertToInt8(aResult);
 }