Bug 1600283 - Remove uses of already_AddRefed. r=#dom-workers-and-storage draft
authorSimon Giesecke <sgiesecke@mozilla.com>
Wed, 04 Dec 2019 16:49:00 +0000
changeset 2515991 dc781fa59f81642a387f9453dc0c3a8915b68891
parent 2515990 1d81b6d9f6c52e4ffb799a1942625f483975d987
child 2515992 a2684db102eae773bfac8f6ec11e36a6dc8bc0fd
push id460090
push userreviewbot
push dateWed, 04 Dec 2019 16:51:29 +0000
treeherdertry@35d310cdd9cf [default view] [failures only]
bugs1600283
milestone73.0a1
Bug 1600283 - Remove uses of already_AddRefed. r=#dom-workers-and-storage Differential Revision: https://phabricator.services.mozilla.com/D55495 Differential Diff: PHID-DIFF-6k7uvkhmi4ug2xe5uvtp
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IDBFactory.h
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -425,30 +425,32 @@ bool IDBFactory::IsChrome() const {
 
 void IDBFactory::IncrementParentLoggingRequestSerialNumber() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mBackgroundActor);
 
   mBackgroundActor->SendIncrementLoggingRequestSerialNumber();
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(JSContext* aCx,
-                                                    const nsAString& aName,
-                                                    uint64_t aVersion,
-                                                    CallerType aCallerType,
-                                                    ErrorResult& aRv) {
+RefPtr<IDBOpenDBRequest> IDBFactory::Open(JSContext* aCx,
+                                          const nsAString& aName,
+                                          uint64_t aVersion,
+                                          CallerType aCallerType,
+                                          ErrorResult& aRv) {
   return OpenInternal(aCx,
                       /* aPrincipal */ nullptr, aName,
                       Optional<uint64_t>(aVersion), Optional<StorageType>(),
                       /* aDeleting */ false, aCallerType, aRv);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(
-    JSContext* aCx, const nsAString& aName, const IDBOpenDBOptions& aOptions,
-    CallerType aCallerType, ErrorResult& aRv) {
+RefPtr<IDBOpenDBRequest> IDBFactory::Open(JSContext* aCx,
+                                          const nsAString& aName,
+                                          const IDBOpenDBOptions& aOptions,
+                                          CallerType aCallerType,
+                                          ErrorResult& aRv) {
   if (!IsChrome() && aOptions.mStorage.WasPassed()) {
     nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
     if (window && window->GetExtantDoc()) {
       window->GetExtantDoc()->WarnOnceAbout(
           Document::eIDBOpenDBOptions_StorageType);
     } else if (!NS_IsMainThread()) {
       // The method below reports on the main thread too, so we need to make
       // sure we're on a worker. Workers don't have a WarnOnceAbout mechanism,
@@ -468,17 +470,17 @@ already_AddRefed<IDBOpenDBRequest> IDBFa
   }
 
   return OpenInternal(aCx,
                       /* aPrincipal */ nullptr, aName, aOptions.mVersion,
                       aOptions.mStorage,
                       /* aDeleting */ false, aCallerType, aRv);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::DeleteDatabase(
+RefPtr<IDBOpenDBRequest> IDBFactory::DeleteDatabase(
     JSContext* aCx, const nsAString& aName, const IDBOpenDBOptions& aOptions,
     CallerType aCallerType, ErrorResult& aRv) {
   return OpenInternal(aCx,
                       /* aPrincipal */ nullptr, aName, Optional<uint64_t>(),
                       aOptions.mStorage,
                       /* aDeleting */ true, aCallerType, aRv);
 }
 
@@ -504,64 +506,64 @@ int16_t IDBFactory::Cmp(JSContext* aCx, 
   if (first.IsUnset() || second.IsUnset()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
     return 0;
   }
 
   return Key::CompareKeys(first, second);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenForPrincipal(
+RefPtr<IDBOpenDBRequest> IDBFactory::OpenForPrincipal(
     JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
     uint64_t aVersion, SystemCallerGuarantee aGuarantee, ErrorResult& aRv) {
   MOZ_ASSERT(aPrincipal);
   if (!NS_IsMainThread()) {
     MOZ_CRASH(
         "Figure out security checks for workers!  What's this aPrincipal "
         "we have on a worker thread?");
   }
 
   return OpenInternal(aCx, aPrincipal, aName, Optional<uint64_t>(aVersion),
                       Optional<StorageType>(),
                       /* aDeleting */ false, aGuarantee, aRv);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenForPrincipal(
+RefPtr<IDBOpenDBRequest> IDBFactory::OpenForPrincipal(
     JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
     const IDBOpenDBOptions& aOptions, SystemCallerGuarantee aGuarantee,
     ErrorResult& aRv) {
   MOZ_ASSERT(aPrincipal);
   if (!NS_IsMainThread()) {
     MOZ_CRASH(
         "Figure out security checks for workers!  What's this aPrincipal "
         "we have on a worker thread?");
   }
 
   return OpenInternal(aCx, aPrincipal, aName, aOptions.mVersion,
                       aOptions.mStorage,
                       /* aDeleting */ false, aGuarantee, aRv);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::DeleteForPrincipal(
+RefPtr<IDBOpenDBRequest> IDBFactory::DeleteForPrincipal(
     JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
     const IDBOpenDBOptions& aOptions, SystemCallerGuarantee aGuarantee,
     ErrorResult& aRv) {
   MOZ_ASSERT(aPrincipal);
   if (!NS_IsMainThread()) {
     MOZ_CRASH(
         "Figure out security checks for workers!  What's this aPrincipal "
         "we have on a worker thread?");
   }
 
   return OpenInternal(aCx, aPrincipal, aName, Optional<uint64_t>(),
                       aOptions.mStorage,
                       /* aDeleting */ true, aGuarantee, aRv);
 }
 
-already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
+RefPtr<IDBOpenDBRequest> IDBFactory::OpenInternal(
     JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
     const Optional<uint64_t>& aVersion,
     const Optional<StorageType>& aStorageType, bool aDeleting,
     CallerType aCallerType, ErrorResult& aRv) {
   MOZ_ASSERT(mGlobal);
 
   CommonFactoryRequestParams commonParams;
 
@@ -744,17 +746,17 @@ already_AddRefed<IDBOpenDBRequest> IDBFa
 
   nsresult rv = InitiateRequest(request, params);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     IDB_REPORT_INTERNAL_ERR();
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return nullptr;
   }
 
-  return request.forget();
+  return request;
 }
 
 nsresult IDBFactory::InitiateRequest(IDBOpenDBRequest* aRequest,
                                      const FactoryRequestParams& aParams) {
   MOZ_ASSERT(aRequest);
   MOZ_ASSERT(mBackgroundActor);
   MOZ_ASSERT(!mBackgroundActorFailed);
 
--- a/dom/indexedDB/IDBFactory.h
+++ b/dom/indexedDB/IDBFactory.h
@@ -136,45 +136,45 @@ class IDBFactory final : public nsISuppo
   uint64_t InnerWindowID() const {
     AssertIsOnOwningThread();
 
     return mInnerWindowID;
   }
 
   bool IsChrome() const;
 
-  already_AddRefed<IDBOpenDBRequest> Open(JSContext* aCx,
-                                          const nsAString& aName,
-                                          uint64_t aVersion,
-                                          CallerType aCallerType,
-                                          ErrorResult& aRv);
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> Open(JSContext* aCx,
+                                             const nsAString& aName,
+                                             uint64_t aVersion,
+                                             CallerType aCallerType,
+                                             ErrorResult& aRv);
 
-  already_AddRefed<IDBOpenDBRequest> Open(JSContext* aCx,
-                                          const nsAString& aName,
-                                          const IDBOpenDBOptions& aOptions,
-                                          CallerType aCallerType,
-                                          ErrorResult& aRv);
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> Open(JSContext* aCx,
+                                             const nsAString& aName,
+                                             const IDBOpenDBOptions& aOptions,
+                                             CallerType aCallerType,
+                                             ErrorResult& aRv);
 
-  already_AddRefed<IDBOpenDBRequest> DeleteDatabase(
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> DeleteDatabase(
       JSContext* aCx, const nsAString& aName, const IDBOpenDBOptions& aOptions,
       CallerType aCallerType, ErrorResult& aRv);
 
   int16_t Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
               JS::Handle<JS::Value> aSecond, ErrorResult& aRv);
 
-  already_AddRefed<IDBOpenDBRequest> OpenForPrincipal(
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> OpenForPrincipal(
       JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
       uint64_t aVersion, SystemCallerGuarantee, ErrorResult& aRv);
 
-  already_AddRefed<IDBOpenDBRequest> OpenForPrincipal(
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> OpenForPrincipal(
       JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
       const IDBOpenDBOptions& aOptions, SystemCallerGuarantee,
       ErrorResult& aRv);
 
-  already_AddRefed<IDBOpenDBRequest> DeleteForPrincipal(
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> DeleteForPrincipal(
       JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
       const IDBOpenDBOptions& aOptions, SystemCallerGuarantee,
       ErrorResult& aRv);
 
   void DisconnectFromGlobal(nsIGlobalObject* aOldGlobal);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
@@ -194,17 +194,17 @@ class IDBFactory final : public nsISuppo
   static nsresult CreateInternal(nsIGlobalObject* aGlobal,
                                  nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
                                  uint64_t aInnerWindowID,
                                  IDBFactory** aFactory);
 
   static nsresult AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
                                            nsIPrincipal** aPrincipal);
 
-  already_AddRefed<IDBOpenDBRequest> OpenInternal(
+  MOZ_MUST_USE RefPtr<IDBOpenDBRequest> OpenInternal(
       JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
       const Optional<uint64_t>& aVersion,
       const Optional<StorageType>& aStorageType, bool aDeleting,
       CallerType aCallerType, ErrorResult& aRv);
 
   nsresult InitiateRequest(IDBOpenDBRequest* aRequest,
                            const indexedDB::FactoryRequestParams& aParams);
 };