Bug 1210591, part 1 - Use nsVariantCC in various places. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Fri, 09 Oct 2015 10:24:23 -0700
changeset 300542 8f665fef765b1c94fcf3ffbe352ee6efc84051cf
parent 300541 465a87f5d4e66dc4af42e0d9a7cbb92d40c0ca88
child 300543 9df7af61aff8a534a6462cd6e7dae5cbeadd62ad
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1210591
milestone44.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 1210591, part 1 - Use nsVariantCC in various places. r=smaug Most of these will end up in DataTransfer:mItems, so this is needed for it to do anything useful.
dom/base/nsContentAreaDragDrop.cpp
dom/base/nsGlobalWindow.cpp
dom/events/DataTransfer.cpp
dom/html/HTMLInputElement.cpp
dom/html/TextTrackManager.cpp
dom/ipc/ContentChild.cpp
dom/ipc/TabParent.cpp
dom/media/MediaManager.cpp
--- a/dom/base/nsContentAreaDragDrop.cpp
+++ b/dom/base/nsContentAreaDragDrop.cpp
@@ -722,17 +722,17 @@ DragDataProducer::Produce(DataTransfer* 
 }
 
 void
 DragDataProducer::AddString(DataTransfer* aDataTransfer,
                             const nsAString& aFlavor,
                             const nsAString& aData,
                             nsIPrincipal* aPrincipal)
 {
-  nsRefPtr<nsVariant> variant = new nsVariant();
+  nsRefPtr<nsVariantCC> variant = new nsVariantCC();
   variant->SetAsAString(aData);
   aDataTransfer->SetDataWithPrincipal(aFlavor, variant, 0, aPrincipal);
 }
 
 nsresult
 DragDataProducer::AddStringsToDataTransfer(nsIContent* aDragNode,
                                            DataTransfer* aDataTransfer)
 {
@@ -778,29 +778,29 @@ DragDataProducer::AddStringsToDataTransf
   AddString(aDataTransfer, NS_LITERAL_STRING(kTextMime),
             mIsAnchor ? mUrlString : mTitleString, principal);
 
   // add image data, if present. For now, all we're going to do with
   // this is turn it into a native data flavor, so indicate that with
   // a new flavor so as not to confuse anyone who is really registered
   // for image/gif or image/jpg.
   if (mImage) {
-    nsRefPtr<nsVariant> variant = new nsVariant();
+    nsRefPtr<nsVariantCC> variant = new nsVariantCC();
     variant->SetAsISupports(mImage);
     aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kNativeImageMime),
                                         variant, 0, principal);
 
     // assume the image comes from a file, and add a file promise. We
     // register ourselves as a nsIFlavorDataProvider, and will use the
     // GetFlavorData callback to save the image to disk.
 
     nsCOMPtr<nsIFlavorDataProvider> dataProvider =
       new nsContentAreaDragDropDataProvider();
     if (dataProvider) {
-      nsRefPtr<nsVariant> variant = new nsVariant();
+      nsRefPtr<nsVariantCC> variant = new nsVariantCC();
       variant->SetAsISupports(dataProvider);
       aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kFilePromiseMime),
                                           variant, 0, principal);
     }
 
     AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseURLMime),
               mImageSourceString, principal);
     AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseDestFilename),
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -558,17 +558,17 @@ bool
 nsTimeout::HasRefCntOne()
 {
   return mRefCnt.get() == 1;
 }
 
 static already_AddRefed<nsIVariant>
 CreateVoidVariant()
 {
-  nsRefPtr<nsVariant> writable = new nsVariant();
+  nsRefPtr<nsVariantCC> writable = new nsVariantCC();
   writable->SetAsVoid();
   return writable.forget();
 }
 
 nsresult
 DialogValueHolder::Get(nsIPrincipal* aSubject, nsIVariant** aResult)
 {
   nsCOMPtr<nsIVariant> result;
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -430,17 +430,17 @@ DataTransfer::GetData(const nsAString& a
   GetData(aFormat, aData, rv);
   return rv.StealNSResult();
 }
 
 void
 DataTransfer::SetData(const nsAString& aFormat, const nsAString& aData,
                       ErrorResult& aRv)
 {
-  nsRefPtr<nsVariant> variant = new nsVariant();
+  nsRefPtr<nsVariantCC> variant = new nsVariantCC();
   variant->SetAsAString(aData);
 
   aRv = MozSetDataAt(aFormat, variant, 0);
 }
 
 NS_IMETHODIMP
 DataTransfer::SetData(const nsAString& aFormat, const nsAString& aData)
 {
@@ -1340,17 +1340,17 @@ DataTransfer::FillInExternalData(Transfe
   }
 
     uint32_t length = 0;
     nsCOMPtr<nsISupports> data;
     trans->GetTransferData(format, getter_AddRefs(data), &length);
     if (!data)
       return;
 
-    nsRefPtr<nsVariant> variant = new nsVariant();
+    nsRefPtr<nsVariantCC> variant = new nsVariantCC();
 
     nsCOMPtr<nsISupportsString> supportsstr = do_QueryInterface(data);
     if (supportsstr) {
       nsAutoString str;
       supportsstr->GetData(str);
       variant->SetAsAString(str);
     }
     else {
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -803,17 +803,17 @@ UploadLastDir::StoreLastUsedDirectory(ns
   docURI->GetSpec(cstrSpec);
   NS_ConvertUTF8toUTF16 spec(cstrSpec);
 
   // Find the parent of aFile, and store it
   nsString unicodePath;
   aDir->GetPath(unicodePath);
   if (unicodePath.IsEmpty()) // nothing to do
     return NS_OK;
-  nsRefPtr<nsVariant> prefValue = new nsVariant();
+  nsRefPtr<nsVariantCC> prefValue = new nsVariantCC();
   prefValue->SetAsAString(unicodePath);
 
   // Use the document's current load context to ensure that the content pref
   // service doesn't persistently store this directory for this domain if the
   // user is using private browsing:
   nsCOMPtr<nsILoadContext> loadContext = aDoc->GetLoadContext();
   return contentPrefService->Set(spec, CPS_PREF_NAME, prefValue, loadContext, nullptr);
 }
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -210,17 +210,17 @@ TextTrackManager::UpdateCueDisplay()
   if (!overlay) {
     return;
   }
 
   nsTArray<nsRefPtr<TextTrackCue> > activeCues;
   mTextTracks->UpdateAndGetShowingCues(activeCues);
 
   if (activeCues.Length() > 0) {
-    nsRefPtr<nsVariant> jsCues = new nsVariant();
+    nsRefPtr<nsVariantCC> jsCues = new nsVariantCC();
 
     jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE,
                        &NS_GET_IID(nsIDOMEventTarget),
                        activeCues.Length(),
                        static_cast<void*>(activeCues.Elements()));
 
     nsPIDOMWindow* window = mMediaElement->OwnerDoc()->GetWindow();
     if (window) {
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2872,17 +2872,17 @@ ContentChild::RecvInvokeDragSession(nsTA
     if (session) {
       session->SetDragAction(aAction);
       nsCOMPtr<DataTransfer> dataTransfer =
         new DataTransfer(nullptr, eDragStart, false, -1);
       for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
         auto& items = aTransfers[i].items();
         for (uint32_t j = 0; j < items.Length(); ++j) {
           const IPCDataTransferItem& item = items[j];
-          nsRefPtr<nsVariant> variant = new nsVariant();
+          nsRefPtr<nsVariantCC> variant = new nsVariantCC();
           if (item.data().type() == IPCDataTransferData::TnsString) {
             const nsString& data = item.data().get_nsString();
             variant->SetAsAString(data);
           } else if (item.data().type() == IPCDataTransferData::TPBlobChild) {
             BlobChild* blob = static_cast<BlobChild*>(item.data().get_PBlobChild());
             nsRefPtr<BlobImpl> blobImpl = blob->GetBlobImpl();
             variant->SetAsISupports(blobImpl);
           } else {
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3583,17 +3583,17 @@ TabParent::RecvInvokeDragSession(nsTArra
 
 void
 TabParent::AddInitialDnDDataTo(DataTransfer* aDataTransfer)
 {
   for (uint32_t i = 0; i < mInitialDataTransferItems.Length(); ++i) {
     nsTArray<DataTransferItem>& itemArray = mInitialDataTransferItems[i];
     for (uint32_t j = 0; j < itemArray.Length(); ++j) {
       DataTransferItem& item = itemArray[j];
-      nsRefPtr<nsVariant> variant = new nsVariant();
+      nsRefPtr<nsVariantCC> variant = new nsVariantCC();
       // Special case kFilePromiseMime so that we get the right
       // nsIFlavorDataProvider for it.
       if (item.mFlavor.EqualsLiteral(kFilePromiseMime)) {
         nsRefPtr<nsISupports> flavorDataProvider =
           new nsContentAreaDragDropDataProvider();
         variant->SetAsISupports(flavorDataProvider);
       } else if (item.mType == DataTransferItem::DataType::eString) {
         variant->SetAsAString(item.mStringData);
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2199,17 +2199,18 @@ MediaManager::AnonymizeId(nsAString& aId
   aId = NS_ConvertUTF8toUTF16(mac);
   return NS_OK;
 }
 
 /* static */
 already_AddRefed<nsIWritableVariant>
 MediaManager::ToJSArray(SourceSet& aDevices)
 {
-  nsRefPtr<nsVariant> var = new nsVariant();
+  MOZ_ASSERT(NS_IsMainThread());
+  nsRefPtr<nsVariantCC> var = new nsVariantCC();
   size_t len = aDevices.Length();
   if (len) {
     nsTArray<nsIMediaDevice*> tmp(len);
     for (auto& device : aDevices) {
       tmp.AppendElement(device);
     }
     auto* elements = static_cast<const void*>(tmp.Elements());
     nsresult rv = var->SetAsArray(nsIDataType::VTYPE_INTERFACE,