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:49 +0000
changeset 2516012 c679577dc37b84ff52c7fc692aeb9f9d1f940f6f
parent 2516011 67b0bd471d0ebea32b9a5815dad4edff09de64dd
child 2516013 523c4009debcfbb645144054a3388db080d84946
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/D55517 Differential Diff: PHID-DIFF-46z7zzuscfzmwlq2hd3t
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IDBFactory.h
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -152,18 +152,18 @@ nsresult IDBFactory::CreateForWindow(nsP
     if (rv == NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR) {
       IDB_REPORT_INTERNAL_ERR();
     }
     return rv;
   }
 
   MOZ_ASSERT(principal);
 
-  nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo());
-  rv = PrincipalToPrincipalInfo(principal, principalInfo);
+  auto principalInfo = MakeUnique<PrincipalInfo>();
+  rv = PrincipalToPrincipalInfo(principal, principalInfo.get());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   MOZ_ASSERT(principalInfo->type() == PrincipalInfo::TContentPrincipalInfo ||
              principalInfo->type() == PrincipalInfo::TSystemPrincipalInfo);
 
@@ -198,34 +198,35 @@ nsresult IDBFactory::CreateForMainThread
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aGlobal);
 
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aGlobal);
   if (NS_WARN_IF(!sop)) {
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo());
+  auto principalInfo = MakeUnique<PrincipalInfo>();
   nsIPrincipal* principal = sop->GetEffectiveStoragePrincipal();
   MOZ_ASSERT(principal);
   bool isSystem;
   if (!AllowedForPrincipal(principal, &isSystem)) {
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  nsresult rv = PrincipalToPrincipalInfo(principal, principalInfo);
+  nsresult rv = PrincipalToPrincipalInfo(principal, principalInfo.get());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  rv = CreateForMainThreadJSInternal(aGlobal, principalInfo, aFactory);
+  rv = CreateForMainThreadJSInternal(aGlobal, std::move(principalInfo),
+                                     aFactory);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   MOZ_ASSERT(!principalInfo);
 
   return NS_OK;
 }
@@ -234,29 +235,29 @@ nsresult IDBFactory::CreateForMainThread
 nsresult IDBFactory::CreateForWorker(nsIGlobalObject* aGlobal,
                                      const PrincipalInfo& aPrincipalInfo,
                                      uint64_t aInnerWindowID,
                                      IDBFactory** aFactory) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(aGlobal);
   MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None);
 
-  nsresult rv = CreateInternal(
-      aGlobal, nsAutoPtr<PrincipalInfo>(new PrincipalInfo(aPrincipalInfo)),
-      aInnerWindowID, aFactory);
+  nsresult rv =
+      CreateInternal(aGlobal, MakeUnique<PrincipalInfo>(aPrincipalInfo),
+                     aInnerWindowID, aFactory);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 // static
 nsresult IDBFactory::CreateForMainThreadJSInternal(
-    nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo> aPrincipalInfo,
+    nsIGlobalObject* aGlobal, UniquePtr<PrincipalInfo> aPrincipalInfo,
     IDBFactory** aFactory) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aGlobal);
   MOZ_ASSERT(aPrincipalInfo);
 
   IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
   if (NS_WARN_IF(!mgr)) {
     IDB_REPORT_INTERNAL_ERR();
@@ -269,17 +270,17 @@ nsresult IDBFactory::CreateForMainThread
     return rv;
   }
 
   return NS_OK;
 }
 
 // static
 nsresult IDBFactory::CreateInternal(nsIGlobalObject* aGlobal,
-                                    nsAutoPtr<PrincipalInfo> aPrincipalInfo,
+                                    UniquePtr<PrincipalInfo> aPrincipalInfo,
                                     uint64_t aInnerWindowID,
                                     IDBFactory** aFactory) {
   MOZ_ASSERT(aGlobal);
   MOZ_ASSERT(aPrincipalInfo);
   MOZ_ASSERT(aPrincipalInfo->type() != PrincipalInfo::T__None);
   MOZ_ASSERT(aFactory);
 
   if (aPrincipalInfo->type() != PrincipalInfo::TContentPrincipalInfo &&
--- a/dom/indexedDB/IDBFactory.h
+++ b/dom/indexedDB/IDBFactory.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_idbfactory_h__
 #define mozilla_dom_idbfactory_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/StorageTypeBinding.h"
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 
 class nsIGlobalObject;
@@ -52,17 +52,17 @@ class LoggingInfo;
 class IDBFactory final : public nsISupports, public nsWrapperCache {
   typedef mozilla::dom::StorageType StorageType;
   typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
   typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
 
   class BackgroundCreateCallback;
   struct PendingRequestInfo;
 
-  nsAutoPtr<PrincipalInfo> mPrincipalInfo;
+  UniquePtr<PrincipalInfo> mPrincipalInfo;
 
   nsCOMPtr<nsIGlobalObject> mGlobal;
 
   // This will only be set if the factory belongs to a window in a child
   // process.
   RefPtr<BrowserChild> mBrowserChild;
 
   indexedDB::BackgroundFactoryChild* mBackgroundActor;
@@ -125,17 +125,17 @@ class IDBFactory final : public nsISuppo
 
   nsIGlobalObject* GetParentObject() const { return mGlobal; }
 
   BrowserChild* GetBrowserChild() const { return mBrowserChild; }
 
   PrincipalInfo* GetPrincipalInfo() const {
     AssertIsOnOwningThread();
 
-    return mPrincipalInfo;
+    return mPrincipalInfo.get();
   }
 
   uint64_t InnerWindowID() const {
     AssertIsOnOwningThread();
 
     return mInnerWindowID;
   }
 
@@ -183,21 +183,21 @@ class IDBFactory final : public nsISuppo
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
  private:
   IDBFactory();
   ~IDBFactory();
 
   static nsresult CreateForMainThreadJSInternal(
-      nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo> aPrincipalInfo,
+      nsIGlobalObject* aGlobal, UniquePtr<PrincipalInfo> aPrincipalInfo,
       IDBFactory** aFactory);
 
   static nsresult CreateInternal(nsIGlobalObject* aGlobal,
-                                 nsAutoPtr<PrincipalInfo> aPrincipalInfo,
+                                 UniquePtr<PrincipalInfo> aPrincipalInfo,
                                  uint64_t aInnerWindowID,
                                  IDBFactory** aFactory);
 
   static nsresult AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
                                            nsCOMPtr<nsIPrincipal>* aPrincipal);
 
   MOZ_MUST_USE RefPtr<IDBOpenDBRequest> OpenInternal(
       JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,