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:57 +0000
changeset 2516014 c297c9a86fb2539cb8dc604c396b2ee075cf1fad
parent 2516013 523c4009debcfbb645144054a3388db080d84946
child 2516015 862631621172218e0152aa07d319c00b7abe3e03
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/D55519 Differential Diff: PHID-DIFF-qs4ggphqmmrg3fskx3xu
dom/indexedDB/IDBObjectStore.cpp
dom/indexedDB/IDBObjectStore.h
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -2411,17 +2411,17 @@ RefPtr<IDBRequest> IDBObjectStore::OpenC
 
   mTransaction->OpenCursor(actor, params);
 
   return request;
 }
 
 void IDBObjectStore::RefreshSpec(bool aMayDelete) {
   AssertIsOnOwningThread();
-  MOZ_ASSERT_IF(mDeletedSpec, mSpec == mDeletedSpec);
+  MOZ_ASSERT_IF(mDeletedSpec, mSpec == mDeletedSpec.get());
 
   const DatabaseSpec* dbSpec = mTransaction->Database()->Spec();
   MOZ_ASSERT(dbSpec);
 
   const nsTArray<ObjectStoreSpec>& objectStores = dbSpec->objectStores();
 
   const auto foundIt = std::find_if(objectStores.cbegin(), objectStores.cend(),
                                     [id = Id()](const auto& objSpec) {
@@ -2438,17 +2438,17 @@ void IDBObjectStore::RefreshSpec(bool aM
     for (auto& index : mDeletedIndexes) {
       index->RefreshMetadata(false);
     }
   }
 
   MOZ_ASSERT_IF(!aMayDelete && !mDeletedSpec, found);
 
   if (found) {
-    MOZ_ASSERT(mSpec != mDeletedSpec);
+    MOZ_ASSERT(mSpec != mDeletedSpec.get());
     mDeletedSpec = nullptr;
   } else {
     NoteDeletion();
   }
 }
 
 const ObjectStoreSpec& IDBObjectStore::Spec() const {
   AssertIsOnOwningThread();
@@ -2458,25 +2458,25 @@ const ObjectStoreSpec& IDBObjectStore::S
 }
 
 void IDBObjectStore::NoteDeletion() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mSpec);
   MOZ_ASSERT(Id() == mSpec->metadata().id());
 
   if (mDeletedSpec) {
-    MOZ_ASSERT(mDeletedSpec == mSpec);
+    MOZ_ASSERT(mDeletedSpec.get() == mSpec);
     return;
   }
 
   // Copy the spec here.
-  mDeletedSpec = new ObjectStoreSpec(*mSpec);
+  mDeletedSpec = MakeUnique<ObjectStoreSpec>(*mSpec);
   mDeletedSpec->indexes().Clear();
 
-  mSpec = mDeletedSpec;
+  mSpec = mDeletedSpec.get();
 
   for (const auto& index : mIndexes) {
     index->NoteDeletion();
   }
 }
 
 const nsString& IDBObjectStore::Name() const {
   AssertIsOnOwningThread();
--- a/dom/indexedDB/IDBObjectStore.h
+++ b/dom/indexedDB/IDBObjectStore.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_idbobjectstore_h__
 #define mozilla_dom_idbobjectstore_h__
 
 #include "js/RootingAPI.h"
 #include "mozilla/dom/IDBCursorBinding.h"
 #include "mozilla/dom/IDBIndexBinding.h"
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 
 struct JSClass;
 class nsIGlobalObject;
@@ -59,17 +59,17 @@ class IDBObjectStore final : public nsIS
   RefPtr<IDBTransaction> mTransaction;
   JS::Heap<JS::Value> mCachedKeyPath;
 
   // This normally points to the ObjectStoreSpec owned by the parent IDBDatabase
   // object. However, if this objectStore is part of a versionchange transaction
   // and it gets deleted then the spec is copied into mDeletedSpec and mSpec is
   // set to point at mDeletedSpec.
   const ObjectStoreSpec* mSpec;
-  nsAutoPtr<ObjectStoreSpec> mDeletedSpec;
+  UniquePtr<ObjectStoreSpec> mDeletedSpec;
 
   nsTArray<RefPtr<IDBIndex>> mIndexes;
   nsTArray<RefPtr<IDBIndex>> mDeletedIndexes;
 
   const int64_t mId;
   bool mRooted;
 
  public: