diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp index 9f67c2f33e08..bb4309f9be8c 100644 --- a/dom/cache/CacheStorage.cpp +++ b/dom/cache/CacheStorage.cpp @@ -333,7 +333,7 @@ already_AddRefed CacheStorage::Match( CacheQueryParams params; ToCacheQueryParams(params, aOptions); - nsAutoPtr entry(new Entry()); + auto entry = MakeUnique(); entry->mPromise = promise; entry->mArgs = StorageMatchArgs(CacheRequest(), params, GetOpenMode()); entry->mRequest = request; @@ -362,7 +362,7 @@ already_AddRefed CacheStorage::Has(const nsAString& aKey, return nullptr; } - nsAutoPtr entry(new Entry()); + auto entry = MakeUnique(); entry->mPromise = promise; entry->mArgs = StorageHasArgs(nsString(aKey)); @@ -390,7 +390,7 @@ already_AddRefed CacheStorage::Open(const nsAString& aKey, return nullptr; } - nsAutoPtr entry(new Entry()); + auto entry = MakeUnique(); entry->mPromise = promise; entry->mArgs = StorageOpenArgs(nsString(aKey)); @@ -418,7 +418,7 @@ already_AddRefed CacheStorage::Delete(const nsAString& aKey, return nullptr; } - nsAutoPtr entry(new Entry()); + auto entry = MakeUnique(); entry->mPromise = promise; entry->mArgs = StorageDeleteArgs(nsString(aKey)); @@ -445,7 +445,7 @@ already_AddRefed CacheStorage::Keys(ErrorResult& aRv) { return nullptr; } - nsAutoPtr entry(new Entry()); + auto entry = MakeUnique(); entry->mPromise = promise; entry->mArgs = StorageKeysArgs(); @@ -540,23 +540,21 @@ CacheStorage::~CacheStorage() { } } -void CacheStorage::RunRequest(nsAutoPtr&& aEntry) { +void CacheStorage::RunRequest(UniquePtr aEntry) { MOZ_ASSERT(mActor); - nsAutoPtr entry(std::move(aEntry)); + AutoChildOpArgs args(this, aEntry->mArgs, 1); - AutoChildOpArgs args(this, entry->mArgs, 1); - - if (entry->mRequest) { + if (aEntry->mRequest) { ErrorResult rv; - args.Add(entry->mRequest, IgnoreBody, IgnoreInvalidScheme, rv); + args.Add(aEntry->mRequest, IgnoreBody, IgnoreInvalidScheme, rv); if (NS_WARN_IF(rv.Failed())) { - entry->mPromise->MaybeReject(std::move(rv)); + aEntry->mPromise->MaybeReject(std::move(rv)); return; } } - mActor->ExecuteOp(mGlobal, entry->mPromise, this, args.SendAsOpArgs()); + mActor->ExecuteOp(mGlobal, aEntry->mPromise, this, args.SendAsOpArgs()); } OpenMode CacheStorage::GetOpenMode() const { diff --git a/dom/cache/CacheStorage.h b/dom/cache/CacheStorage.h index f776590395e9..eee0235cea7a 100644 --- a/dom/cache/CacheStorage.h +++ b/dom/cache/CacheStorage.h @@ -7,9 +7,9 @@ #ifndef mozilla_dom_cache_CacheStorage_h #define mozilla_dom_cache_CacheStorage_h +#include "mozilla/UniquePtr.h" #include "mozilla/dom/cache/Types.h" #include "mozilla/dom/cache/TypeUtils.h" -#include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsISupportsImpl.h" #include "nsTArray.h" @@ -91,7 +91,7 @@ class CacheStorage final : public nsISupports, ~CacheStorage(); struct Entry; - void RunRequest(nsAutoPtr&& aEntry); + void RunRequest(UniquePtr aEntry); OpenMode GetOpenMode() const;