Bug 1600283 - Replaced use of nsAutoPtr by UniquePtr. r=#dom-workers-and-storage draft
authorSimon Giesecke <sgiesecke@mozilla.com>
Wed, 04 Dec 2019 16:50:53 +0000
changeset 2516013 523c4009debcfbb645144054a3388db080d84946
parent 2516012 c679577dc37b84ff52c7fc692aeb9f9d1f940f6f
child 2516014 c297c9a86fb2539cb8dc604c396b2ee075cf1fad
push id460090
push userreviewbot
push dateWed, 04 Dec 2019 16:51:29 +0000
treeherdertry@35d310cdd9cf [default view] [failures only]
bugs1600283
milestone73.0a1
Bug 1600283 - Replaced use of nsAutoPtr by UniquePtr. r=#dom-workers-and-storage Differential Revision: https://phabricator.services.mozilla.com/D55518 Differential Diff: PHID-DIFF-kif65motsnjbcqincrob
dom/indexedDB/IDBIndex.cpp
dom/indexedDB/IDBIndex.h
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -125,48 +125,48 @@ RefPtr<IDBRequest> IDBIndex::GetAllKeys(
                                         ErrorResult& aRv) {
   AssertIsOnOwningThread();
 
   return GetAllInternal(/* aKeysOnly */ true, aCx, aKey, aLimit, aRv);
 }
 
 void IDBIndex::RefreshMetadata(bool aMayDelete) {
   AssertIsOnOwningThread();
-  MOZ_ASSERT_IF(mDeletedMetadata, mMetadata == mDeletedMetadata);
+  MOZ_ASSERT_IF(mDeletedMetadata, mMetadata == mDeletedMetadata.get());
 
   const auto& indexes = mObjectStore->Spec().indexes();
   const auto foundIt = std::find_if(
       indexes.cbegin(), indexes.cend(),
       [id = Id()](const auto& metadata) { return metadata.id() == id; });
   const bool found = foundIt != indexes.cend();
 
   MOZ_ASSERT_IF(!aMayDelete && !mDeletedMetadata, found);
 
   if (found) {
     mMetadata = &*foundIt;
-    MOZ_ASSERT(mMetadata != mDeletedMetadata);
+    MOZ_ASSERT(mMetadata != mDeletedMetadata.get());
     mDeletedMetadata = nullptr;
   } else {
     NoteDeletion();
   }
 }
 
 void IDBIndex::NoteDeletion() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
   MOZ_ASSERT(Id() == mMetadata->id());
 
   if (mDeletedMetadata) {
-    MOZ_ASSERT(mMetadata == mDeletedMetadata);
+    MOZ_ASSERT(mMetadata == mDeletedMetadata.get());
     return;
   }
 
-  mDeletedMetadata = new IndexMetadata(*mMetadata);
+  mDeletedMetadata = MakeUnique<IndexMetadata>(*mMetadata);
 
-  mMetadata = mDeletedMetadata;
+  mMetadata = mDeletedMetadata.get();
 }
 
 const nsString& IDBIndex::Name() const {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
 
   return mMetadata->name();
 }
--- a/dom/indexedDB/IDBIndex.h
+++ b/dom/indexedDB/IDBIndex.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_idbindex_h__
 #define mozilla_dom_idbindex_h__
 
 #include "js/RootingAPI.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/IDBCursorBinding.h"
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsWrapperCache.h"
 
 class nsIGlobalObject;
 
 namespace mozilla {
@@ -41,17 +41,17 @@ class IDBIndex final : public nsISupport
 
   JS::Heap<JS::Value> mCachedKeyPath;
 
   // This normally points to the IndexMetadata owned by the parent IDBDatabase
   // object. However, if this index is part of a versionchange transaction and
   // it gets deleted then the metadata is copied into mDeletedMetadata and
   // mMetadata is set to point at mDeletedMetadata.
   const indexedDB::IndexMetadata* mMetadata;
-  nsAutoPtr<indexedDB::IndexMetadata> mDeletedMetadata;
+  UniquePtr<indexedDB::IndexMetadata> mDeletedMetadata;
 
   const int64_t mId;
   bool mRooted;
 
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)