Bug 1600283 - Remove uses of already_AddRefed. r=#dom-workers-and-storage draft
authorSimon Giesecke <sgiesecke@mozilla.com>
Wed, 04 Dec 2019 16:48:50 +0000
changeset 2515989 8b28af9eadc72a6b23e483236dfbba8ab3a2945e
parent 2515988 098f2f718cd8cfd82d7c61a187a5ee3493b46187
child 2515990 1d81b6d9f6c52e4ffb799a1942625f483975d987
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/D55492 Differential Diff: PHID-DIFF-q37glmvsaczwa72unqyt
dom/indexedDB/IDBCursor.cpp
dom/indexedDB/IDBCursor.h
--- a/dom/indexedDB/IDBCursor.cpp
+++ b/dom/indexedDB/IDBCursor.cpp
@@ -71,87 +71,86 @@ IDBCursor::~IDBCursor() {
 
   if (mBackgroundActor) {
     mBackgroundActor->SendDeleteMeInternal();
     MOZ_ASSERT(!mBackgroundActor, "SendDeleteMeInternal should have cleared!");
   }
 }
 
 // static
-already_AddRefed<IDBCursor> IDBCursor::Create(
-    BackgroundCursorChild* aBackgroundActor, Key aKey,
-    StructuredCloneReadInfo&& aCloneInfo) {
+RefPtr<IDBCursor> IDBCursor::Create(BackgroundCursorChild* aBackgroundActor,
+                                    Key aKey,
+                                    StructuredCloneReadInfo&& aCloneInfo) {
   MOZ_ASSERT(aBackgroundActor);
   aBackgroundActor->AssertIsOnOwningThread();
   MOZ_ASSERT(aBackgroundActor->GetObjectStore());
   MOZ_ASSERT(!aBackgroundActor->GetIndex());
   MOZ_ASSERT(!aKey.IsUnset());
 
   RefPtr<IDBCursor> cursor =
       new IDBCursor(Type_ObjectStore, aBackgroundActor, std::move(aKey));
 
   cursor->mCloneInfo = std::move(aCloneInfo);
 
-  return cursor.forget();
+  return cursor;
 }
 
 // static
-already_AddRefed<IDBCursor> IDBCursor::Create(
-    BackgroundCursorChild* aBackgroundActor, Key aKey) {
+RefPtr<IDBCursor> IDBCursor::Create(BackgroundCursorChild* aBackgroundActor,
+                                    Key aKey) {
   MOZ_ASSERT(aBackgroundActor);
   aBackgroundActor->AssertIsOnOwningThread();
   MOZ_ASSERT(aBackgroundActor->GetObjectStore());
   MOZ_ASSERT(!aBackgroundActor->GetIndex());
   MOZ_ASSERT(!aKey.IsUnset());
 
   RefPtr<IDBCursor> cursor =
       new IDBCursor(Type_ObjectStoreKey, aBackgroundActor, std::move(aKey));
 
-  return cursor.forget();
+  return cursor;
 }
 
 // static
-already_AddRefed<IDBCursor> IDBCursor::Create(
-    BackgroundCursorChild* aBackgroundActor, Key aKey, Key aSortKey,
-    Key aPrimaryKey, StructuredCloneReadInfo&& aCloneInfo) {
+RefPtr<IDBCursor> IDBCursor::Create(BackgroundCursorChild* aBackgroundActor,
+                                    Key aKey, Key aSortKey, Key aPrimaryKey,
+                                    StructuredCloneReadInfo&& aCloneInfo) {
   MOZ_ASSERT(aBackgroundActor);
   aBackgroundActor->AssertIsOnOwningThread();
   MOZ_ASSERT(aBackgroundActor->GetIndex());
   MOZ_ASSERT(!aBackgroundActor->GetObjectStore());
   MOZ_ASSERT(!aKey.IsUnset());
   MOZ_ASSERT(!aPrimaryKey.IsUnset());
 
   RefPtr<IDBCursor> cursor =
       new IDBCursor(Type_Index, aBackgroundActor, std::move(aKey));
 
   cursor->mSortKey = std::move(aSortKey);
   cursor->mPrimaryKey = std::move(aPrimaryKey);
   cursor->mCloneInfo = std::move(aCloneInfo);
 
-  return cursor.forget();
+  return cursor;
 }
 
 // static
-already_AddRefed<IDBCursor> IDBCursor::Create(
-    BackgroundCursorChild* aBackgroundActor, Key aKey, Key aSortKey,
-    Key aPrimaryKey) {
+RefPtr<IDBCursor> IDBCursor::Create(BackgroundCursorChild* aBackgroundActor,
+                                    Key aKey, Key aSortKey, Key aPrimaryKey) {
   MOZ_ASSERT(aBackgroundActor);
   aBackgroundActor->AssertIsOnOwningThread();
   MOZ_ASSERT(aBackgroundActor->GetIndex());
   MOZ_ASSERT(!aBackgroundActor->GetObjectStore());
   MOZ_ASSERT(!aKey.IsUnset());
   MOZ_ASSERT(!aPrimaryKey.IsUnset());
 
   RefPtr<IDBCursor> cursor =
       new IDBCursor(Type_IndexKey, aBackgroundActor, std::move(aKey));
 
   cursor->mSortKey = std::move(aSortKey);
   cursor->mPrimaryKey = std::move(aPrimaryKey);
 
-  return cursor.forget();
+  return cursor;
 }
 
 // static
 auto IDBCursor::ConvertDirection(IDBCursorDirection aDirection) -> Direction {
   switch (aDirection) {
     case mozilla::dom::IDBCursorDirection::Next:
       return NEXT;
 
@@ -608,19 +607,19 @@ void IDBCursor::Advance(uint32_t aCount,
   }
 
   mBackgroundActor->SendContinueInternal(AdvanceParams(aCount), mKey,
                                          mPrimaryKey);
 
   mContinueCalled = true;
 }
 
-already_AddRefed<IDBRequest> IDBCursor::Update(JSContext* aCx,
-                                               JS::Handle<JS::Value> aValue,
-                                               ErrorResult& aRv) {
+RefPtr<IDBRequest> IDBCursor::Update(JSContext* aCx,
+                                     JS::Handle<JS::Value> aValue,
+                                     ErrorResult& aRv) {
   AssertIsOnOwningThread();
 
   if (!mTransaction->CanAcceptRequests()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
     return nullptr;
   }
 
   if (!mTransaction->IsWriteAllowed()) {
@@ -717,21 +716,20 @@ already_AddRefed<IDBRequest> IDBCursor::
         "IDBCursor.update()", mTransaction->LoggingSerialNumber(),
         request->LoggingSerialNumber(),
         IDB_LOG_STRINGIFY(mTransaction->Database()),
         IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(objectStore),
         IDB_LOG_STRINGIFY(mSourceIndex), IDB_LOG_STRINGIFY(mDirection),
         IDB_LOG_STRINGIFY(objectStore, primaryKey));
   }
 
-  return request.forget();
+  return request;
 }
 
-already_AddRefed<IDBRequest> IDBCursor::Delete(JSContext* aCx,
-                                               ErrorResult& aRv) {
+RefPtr<IDBRequest> IDBCursor::Delete(JSContext* aCx, ErrorResult& aRv) {
   AssertIsOnOwningThread();
 
   if (!mTransaction->CanAcceptRequests()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
     return nullptr;
   }
 
   if (!mTransaction->IsWriteAllowed()) {
@@ -789,17 +787,17 @@ already_AddRefed<IDBRequest> IDBCursor::
         "IDBCursor.delete()", mTransaction->LoggingSerialNumber(),
         request->LoggingSerialNumber(),
         IDB_LOG_STRINGIFY(mTransaction->Database()),
         IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(objectStore),
         IDB_LOG_STRINGIFY(mSourceIndex), IDB_LOG_STRINGIFY(mDirection),
         IDB_LOG_STRINGIFY(objectStore, primaryKey));
   }
 
-  return request.forget();
+  return request;
 }
 
 void IDBCursor::Reset(Key&& aKey, StructuredCloneReadInfo&& aValue) {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mType == Type_ObjectStore);
 
   Reset();
 
--- a/dom/indexedDB/IDBCursor.h
+++ b/dom/indexedDB/IDBCursor.h
@@ -87,28 +87,28 @@ class IDBCursor final : public nsISuppor
   bool mHaveCachedKey : 1;
   bool mHaveCachedPrimaryKey : 1;
   bool mHaveCachedValue : 1;
   bool mRooted : 1;
   bool mContinueCalled : 1;
   bool mHaveValue : 1;
 
  public:
-  static already_AddRefed<IDBCursor> Create(
+  static MOZ_MUST_USE RefPtr<IDBCursor> Create(
       indexedDB::BackgroundCursorChild* aBackgroundActor, Key aKey,
       StructuredCloneReadInfo&& aCloneInfo);
 
-  static already_AddRefed<IDBCursor> Create(
+  static MOZ_MUST_USE RefPtr<IDBCursor> Create(
       indexedDB::BackgroundCursorChild* aBackgroundActor, Key aKey);
 
-  static already_AddRefed<IDBCursor> Create(
+  static MOZ_MUST_USE RefPtr<IDBCursor> Create(
       indexedDB::BackgroundCursorChild* aBackgroundActor, Key aKey,
       Key aSortKey, Key aPrimaryKey, StructuredCloneReadInfo&& aCloneInfo);
 
-  static already_AddRefed<IDBCursor> Create(
+  static MOZ_MUST_USE RefPtr<IDBCursor> Create(
       indexedDB::BackgroundCursorChild* aBackgroundActor, Key aKey,
       Key aSortKey, Key aPrimaryKey);
 
   static Direction ConvertDirection(IDBCursorDirection aDirection);
 
   void AssertIsOnOwningThread() const
 #ifdef DEBUG
       ;
@@ -136,21 +136,21 @@ class IDBCursor final : public nsISuppor
 
   void Continue(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
 
   void ContinuePrimaryKey(JSContext* aCx, JS::Handle<JS::Value> aKey,
                           JS::Handle<JS::Value> aPrimaryKey, ErrorResult& aRv);
 
   void Advance(uint32_t aCount, ErrorResult& aRv);
 
-  already_AddRefed<IDBRequest> Update(JSContext* aCx,
-                                      JS::Handle<JS::Value> aValue,
-                                      ErrorResult& aRv);
+  MOZ_MUST_USE RefPtr<IDBRequest> Update(JSContext* aCx,
+                                         JS::Handle<JS::Value> aValue,
+                                         ErrorResult& aRv);
 
-  already_AddRefed<IDBRequest> Delete(JSContext* aCx, ErrorResult& aRv);
+  MOZ_MUST_USE RefPtr<IDBRequest> Delete(JSContext* aCx, ErrorResult& aRv);
 
   void Reset();
 
   void Reset(Key&& aKey, StructuredCloneReadInfo&& aValue);
 
   void Reset(Key&& aKey);
 
   void Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey,