Bug 1600283 - Replaced use of nsAutoPtr by UniquePtr. r=#dom-workers-and-storage draft
authorSimon Giesecke <sgiesecke@mozilla.com>
Wed, 04 Dec 2019 16:51:02 +0000
changeset 2516015 862631621172218e0152aa07d319c00b7abe3e03
parent 2516014 c297c9a86fb2539cb8dc604c396b2ee075cf1fad
child 2516016 35d310cdd9cf6513ade7603a6b9998890430afe9
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/D55520 Differential Diff: PHID-DIFF-my6yfvan7pfbbm2wrmkh
dom/indexedDB/ActorsChild.cpp
dom/indexedDB/ActorsChild.h
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBDatabase.h
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -1779,17 +1779,17 @@ mozilla::ipc::IPCResult BackgroundFactor
 }
 
 /*******************************************************************************
  * BackgroundDatabaseChild
  ******************************************************************************/
 
 BackgroundDatabaseChild::BackgroundDatabaseChild(
     const DatabaseSpec& aSpec, BackgroundFactoryRequestChild* aOpenRequestActor)
-    : mSpec(new DatabaseSpec(aSpec)),
+    : mSpec(MakeUnique<DatabaseSpec>(aSpec)),
       mOpenRequestActor(aOpenRequestActor),
       mDatabase(nullptr) {
   // Can't assert owning thread here because IPDL has not yet set our manager!
   MOZ_ASSERT(aOpenRequestActor);
 
   MOZ_COUNT_CTOR(indexedDB::BackgroundDatabaseChild);
 }
 
@@ -1831,23 +1831,23 @@ void BackgroundDatabaseChild::EnsureDOMO
 
   auto request = mOpenRequestActor->GetOpenDBRequest();
   MOZ_ASSERT(request);
 
   auto factory =
       static_cast<BackgroundFactoryChild*>(Manager())->GetDOMObject();
   MOZ_ASSERT(factory);
 
-  mTemporaryStrongDatabase = IDBDatabase::Create(request, factory, this, mSpec);
+  mTemporaryStrongDatabase =
+      IDBDatabase::Create(request, factory, this, std::move(mSpec));
 
   MOZ_ASSERT(mTemporaryStrongDatabase);
   mTemporaryStrongDatabase->AssertIsOnOwningThread();
 
   mDatabase = mTemporaryStrongDatabase;
-  mSpec.forget();
 
   mOpenRequestActor->SetDatabaseActor(this);
 }
 
 void BackgroundDatabaseChild::ReleaseDOMObject() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mTemporaryStrongDatabase);
   mTemporaryStrongDatabase->AssertIsOnOwningThread();
--- a/dom/indexedDB/ActorsChild.h
+++ b/dom/indexedDB/ActorsChild.h
@@ -18,16 +18,17 @@
 #include "mozilla/dom/indexedDB/PBackgroundIDBRequestChild.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBTransactionChild.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBVersionChangeTransactionChild.h"
 #include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsChild.h"
 #include "mozilla/dom/PBackgroundFileHandleChild.h"
 #include "mozilla/dom/PBackgroundFileRequestChild.h"
 #include "mozilla/dom/PBackgroundMutableFileChild.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 
 class nsIEventTarget;
 struct nsID;
 
 namespace mozilla {
@@ -270,33 +271,33 @@ class BackgroundFactoryRequestChild fina
   mozilla::ipc::IPCResult RecvBlocked(const uint64_t& aCurrentVersion) override;
 };
 
 class BackgroundDatabaseChild final : public PBackgroundIDBDatabaseChild {
   friend class BackgroundFactoryChild;
   friend class BackgroundFactoryRequestChild;
   friend IDBDatabase;
 
-  nsAutoPtr<DatabaseSpec> mSpec;
+  UniquePtr<DatabaseSpec> mSpec;
   RefPtr<IDBDatabase> mTemporaryStrongDatabase;
   BackgroundFactoryRequestChild* mOpenRequestActor;
   IDBDatabase* mDatabase;
 
  public:
   void AssertIsOnOwningThread() const
 #ifdef DEBUG
       ;
 #else
   {
   }
 #endif
 
   const DatabaseSpec* Spec() const {
     AssertIsOnOwningThread();
-    return mSpec;
+    return mSpec.get();
   }
 
   IDBDatabase* GetDOMObject() const {
     AssertIsOnOwningThread();
     return mDatabase;
   }
 
   bool SendDeleteMe() = delete;
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -142,51 +142,53 @@ class IDBDatabase::Observer final : publ
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(!mWeakDatabase);
   }
 
   NS_DECL_NSIOBSERVER
 };
 
 IDBDatabase::IDBDatabase(IDBOpenDBRequest* aRequest, IDBFactory* aFactory,
-                         BackgroundDatabaseChild* aActor, DatabaseSpec* aSpec)
+                         BackgroundDatabaseChild* aActor,
+                         UniquePtr<DatabaseSpec> aSpec)
     : DOMEventTargetHelper(aRequest),
       mFactory(aFactory),
