Bug 1711663 - Rename FileManagerBase to FileInfoManager; r=dom-storage-reviewers,jstutte
authorJan Varga <jvarga@mozilla.com>
Tue, 01 Jun 2021 08:50:31 +0000
changeset 654053 030c75a42520e7033a67a7d257c2074b48556a69
parent 654052 e902ab5efc572964283fc8657ca75a45a8b6a018
child 654054 42aca39d8ed6d69c588664c3838915e4d3382202
push id2623
push userffxbld-merge
push dateMon, 02 Aug 2021 14:47:51 +0000
treeherdermozilla-release@8500ce65f7c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-storage-reviewers, jstutte
bugs1711663
milestone91.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1711663 - Rename FileManagerBase to FileInfoManager; r=dom-storage-reviewers,jstutte Differential Revision: https://phabricator.services.mozilla.com/D115359
dom/indexedDB/ActorsParent.cpp
dom/indexedDB/DatabaseFileManager.h
dom/indexedDB/FileInfo.h
dom/indexedDB/FileInfoImpl.h
dom/indexedDB/FileInfoManager.h
dom/indexedDB/FileManagerBase.h
dom/indexedDB/test/gtest/TestSimpleFileInfo.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -21,17 +21,17 @@
 #include <utility>
 #include "ActorsParentCommon.h"
 #include "CrashAnnotations.h"
 #include "DatabaseFileInfoFwd.h"
 #include "DatabaseFileManager.h"
 #include "DBSchema.h"
 #include "ErrorList.h"
 #include "FileInfo.h"
-#include "FileManagerBase.h"
+#include "FileInfoManager.h"
 #include "IDBCursorType.h"
 #include "IDBObjectStore.h"
 #include "IDBTransaction.h"
 #include "IndexedDBCommon.h"
 #include "IndexedDatabaseInlines.h"
 #include "IndexedDatabaseManager.h"
 #include "KeyPath.h"
 #include "MainThreadUtils.h"
@@ -12229,17 +12229,17 @@ nsresult DatabaseFileManager::Init(nsIFi
                        MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 1));
 
         // We put a raw pointer into the hash table, so the memory refcount will
         // be 0, but the dbRefCnt is non-zero, which will keep the
         // DatabaseFileInfo object alive.
         MOZ_ASSERT(dbRefCnt > 0);
         mFileInfos.InsertOrUpdate(
             id, MakeNotNull<DatabaseFileInfo*>(
-                    FileManagerGuard{}, SafeRefPtrFromThis(), id,
+                    FileInfoManagerGuard{}, SafeRefPtrFromThis(), id,
                     static_cast<nsrefcnt>(dbRefCnt)));
 
         mLastFileId = std::max(id, mLastFileId);
 
         return Ok{};
       }));
 
   return NS_OK;
--- a/dom/indexedDB/DatabaseFileManager.h
+++ b/dom/indexedDB/DatabaseFileManager.h
@@ -2,33 +2,33 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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_DATABASEFILEMANAGER_H_
 #define DOM_INDEXEDDB_DATABASEFILEMANAGER_H_
 
+#include "FileInfoManager.h"
 #include "mozilla/dom/quota/CommonMetadata.h"
 #include "mozilla/dom/quota/PersistenceType.h"
 #include "mozilla/dom/quota/UsageInfo.h"
 #include "mozilla/InitializedOnce.h"
