Bug 1711663 - Rename FileInfoT to FileInfo; r=dom-storage-reviewers,jstutte

This patch also renames FileManagerBase::FileInfo alias to
FileManagerBase::FileInfoType to fix a base toolchains compilation error.
FileManagerBase::AutoLock has been renamed to FileManagerBae::AutoLockType for
consistency.

Differential Revision: https://phabricator.services.mozilla.com/D115358
This commit is contained in:
Jan Varga 2021-06-01 07:04:28 +00:00
Родитель 7ea1bcd018
Коммит 36a184350d
7 изменённых файлов: 53 добавлений и 53 удалений

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

@ -25,7 +25,7 @@
#include "DatabaseFileManager.h"
#include "DBSchema.h"
#include "ErrorList.h"
#include "FileInfoT.h"
#include "FileInfo.h"
#include "FileManagerBase.h"
#include "IDBCursorType.h"
#include "IDBObjectStore.h"

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

@ -5,10 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DatabaseFileManager.h"
#include "FileInfoTImpl.h"
#include "FileInfoImpl.h"
namespace mozilla::dom::indexedDB {
template class FileInfoT<DatabaseFileManager>;
template class FileInfo<DatabaseFileManager>;
} // namespace mozilla::dom::indexedDB

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

@ -12,9 +12,9 @@ namespace mozilla::dom::indexedDB {
class DatabaseFileManager;
template <typename FileManager>
class FileInfoT;
class FileInfo;
using DatabaseFileInfo = FileInfoT<indexedDB::DatabaseFileManager>;
using DatabaseFileInfo = FileInfo<indexedDB::DatabaseFileManager>;
} // namespace mozilla::dom::indexedDB

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_indexeddb_fileinfot_h__
#define mozilla_dom_indexeddb_fileinfot_h__
#ifndef DOM_INDEXEDDB_FILEINFO_H_
#define DOM_INDEXEDDB_FILEINFO_H_
#include "nsISupportsImpl.h"
#include "nsCOMPtr.h"
@ -16,14 +16,14 @@ namespace dom {
namespace indexedDB {
template <typename FileManager>
class FileInfoT final {
class FileInfo final {
public:
using AutoLock = typename FileManager::AutoLock;
using AutoLockType = typename FileManager::AutoLockType;
using IdType = int64_t;
FileInfoT(const typename FileManager::FileManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt = 0);
FileInfo(const typename FileManager::FileManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt = 0);
void AddRef();
void Release(const bool aSyncDeleteFile = false);
@ -59,4 +59,4 @@ class FileInfoT final {
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_indexeddb_fileinfot_h__
#endif // DOM_INDEXEDDB_FILEINFO_H_

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

@ -4,10 +4,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_indexeddb_fileinfotimpl_h__
#define mozilla_dom_indexeddb_fileinfotimpl_h__
#ifndef DOM_INDEXEDDB_FILEINFOIMPL_H_
#define DOM_INDEXEDDB_FILEINFOIMPL_H_
#include "FileInfoT.h"
#include "FileInfo.h"
#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/Mutex.h"
@ -18,7 +18,7 @@ namespace dom {
namespace indexedDB {
template <typename FileManager>
FileInfoT<FileManager>::FileInfoT(
FileInfo<FileManager>::FileInfo(
const typename FileManager::FileManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt)
@ -30,26 +30,26 @@ FileInfoT<FileManager>::FileInfoT(
}
template <typename FileManager>
void FileInfoT<FileManager>::AddRef() {
AutoLock lock(FileManager::Mutex());
void FileInfo<FileManager>::AddRef() {
AutoLockType lock(FileManager::Mutex());
LockedAddRef();
}
template <typename FileManager>
void FileInfoT<FileManager>::Release(const bool aSyncDeleteFile) {
void FileInfo<FileManager>::Release(const bool aSyncDeleteFile) {
UpdateReferences(mRefCnt, -1, aSyncDeleteFile);
}
template <typename FileManager>
void FileInfoT<FileManager>::UpdateDBRefs(int32_t aDelta) {
void FileInfo<FileManager>::UpdateDBRefs(int32_t aDelta) {
UpdateReferences(mDBRefCnt, aDelta);
}
template <typename FileManager>
void FileInfoT<FileManager>::GetReferences(int32_t* const aRefCnt,
int32_t* const aDBRefCnt) {
AutoLock lock(FileManager::Mutex());
void FileInfo<FileManager>::GetReferences(int32_t* const aRefCnt,
int32_t* const aDBRefCnt) {
AutoLockType lock(FileManager::Mutex());
if (aRefCnt) {
*aRefCnt = mRefCnt;
@ -61,22 +61,22 @@ void FileInfoT<FileManager>::GetReferences(int32_t* const aRefCnt,
}
template <typename FileManager>
FileManager& FileInfoT<FileManager>::Manager() const {
FileManager& FileInfo<FileManager>::Manager() const {
return *mFileManager;
}
template <typename FileManager>
int64_t FileInfoT<FileManager>::Id() const {
int64_t FileInfo<FileManager>::Id() const {
return mFileId;
}
template <typename FileManager>
void FileInfoT<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
const int32_t aDelta,
const bool aSyncDeleteFile) {
void FileInfo<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
const int32_t aDelta,
const bool aSyncDeleteFile) {
bool needsCleanup;
{
AutoLock lock(FileManager::Mutex());
AutoLockType lock(FileManager::Mutex());
aRefCount = aRefCount + aDelta;
@ -105,14 +105,14 @@ void FileInfoT<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
}
template <typename FileManager>
void FileInfoT<FileManager>::LockedAddRef() {
void FileInfo<FileManager>::LockedAddRef() {
FileManager::Mutex().AssertCurrentThreadOwns();
++mRefCnt;
}
template <typename FileManager>
bool FileInfoT<FileManager>::LockedClearDBRefs(
bool FileInfo<FileManager>::LockedClearDBRefs(
const typename FileManager::FileManagerGuard&) {
FileManager::Mutex().AssertCurrentThreadOwns();
@ -133,12 +133,12 @@ bool FileInfoT<FileManager>::LockedClearDBRefs(
}
template <typename FileManager>
void FileInfoT<FileManager>::Cleanup() {
void FileInfo<FileManager>::Cleanup() {
QM_WARNONLY_TRY(mFileManager->AsyncDeleteFile(Id()));
}
template <typename FileManager>
nsCOMPtr<nsIFile> FileInfoT<FileManager>::GetFileForFileInfo() const {
nsCOMPtr<nsIFile> FileInfo<FileManager>::GetFileForFileInfo() const {
const nsCOMPtr<nsIFile> directory = Manager().GetDirectory();
if (NS_WARN_IF(!directory)) {
return nullptr;
@ -156,4 +156,4 @@ nsCOMPtr<nsIFile> FileInfoT<FileManager>::GetFileForFileInfo() const {
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_indexeddb_fileinfotimpl_h__
#endif // DOM_INDEXEDDB_FILEINFOIMPL_H_

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

@ -13,7 +13,7 @@
#include "nsTHashMap.h"
#include "nsHashKeys.h"
#include "nsISupportsImpl.h"
#include "FileInfoT.h"
#include "FileInfo.h"
#include "FlippedOnce.h"
namespace mozilla {
@ -23,30 +23,30 @@ namespace indexedDB {
template <typename FileManager>
class FileManagerBase {
public:
using FileInfo = FileInfoT<FileManager>;
using FileInfoType = FileInfo<FileManager>;
using MutexType = StaticMutex;
using AutoLock = mozilla::detail::BaseAutoLock<MutexType&>;
using AutoLockType = mozilla::detail::BaseAutoLock<MutexType&>;
[[nodiscard]] SafeRefPtr<FileInfo> GetFileInfo(int64_t aId) const {
[[nodiscard]] SafeRefPtr<FileInfoType> GetFileInfo(int64_t aId) const {
return AcquireFileInfo([this, aId] { return mFileInfos.MaybeGet(aId); });
}
[[nodiscard]] SafeRefPtr<FileInfo> CreateFileInfo() {
[[nodiscard]] SafeRefPtr<FileInfoType> CreateFileInfo() {
return AcquireFileInfo([this] {
const int64_t id = ++mLastFileId;
auto fileInfo =
MakeNotNull<FileInfo*>(FileManagerGuard{},
SafeRefPtr{static_cast<FileManager*>(this),
AcquireStrongRefFromRawPtr{}},
id);
MakeNotNull<FileInfoType*>(FileManagerGuard{},
SafeRefPtr{static_cast<FileManager*>(this),
AcquireStrongRefFromRawPtr{}},
id);
mFileInfos.InsertOrUpdate(id, fileInfo);
return Some(fileInfo);
});
}
void RemoveFileInfo(const int64_t aId, const AutoLock& aFileMutexLock) {
void RemoveFileInfo(const int64_t aId, const AutoLockType& aFileMutexLock) {
#ifdef DEBUG
aFileMutexLock.AssertOwns(FileManager::Mutex());
#endif
@ -54,12 +54,12 @@ class FileManagerBase {
}
nsresult Invalidate() {
AutoLock lock(FileManager::Mutex());
AutoLockType lock(FileManager::Mutex());
mInvalidated.Flip();
mFileInfos.RemoveIf([](const auto& iter) {
FileInfo* info = iter.Data();
FileInfoType* info = iter.Data();
MOZ_ASSERT(info);
return !info->LockedClearDBRefs(FileManagerGuard{});
@ -79,7 +79,7 @@ class FileManagerBase {
// under the FileManager lock, acquires a strong reference to the returned
// object under the lock, and returns the strong reference.
template <typename FileInfoTableOp>
[[nodiscard]] SafeRefPtr<FileInfo> AcquireFileInfo(
[[nodiscard]] SafeRefPtr<FileInfoType> AcquireFileInfo(
const FileInfoTableOp& aFileInfoTableOp) const {
if (!AssertValid()) {
// In release, the assertions are disabled.
@ -88,8 +88,8 @@ class FileManagerBase {
// We cannot simply change this to SafeRefPtr<FileInfo>, because
// FileInfo::AddRef also acquires the FileManager::Mutex.
auto fileInfo = [&aFileInfoTableOp]() -> RefPtr<FileInfo> {
AutoLock lock(FileManager::Mutex());
auto fileInfo = [&aFileInfoTableOp]() -> RefPtr<FileInfoType> {
AutoLockType lock(FileManager::Mutex());
const auto maybeFileInfo = aFileInfoTableOp();
if (maybeFileInfo) {
@ -123,7 +123,7 @@ class FileManagerBase {
// Access to the following fields must be protected by
// FileManager::Mutex()
int64_t mLastFileId = 0;
nsTHashMap<nsUint64HashKey, NotNull<FileInfo*>> mFileInfos;
nsTHashMap<nsUint64HashKey, NotNull<FileInfoType*>> mFileInfos;
FlippedOnce<false> mInvalidated;
};

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileInfoTImpl.h"
#include "FileInfoImpl.h"
#include "FileManagerBase.h"
#include "gtest/gtest.h"
@ -18,7 +18,7 @@ using namespace mozilla::dom::indexedDB;
class SimpleFileManager;
using SimpleFileInfo = FileInfoT<SimpleFileManager>;
using SimpleFileInfo = FileInfo<SimpleFileManager>;
struct SimpleFileManagerStats final {
// XXX We don't keep track of the specific aFileId parameters here, should we?