-      mSpec(aSpec),
+      mSpec(std::move(aSpec)),
       mBackgroundActor(aActor),
       mFileHandleDisabled(aRequest->IsFileHandleDisabled()),
       mClosed(false),
       mInvalidated(false),
       mQuotaExceeded(false),
       mIncreasedActiveDatabaseCount(false) {
   MOZ_ASSERT(aRequest);
   MOZ_ASSERT(aFactory);
   aFactory->AssertIsOnOwningThread();
   MOZ_ASSERT(aActor);
-  MOZ_ASSERT(aSpec);
+  MOZ_ASSERT(mSpec);
 }
 
 IDBDatabase::~IDBDatabase() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(!mBackgroundActor);
   MOZ_ASSERT(!mIncreasedActiveDatabaseCount);
 }
 
 // static
 RefPtr<IDBDatabase> IDBDatabase::Create(IDBOpenDBRequest* aRequest,
                                         IDBFactory* aFactory,
                                         BackgroundDatabaseChild* aActor,
-                                        DatabaseSpec* aSpec) {
+                                        UniquePtr<DatabaseSpec> aSpec) {
   MOZ_ASSERT(aRequest);
   MOZ_ASSERT(aFactory);
   aFactory->AssertIsOnOwningThread();
   MOZ_ASSERT(aActor);
   MOZ_ASSERT(aSpec);
 
-  RefPtr<IDBDatabase> db = new IDBDatabase(aRequest, aFactory, aActor, aSpec);
+  RefPtr<IDBDatabase> db =
+      new IDBDatabase(aRequest, aFactory, aActor, std::move(aSpec));
 
   if (NS_IsMainThread()) {
     nsCOMPtr<nsPIDOMWindowInner> window =
         do_QueryInterface(aFactory->GetParentObject());
     if (window) {
       uint64_t windowId = window->WindowID();
 
       RefPtr<Observer> observer = new Observer(db, windowId);
--- a/dom/indexedDB/IDBDatabase.h
+++ b/dom/indexedDB/IDBDatabase.h
@@ -85,17 +85,18 @@ class IDBDatabase final : public DOMEven
   bool mClosed;
   bool mInvalidated;
   bool mQuotaExceeded;
   bool mIncreasedActiveDatabaseCount;
 
  public:
   static MOZ_MUST_USE RefPtr<IDBDatabase> Create(
       IDBOpenDBRequest* aRequest, IDBFactory* aFactory,
-      indexedDB::BackgroundDatabaseChild* aActor, DatabaseSpec* aSpec);
+      indexedDB::BackgroundDatabaseChild* aActor,
+      UniquePtr<DatabaseSpec> aSpec);
 
   void AssertIsOnOwningThread() const
 #ifdef DEBUG
       ;
 #else
   {
   }
 #endif
@@ -235,17 +236,18 @@ class IDBDatabase final : public DOMEven
   virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
 
   // nsWrapperCache
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
  private:
   IDBDatabase(IDBOpenDBRequest* aRequest, IDBFactory* aFactory,
-              indexedDB::BackgroundDatabaseChild* aActor, DatabaseSpec* aSpec);
+              indexedDB::BackgroundDatabaseChild* aActor,
+              UniquePtr<DatabaseSpec> aSpec);
 
   ~IDBDatabase();
 
   void CloseInternal();
 
   void InvalidateInternal();
 
   bool RunningVersionChangeTransaction() const {