Skip to content

Commit

Permalink
Backed out 5 changesets (bug 1711663) for causing build bustages on F…
Browse files Browse the repository at this point in the history
…ileManager. CLOSED TREE

Backed out changeset 9f3260aaab11 (bug 1711663)
Backed out changeset adb6539a1e6f (bug 1711663)
Backed out changeset 2b58a824285d (bug 1711663)
Backed out changeset 28e04756a73d (bug 1711663)
Backed out changeset 8a36c84e9269 (bug 1711663)
  • Loading branch information
Iulian Moraru committed May 31, 2021
1 parent e4c0b7b commit 493590d
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 317 deletions.
185 changes: 88 additions & 97 deletions dom/indexedDB/ActorsParent.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dom/indexedDB/ActorsParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Client;

namespace indexedDB {

class FileManager;
class LoggingInfo;
class PBackgroundIDBFactoryParent;
class PBackgroundIndexedDBUtilsParent;
Expand Down
31 changes: 16 additions & 15 deletions dom/indexedDB/ActorsParentCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "ActorsParentCommon.h"

// local includes
#include "DatabaseFileInfo.h"
#include "DatabaseFileManager.h"
#include "DatabaseFileInfoFwd.h" // for DatabaseFileInfo
#include "FileManager.h"
#include "IndexedDatabase.h" // for StructuredCloneFile...
#include "IndexedDatabaseManager.h"
#include "IndexedDBCommon.h"
Expand Down Expand Up @@ -92,8 +92,7 @@ int32_t ToInteger(const nsAString& aStr, nsresult* const aRv) {
}

Result<StructuredCloneFileParent, nsresult> DeserializeStructuredCloneFile(
const DatabaseFileManager& aFileManager,
const nsDependentSubstring& aText) {
const FileManager& aFileManager, const nsDependentSubstring& aText) {
MOZ_ASSERT(!aText.IsEmpty());

const StructuredCloneFileBase::FileType type =
Expand Down Expand Up @@ -338,7 +337,7 @@ nsresult ReadCompressedIndexDataValuesFromSource(
Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromBlob(const uint8_t* aBlobData,
uint32_t aBlobDataLength,
const DatabaseFileManager& aFileManager,
const FileManager& aFileManager,
const nsAString& aFileIds,
const Maybe<CipherKey>& aMaybeKey) {
MOZ_ASSERT(!IsOnBackgroundThread());
Expand Down Expand Up @@ -379,9 +378,10 @@ GetStructuredCloneReadInfoFromBlob(const uint8_t* aBlobData,
}

Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromExternalBlob(
uint64_t aIntData, const DatabaseFileManager& aFileManager,
const nsAString& aFileIds, const Maybe<CipherKey>& aMaybeKey) {
GetStructuredCloneReadInfoFromExternalBlob(uint64_t aIntData,
const FileManager& aFileManager,
const nsAString& aFileIds,
const Maybe<CipherKey>& aMaybeKey) {
MOZ_ASSERT(!IsOnBackgroundThread());

AUTO_PROFILER_LABEL("GetStructuredCloneReadInfoFromExternalBlob", DOM);
Expand Down Expand Up @@ -441,7 +441,7 @@ template <typename T>
Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromSource(T* aSource, uint32_t aDataIndex,
uint32_t aFileIdsIndex,
const DatabaseFileManager& aFileManager,
const FileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey) {
MOZ_ASSERT(!IsOnBackgroundThread());
MOZ_ASSERT(aSource);
Expand Down Expand Up @@ -671,10 +671,11 @@ ReadCompressedNumber(const Span<const uint8_t> aSpan) {
}

Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromValueArray(
mozIStorageValueArray* aValues, uint32_t aDataIndex, uint32_t aFileIdsIndex,
const DatabaseFileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey) {
GetStructuredCloneReadInfoFromValueArray(mozIStorageValueArray* aValues,
uint32_t aDataIndex,
uint32_t aFileIdsIndex,
const FileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey) {
return GetStructuredCloneReadInfoFromSource(
aValues, aDataIndex, aFileIdsIndex, aFileManager, aMaybeKey);
}
Expand All @@ -683,14 +684,14 @@ Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromStatement(mozIStorageStatement* aStatement,
uint32_t aDataIndex,
uint32_t aFileIdsIndex,
const DatabaseFileManager& aFileManager,
const FileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey) {
return GetStructuredCloneReadInfoFromSource(
aStatement, aDataIndex, aFileIdsIndex, aFileManager, aMaybeKey);
}

Result<nsTArray<StructuredCloneFileParent>, nsresult>
DeserializeStructuredCloneFiles(const DatabaseFileManager& aFileManager,
DeserializeStructuredCloneFiles(const FileManager& aFileManager,
const nsAString& aText) {
MOZ_ASSERT(!IsOnBackgroundThread());

Expand Down
14 changes: 8 additions & 6 deletions dom/indexedDB/ActorsParentCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace mozilla {
namespace dom {
namespace indexedDB {

class DatabaseFileManager;
class FileManager;
struct StructuredCloneFileParent;
struct StructuredCloneReadInfoParent;

Expand Down Expand Up @@ -102,19 +102,21 @@ Result<std::pair<uint64_t, mozilla::Span<const uint8_t>>, nsresult>
ReadCompressedNumber(Span<const uint8_t> aSpan);

Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromValueArray(
mozIStorageValueArray* aValues, uint32_t aDataIndex, uint32_t aFileIdsIndex,
const DatabaseFileManager& aFileManager, const Maybe<CipherKey>& aMaybeKey);
GetStructuredCloneReadInfoFromValueArray(mozIStorageValueArray* aValues,
uint32_t aDataIndex,
uint32_t aFileIdsIndex,
const FileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey);

Result<StructuredCloneReadInfoParent, nsresult>
GetStructuredCloneReadInfoFromStatement(mozIStorageStatement* aStatement,
uint32_t aDataIndex,
uint32_t aFileIdsIndex,
const DatabaseFileManager& aFileManager,
const FileManager& aFileManager,
const Maybe<CipherKey>& aMaybeKey);

Result<nsTArray<StructuredCloneFileParent>, nsresult>
DeserializeStructuredCloneFiles(const DatabaseFileManager& aFileManager,
DeserializeStructuredCloneFiles(const FileManager& aFileManager,
const nsAString& aText);

nsresult ExecuteSimpleSQLSequence(mozIStorageConnection& aConnection,
Expand Down
7 changes: 3 additions & 4 deletions dom/indexedDB/DatabaseFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* 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 "DatabaseFileInfo.h"

#include "FileInfoImpl.h"
#include "FileInfoTImpl.h"
#include "FileManager.h"

namespace mozilla::dom::indexedDB {

template class FileInfo<DatabaseFileManager>;
template class FileInfoT<FileManager>;

} // namespace mozilla::dom::indexedDB
15 changes: 0 additions & 15 deletions dom/indexedDB/DatabaseFileInfo.h

This file was deleted.

6 changes: 3 additions & 3 deletions dom/indexedDB/DatabaseFileInfoFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

namespace mozilla::dom::indexedDB {

class DatabaseFileManager;
class FileManager;

template <typename FileManager>
class FileInfo;
class FileInfoT;

using DatabaseFileInfo = FileInfo<DatabaseFileManager>;
using DatabaseFileInfo = FileInfoT<indexedDB::FileManager>;

} // namespace mozilla::dom::indexedDB

Expand Down
37 changes: 13 additions & 24 deletions dom/indexedDB/FileInfo.h → dom/indexedDB/FileInfoT.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 DOM_INDEXEDDB_FILEINFO_H_
#define DOM_INDEXEDDB_FILEINFO_H_
#ifndef mozilla_dom_indexeddb_fileinfot_h__
#define mozilla_dom_indexeddb_fileinfot_h__

#include "nsISupportsImpl.h"
#include "nsCOMPtr.h"
Expand All @@ -15,29 +15,15 @@ namespace mozilla {
namespace dom {
namespace indexedDB {

class FileInfoBase {
public:
using IdType = int64_t;

IdType Id() const { return mFileId; }

protected:
explicit FileInfoBase(const int64_t aFileId) : mFileId(aFileId) {
MOZ_ASSERT(mFileId > 0);
}

private:
const IdType mFileId;
};

template <typename FileManager>
class FileInfo final : public FileInfoBase {
class FileInfoT final {
public:
using AutoLock = typename FileManager::AutoLock;
using IdType = int64_t;

FileInfo(const typename FileManager::FileInfoManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt = 0);
FileInfoT(const typename FileManager::FileManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt = 0);

void AddRef();
void Release(const bool aSyncDeleteFile = false);
Expand All @@ -48,18 +34,21 @@ class FileInfo final : public FileInfoBase {

FileManager& Manager() const;

IdType Id() const;

nsCOMPtr<nsIFile> GetFileForFileInfo() const;

void LockedAddRef();
bool LockedClearDBRefs(
const typename FileManager::FileInfoManagerGuard& aGuard);
bool LockedClearDBRefs(const typename FileManager::FileManagerGuard& aGuard);

private:
void UpdateReferences(ThreadSafeAutoRefCnt& aRefCount, int32_t aDelta,
bool aSyncDeleteFile = false);

void Cleanup();

const IdType mFileId;

ThreadSafeAutoRefCnt mRefCnt;
ThreadSafeAutoRefCnt mDBRefCnt;

Expand All @@ -70,4 +59,4 @@ class FileInfo final : public FileInfoBase {
} // namespace dom
} // namespace mozilla

#endif // DOM_INDEXEDDB_FILEINFO_H_
#endif // mozilla_dom_indexeddb_fileinfot_h__
50 changes: 28 additions & 22 deletions dom/indexedDB/FileInfoImpl.h → dom/indexedDB/FileInfoTImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 DOM_INDEXEDDB_FILEINFOIMPL_H_
#define DOM_INDEXEDDB_FILEINFOIMPL_H_
#ifndef mozilla_dom_indexeddb_fileinfotimpl_h__
#define mozilla_dom_indexeddb_fileinfotimpl_h__

#include "FileInfo.h"
#include "FileInfoT.h"

#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/Mutex.h"
Expand All @@ -18,36 +18,37 @@ namespace dom {
namespace indexedDB {

template <typename FileManager>
FileInfo<FileManager>::FileInfo(
const typename FileManager::FileInfoManagerGuard& aGuard,
FileInfoT<FileManager>::FileInfoT(
const typename FileManager::FileManagerGuard& aGuard,
SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
const nsrefcnt aInitialDBRefCnt)
: FileInfoBase{aFileId},
: mFileId(aFileId),
mDBRefCnt(aInitialDBRefCnt),
mFileManager(std::move(aFileManager)) {
MOZ_ASSERT(mFileId > 0);
MOZ_ASSERT(mFileManager);
}

template <typename FileManager>
void FileInfo<FileManager>::AddRef() {
void FileInfoT<FileManager>::AddRef() {
AutoLock lock(FileManager::Mutex());

LockedAddRef();
}

template <typename FileManager>
void FileInfo<FileManager>::Release(const bool aSyncDeleteFile) {
void FileInfoT<FileManager>::Release(const bool aSyncDeleteFile) {
UpdateReferences(mRefCnt, -1, aSyncDeleteFile);
}

template <typename FileManager>
void FileInfo<FileManager>::UpdateDBRefs(int32_t aDelta) {
void FileInfoT<FileManager>::UpdateDBRefs(int32_t aDelta) {
UpdateReferences(mDBRefCnt, aDelta);
}

template <typename FileManager>
void FileInfo<FileManager>::GetReferences(int32_t* const aRefCnt,
int32_t* const aDBRefCnt) {
void FileInfoT<FileManager>::GetReferences(int32_t* const aRefCnt,
int32_t* const aDBRefCnt) {
AutoLock lock(FileManager::Mutex());

if (aRefCnt) {
Expand All @@ -60,14 +61,19 @@ void FileInfo<FileManager>::GetReferences(int32_t* const aRefCnt,
}

template <typename FileManager>
FileManager& FileInfo<FileManager>::Manager() const {
FileManager& FileInfoT<FileManager>::Manager() const {
return *mFileManager;
}

template <typename FileManager>
void FileInfo<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
const int32_t aDelta,
const bool aSyncDeleteFile) {
int64_t FileInfoT<FileManager>::Id() const {
return mFileId;
}

template <typename FileManager>
void FileInfoT<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
const int32_t aDelta,
const bool aSyncDeleteFile) {
bool needsCleanup;
{
AutoLock lock(FileManager::Mutex());
Expand All @@ -80,7 +86,7 @@ void FileInfo<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,

mFileManager->RemoveFileInfo(Id(), lock);

// If the FileManager was already invalidated, we don't need to do any
// If the file manager was already invalidated, we don't need to do any
// cleanup anymore. In that case, the entire origin directory has already
// been deleted by the quota manager, and we don't need to delete individual
// files.
Expand All @@ -99,15 +105,15 @@ void FileInfo<FileManager>::UpdateReferences(ThreadSafeAutoRefCnt& aRefCount,
}

template <typename FileManager>
void FileInfo<FileManager>::LockedAddRef() {
void FileInfoT<FileManager>::LockedAddRef() {
FileManager::Mutex().AssertCurrentThreadOwns();

++mRefCnt;
}

template <typename FileManager>
bool FileInfo<FileManager>::LockedClearDBRefs(
const typename FileManager::FileInfoManagerGuard&) {
bool FileInfoT<FileManager>::LockedClearDBRefs(
const typename FileManager::FileManagerGuard&) {
FileManager::Mutex().AssertCurrentThreadOwns();

mDBRefCnt = 0;
Expand All @@ -127,12 +133,12 @@ bool FileInfo<FileManager>::LockedClearDBRefs(
}

template <typename FileManager>
void FileInfo<FileManager>::Cleanup() {
void FileInfoT<FileManager>::Cleanup() {
QM_WARNONLY_TRY(mFileManager->AsyncDeleteFile(Id()));
}

template <typename FileManager>
nsCOMPtr<nsIFile> FileInfo<FileManager>::GetFileForFileInfo() const {
nsCOMPtr<nsIFile> FileInfoT<FileManager>::GetFileForFileInfo() const {
const nsCOMPtr<nsIFile> directory = Manager().GetDirectory();
if (NS_WARN_IF(!directory)) {
return nullptr;
Expand All @@ -150,4 +156,4 @@ nsCOMPtr<nsIFile> FileInfo<FileManager>::GetFileForFileInfo() const {
} // namespace dom
} // namespace mozilla

#endif // DOM_INDEXEDDB_FILEINFOIMPL_H_
#endif // mozilla_dom_indexeddb_fileinfotimpl_h__
Loading

0 comments on commit 493590d

Please sign in to comment.