-#include "FileManagerBase.h"
 
 class nsIFile;
 class mozIStorageConnection;
 
 namespace mozilla::dom::indexedDB {
 
 // Implemented in ActorsParent.cpp.
 class DatabaseFileManager final
-    : public FileManagerBase<DatabaseFileManager>,
+    : public FileInfoManager<DatabaseFileManager>,
       public AtomicSafeRefCounted<DatabaseFileManager> {
   using PersistenceType = mozilla::dom::quota::PersistenceType;
-  using FileManagerBase<DatabaseFileManager>::MutexType;
+  using FileInfoManager<DatabaseFileManager>::MutexType;
 
   const PersistenceType mPersistenceType;
   const quota::OriginMetadata mOriginMetadata;
   const nsString mDatabaseName;
 
   LazyInitializedOnce<const nsString> mDirectoryPath;
   LazyInitializedOnce<const nsString> mJournalDirectoryPath;
 
--- a/dom/indexedDB/FileInfo.h
+++ b/dom/indexedDB/FileInfo.h
@@ -16,17 +16,17 @@ namespace dom {
 namespace indexedDB {
 
 template <typename FileManager>
 class FileInfo final {
  public:
   using AutoLockType = typename FileManager::AutoLockType;
   using IdType = int64_t;
 
-  FileInfo(const typename FileManager::FileManagerGuard& aGuard,
+  FileInfo(const typename FileManager::FileInfoManagerGuard& aGuard,
            SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
            const nsrefcnt aInitialDBRefCnt = 0);
 
   void AddRef();
   void Release(const bool aSyncDeleteFile = false);
 
   void UpdateDBRefs(int32_t aDelta);
 
@@ -34,17 +34,18 @@ class FileInfo final {
 
   FileManager& Manager() const;
 
   IdType Id() const;
 
   nsCOMPtr<nsIFile> GetFileForFileInfo() const;
 
   void LockedAddRef();
-  bool LockedClearDBRefs(const typename FileManager::FileManagerGuard& aGuard);
+  bool LockedClearDBRefs(
+      const typename FileManager::FileInfoManagerGuard& aGuard);
 
  private:
   void UpdateReferences(ThreadSafeAutoRefCnt& aRefCount, int32_t aDelta,
                         bool aSyncDeleteFile = false);
 
   void Cleanup();
 
   const IdType mFileId;
--- a/dom/indexedDB/FileInfoImpl.h
+++ b/dom/indexedDB/FileInfoImpl.h
@@ -14,17 +14,17 @@
 #include "nsIFile.h"
 
 namespace mozilla {
 namespace dom {
 namespace indexedDB {
 
 template <typename FileManager>
 FileInfo<FileManager>::FileInfo(
-    const typename FileManager::FileManagerGuard& aGuard,
+    const typename FileManager::FileInfoManagerGuard& aGuard,
     SafeRefPtr<FileManager> aFileManager, const int64_t aFileId,
     const nsrefcnt aInitialDBRefCnt)
     : mFileId(aFileId),
       mDBRefCnt(aInitialDBRefCnt),
       mFileManager(std::move(aFileManager)) {
   MOZ_ASSERT(mFileId > 0);
   MOZ_ASSERT(mFileManager);
 }
@@ -108,17 +108,17 @@ template <typename FileManager>
 void FileInfo<FileManager>::LockedAddRef() {
   FileManager::Mutex().AssertCurrentThreadOwns();
 
   ++mRefCnt;
 }
 
 template <typename FileManager>
 bool FileInfo<FileManager>::LockedClearDBRefs(
-    const typename FileManager::FileManagerGuard&) {
+    const typename FileManager::FileInfoManagerGuard&) {
   FileManager::Mutex().AssertCurrentThreadOwns();
 
   mDBRefCnt = 0;
 
   if (mRefCnt) {
     return true;
   }
 
rename from dom/indexedDB/FileManagerBase.h
rename to dom/indexedDB/FileInfoManager.h
--- a/dom/indexedDB/FileManagerBase.h
+++ b/dom/indexedDB/FileInfoManager.h
@@ -1,47 +1,47 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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_filemanagerbase_h__
-#define mozilla_dom_indexeddb_filemanagerbase_h__
+#ifndef DOM_INDEXEDDB_FILEINFOMANAGER_H_
+#define DOM_INDEXEDDB_FILEINFOMANAGER_H_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/StaticMutex.h"
 #include "nsTHashMap.h"
 #include "nsHashKeys.h"
 #include "nsISupportsImpl.h"
 #include "FileInfo.h"
 #include "FlippedOnce.h"
 
 namespace mozilla {
 namespace dom {
 namespace indexedDB {
 
 template <typename FileManager>
-class FileManagerBase {
+class FileInfoManager {
  public:
   using FileInfoType = FileInfo<FileManager>;
   using MutexType = StaticMutex;
   using AutoLockType = mozilla::detail::BaseAutoLock<MutexType&>;
 
   [[nodiscard]] SafeRefPtr<FileInfoType> GetFileInfo(int64_t aId) const {
     return AcquireFileInfo([this, aId] { return mFileInfos.MaybeGet(aId); });
   }
 
   [[nodiscard]] SafeRefPtr<FileInfoType> CreateFileInfo() {
     return AcquireFileInfo([this] {
       const int64_t id = ++mLastFileId;
 
       auto fileInfo =
-          MakeNotNull<FileInfoType*>(FileManagerGuard{},
+          MakeNotNull<FileInfoType*>(FileInfoManagerGuard{},
                                      SafeRefPtr{static_cast<FileManager*>(this),
                                                 AcquireStrongRefFromRawPtr{}},
                                      id);
 
       mFileInfos.InsertOrUpdate(id, fileInfo);
       return Some(fileInfo);
     });
   }
@@ -57,26 +57,26 @@ class FileManagerBase {
     AutoLockType lock(FileManager::Mutex());
 
     mInvalidated.Flip();
 
     mFileInfos.RemoveIf([](const auto& iter) {
       FileInfoType* info = iter.Data();
       MOZ_ASSERT(info);
 
-      return !info->LockedClearDBRefs(FileManagerGuard{});
+      return !info->LockedClearDBRefs(FileInfoManagerGuard{});
     });
 
     return NS_OK;
   }
 
   bool Invalidated() const { return mInvalidated; }
 
-  class FileManagerGuard {
-    FileManagerGuard() = default;
+  class FileInfoManagerGuard {
+    FileInfoManagerGuard() = default;
   };
 
  private:
   // Runs the given aFileInfoTableOp operation, which must return a FileInfo*,
   // 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<FileInfoType> AcquireFileInfo(
@@ -110,26 +110,26 @@ class FileManagerBase {
       MOZ_ASSERT(false);
       return false;
     }
 
     return true;
   }
 
 #ifdef DEBUG
-  ~FileManagerBase() { MOZ_ASSERT(mFileInfos.IsEmpty()); }
+  ~FileInfoManager() { MOZ_ASSERT(mFileInfos.IsEmpty()); }
 #else
-  ~FileManagerBase() = default;
+  ~FileInfoManager() = default;
 #endif
 
   // Access to the following fields must be protected by
   // FileManager::Mutex()
   int64_t mLastFileId = 0;
   nsTHashMap<nsUint64HashKey, NotNull<FileInfoType*>> mFileInfos;
 
   FlippedOnce<false> mInvalidated;
 };
 
 }  // namespace indexedDB
 }  // namespace dom
 }  // namespace mozilla
 
-#endif  // mozilla_dom_indexeddb_filemanagerbase_h__
+#endif  // DOM_INDEXEDDB_FILEINFOMANAGER_H_
--- a/dom/indexedDB/test/gtest/TestSimpleFileInfo.cpp
+++ b/dom/indexedDB/test/gtest/TestSimpleFileInfo.cpp
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "FileInfoImpl.h"
-#include "FileManagerBase.h"
+#include "FileInfoManager.h"
 
 #include "gtest/gtest.h"
 
 #include "mozilla/ArrayAlgorithm.h"
 #include "mozilla/StaticMutex.h"
 #include "nsTArray.h"
 
 #include <array>
@@ -22,20 +22,20 @@ using SimpleFileInfo = FileInfo<SimpleFi
 
 struct SimpleFileManagerStats final {
   // XXX We don't keep track of the specific aFileId parameters here, should we?
 
   size_t mAsyncDeleteFileCalls = 0;
   size_t mSyncDeleteFileCalls = 0;
 };
 
-class SimpleFileManager final : public FileManagerBase<SimpleFileManager>,
+class SimpleFileManager final : public FileInfoManager<SimpleFileManager>,
                                 public AtomicSafeRefCounted<SimpleFileManager> {
  public:
-  using FileManagerBase<SimpleFileManager>::MutexType;
+  using FileInfoManager<SimpleFileManager>::MutexType;
 
   MOZ_DECLARE_REFCOUNTED_TYPENAME(SimpleFileManager)
 
   // SimpleFileManager functions that are used by SimpleFileInfo
 
   [[nodiscard]] nsresult AsyncDeleteFile(const int64_t aFileId) {
     MOZ_RELEASE_ASSERT(!mFileInfos.Contains(aFileId));
 
@@ -59,19 +59,19 @@ class SimpleFileManager final : public F
   explicit SimpleFileManager(SimpleFileManagerStats* aStats = nullptr)
       : mStats{aStats} {}
 
   void CreateDBOnlyFileInfos() {
     for (const auto id : kDBOnlyFileInfoIds) {
       // Copied from within DatabaseFileManager::Init.
 
       mFileInfos.InsertOrUpdate(
-          id,
-          MakeNotNull<SimpleFileInfo*>(FileManagerGuard{}, SafeRefPtrFromThis(),
-                                       id, static_cast<nsrefcnt>(1)));
+          id, MakeNotNull<SimpleFileInfo*>(FileInfoManagerGuard{},
+                                           SafeRefPtrFromThis(), id,
+                                           static_cast<nsrefcnt>(1)));
 
       mLastFileId = std::max(id, mLastFileId);
     }
   }
 
   static MutexType& Mutex() { return sMutex; }
 
   static constexpr auto kDBOnlyFileInfoIds =