Bug 1600283 - Remove uses of already_AddRefed. r=dom-workers-and-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D55479

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-12-16 13:17:33 +00:00
Родитель 5758ca4f25
Коммит 78cd4c8321
2 изменённых файлов: 108 добавлений и 91 удалений

Просмотреть файл

@ -30,17 +30,13 @@ using namespace mozilla::dom::indexedDB;
namespace {
already_AddRefed<IDBRequest> GenerateRequest(JSContext* aCx, IDBIndex* aIndex) {
RefPtr<IDBRequest> GenerateRequest(JSContext* aCx, IDBIndex* aIndex) {
MOZ_ASSERT(aIndex);
aIndex->AssertIsOnOwningThread();
IDBTransaction* const transaction = aIndex->ObjectStore()->Transaction();
auto* const transaction = aIndex->ObjectStore()->Transaction();
RefPtr<IDBRequest> request =
IDBRequest::Create(aCx, aIndex, transaction->Database(), transaction);
MOZ_ASSERT(request);
return request.forget();
return IDBRequest::Create(aCx, aIndex, transaction->Database(), transaction);
}
} // namespace
@ -65,14 +61,12 @@ IDBIndex::~IDBIndex() {
}
}
already_AddRefed<IDBIndex> IDBIndex::Create(IDBObjectStore* aObjectStore,
RefPtr<IDBIndex> IDBIndex::Create(IDBObjectStore* aObjectStore,
const IndexMetadata& aMetadata) {
MOZ_ASSERT(aObjectStore);
aObjectStore->AssertIsOnOwningThread();
RefPtr<IDBIndex> index = new IDBIndex(aObjectStore, &aMetadata);
return index.forget();
return new IDBIndex(aObjectStore, &aMetadata);
}
#ifdef DEBUG
@ -84,6 +78,56 @@ void IDBIndex::AssertIsOnOwningThread() const {
#endif // DEBUG
RefPtr<IDBRequest> IDBIndex::OpenCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return OpenCursorInternal(/* aKeysOnly */ false, aCx, aRange, aDirection,
aRv);
}
RefPtr<IDBRequest> IDBIndex::OpenKeyCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return OpenCursorInternal(/* aKeysOnly */ true, aCx, aRange, aDirection, aRv);
}
RefPtr<IDBRequest> IDBIndex::Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetInternal(/* aKeyOnly */ false, aCx, aKey, aRv);
}
RefPtr<IDBRequest> IDBIndex::GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetInternal(/* aKeyOnly */ true, aCx, aKey, aRv);
}
RefPtr<IDBRequest> IDBIndex::GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetAllInternal(/* aKeysOnly */ false, aCx, aKey, aLimit, aRv);
}
RefPtr<IDBRequest> IDBIndex::GetAllKeys(JSContext* aCx,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetAllInternal(/* aKeysOnly */ true, aCx, aKey, aLimit, aRv);
}
void IDBIndex::RefreshMetadata(bool aMayDelete) {
AssertIsOnOwningThread();
MOZ_ASSERT_IF(mDeletedMetadata, mMetadata == mDeletedMetadata);
@ -259,8 +303,7 @@ void IDBIndex::GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
aResult.set(mCachedKeyPath);
}
already_AddRefed<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly,
JSContext* aCx,
RefPtr<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly, JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
@ -302,7 +345,7 @@ already_AddRefed<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly,
params = IndexGetParams(objectStoreId, indexId, serializedKeyRange);
}
RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
auto request = GenerateRequest(aCx, this);
MOZ_ASSERT(request);
if (aKeyOnly) {
@ -332,12 +375,13 @@ already_AddRefed<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly,
transaction->StartRequest(request, params);
return request.forget();
return request;
}
already_AddRefed<IDBRequest> IDBIndex::GetAllInternal(
bool aKeysOnly, JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv) {
RefPtr<IDBRequest> IDBIndex::GetAllInternal(bool aKeysOnly, JSContext* aCx,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv) {
AssertIsOnOwningThread();
if (mDeletedMetadata) {
@ -375,7 +419,7 @@ already_AddRefed<IDBRequest> IDBIndex::GetAllInternal(
: RequestParams{IndexGetAllParams(objectStoreId, indexId,
optionalKeyRange, limit)};
RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
auto request = GenerateRequest(aCx, this);
MOZ_ASSERT(request);
if (aKeysOnly) {
@ -407,12 +451,13 @@ already_AddRefed<IDBRequest> IDBIndex::GetAllInternal(
transaction->StartRequest(request, params);
return request.forget();
return request;
}
already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
bool aKeysOnly, JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv) {
RefPtr<IDBRequest> IDBIndex::OpenCursorInternal(bool aKeysOnly, JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv) {
AssertIsOnOwningThread();
if (mDeletedMetadata) {
@ -454,7 +499,7 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
aKeysOnly ? OpenCursorParams{IndexOpenKeyCursorParams{commonIndexParams}}
: OpenCursorParams{IndexOpenCursorParams{commonIndexParams}};
RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
auto request = GenerateRequest(aCx, this);
MOZ_ASSERT(request);
if (aKeysOnly) {
@ -489,11 +534,10 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
mObjectStore->Transaction()->OpenCursor(actor, params);
return request.forget();
return request;
}
already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
JS::Handle<JS::Value> aKey,
RefPtr<IDBRequest> IDBIndex::Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
@ -524,7 +568,7 @@ already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
params.optionalKeyRange().emplace(serializedKeyRange);
}
RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
auto request = GenerateRequest(aCx, this);
MOZ_ASSERT(request);
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
@ -543,7 +587,7 @@ already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
transaction->StartRequest(request, params);
return request.forget();
return request;
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBIndex)

Просмотреть файл

@ -55,7 +55,7 @@ class IDBIndex final : public nsISupports, public nsWrapperCache {
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)
static already_AddRefed<IDBIndex> Create(
static MOZ_MUST_USE RefPtr<IDBIndex> Create(
IDBObjectStore* aObjectStore, const indexedDB::IndexMetadata& aMetadata);
int64_t Id() const {
@ -94,61 +94,37 @@ class IDBIndex final : public nsISupports, public nsWrapperCache {
void GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
already_AddRefed<IDBRequest> OpenCursor(JSContext* aCx,
MOZ_MUST_USE RefPtr<IDBRequest> OpenCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return OpenCursorInternal(/* aKeysOnly */ false, aCx, aRange, aDirection,
aRv);
}
already_AddRefed<IDBRequest> OpenKeyCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return OpenCursorInternal(/* aKeysOnly */ true, aCx, aRange, aDirection,
aRv);
}
already_AddRefed<IDBRequest> Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetInternal(/* aKeyOnly */ false, aCx, aKey, aRv);
}
already_AddRefed<IDBRequest> GetKey(JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetInternal(/* aKeyOnly */ true, aCx, aKey, aRv);
}
already_AddRefed<IDBRequest> Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
already_AddRefed<IDBRequest> GetAll(JSContext* aCx,
MOZ_MUST_USE RefPtr<IDBRequest> OpenKeyCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> Get(JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> GetKey(JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> Count(JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> GetAll(JSContext* aCx,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv) {
AssertIsOnOwningThread();
ErrorResult& aRv);
return GetAllInternal(/* aKeysOnly */ false, aCx, aKey, aLimit, aRv);
}
already_AddRefed<IDBRequest> GetAllKeys(JSContext* aCx,
MOZ_MUST_USE RefPtr<IDBRequest> GetAllKeys(JSContext* aCx,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv) {
AssertIsOnOwningThread();
return GetAllInternal(/* aKeysOnly */ true, aCx, aKey, aLimit, aRv);
}
ErrorResult& aRv);
void RefreshMetadata(bool aMayDelete);
@ -178,20 +154,17 @@ class IDBIndex final : public nsISupports, public nsWrapperCache {
~IDBIndex();
already_AddRefed<IDBRequest> GetInternal(bool aKeyOnly, JSContext* aCx,
MOZ_MUST_USE RefPtr<IDBRequest> GetInternal(bool aKeyOnly, JSContext* aCx,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
already_AddRefed<IDBRequest> GetAllInternal(bool aKeysOnly, JSContext* aCx,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> GetAllInternal(
bool aKeysOnly, JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
already_AddRefed<IDBRequest> OpenCursorInternal(bool aKeysOnly,
JSContext* aCx,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection,
ErrorResult& aRv);
MOZ_MUST_USE RefPtr<IDBRequest> OpenCursorInternal(
bool aKeysOnly, JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
};
} // namespace dom