Bug 1395102 - P2 - Rename the intermediate class in P1 to RepositoryOperationBase; r=janv
authorTom Tung <shes050117@gmail.com>
Wed, 17 Oct 2018 14:29:55 +0200
changeset 490621 a0de0c0ec6b01e9d74cd2bcfe6333e1cbaf566dc
parent 490620 0d01e0a4de9550efec739bfe912b0cdb50057941
child 490622 47335300b3377e6a3c696fb9392d30d567a2bac6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjanv
bugs1395102
milestone64.0a1
Bug 1395102 - P2 - Rename the intermediate class in P1 to RepositoryOperationBase; r=janv To do this, it also rename the StorageDirectoryHelper to StorageOperationBase to align with classes naming. Bsides, this patch renames RepositoryOperationBase::DoUpgrade() to RepositoryOperationBase::ProcessRepository().
dom/quota/ActorsParent.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -1595,17 +1595,17 @@ mozilla::Atomic<bool> gShutdown(false);
 // Constants for temporary storage limit computing.
 static const int32_t kDefaultFixedLimitKB = -1;
 static const uint32_t kDefaultChunkSizeKB = 10 * 1024;
 int32_t gFixedLimitKB = kDefaultFixedLimitKB;
 uint32_t gChunkSizeKB = kDefaultChunkSizeKB;
 
 bool gTestingEnabled = false;
 
-class StorageDirectoryHelper
+class StorageOperationBase
   : public Runnable
 {
   mozilla::Mutex mMutex;
   mozilla::CondVar mCondVar;
   nsresult mMainThreadResultCode;
   bool mWaiting;
 
 protected:
@@ -1613,30 +1613,30 @@ protected:
 
   nsTArray<OriginProps> mOriginProps;
 
   nsCOMPtr<nsIFile> mDirectory;
 
   const bool mPersistent;
 
 public:
-  StorageDirectoryHelper(nsIFile* aDirectory, bool aPersistent)
-    : Runnable("dom::quota::StorageDirectoryHelper")
-    , mMutex("StorageDirectoryHelper::mMutex")
-    , mCondVar(mMutex, "StorageDirectoryHelper::mCondVar")
+  StorageOperationBase(nsIFile* aDirectory, bool aPersistent)
+    : Runnable("dom::quota::StorageOperationBase")
+    , mMutex("StorageOperationBase::mMutex")
+    , mCondVar(mMutex, "StorageOperationBase::mCondVar")
     , mMainThreadResultCode(NS_OK)
     , mWaiting(true)
     , mDirectory(aDirectory)
     , mPersistent(aPersistent)
   {
     AssertIsOnIOThread();
   }
 
 protected:
-  ~StorageDirectoryHelper()
+  virtual ~StorageOperationBase()
   { }
 
   nsresult
   GetDirectoryMetadata(nsIFile* aDirectory,
                        int64_t& aTimestamp,
                        nsACString& aGroup,
                        nsACString& aOrigin,
                        Nullable<bool>& aIsApp);
@@ -1667,17 +1667,17 @@ protected:
 private:
   nsresult
   RunOnMainThread();
 
   NS_IMETHOD
   Run() override;
 };
 
-struct StorageDirectoryHelper::OriginProps
+struct StorageOperationBase::OriginProps
 {
   enum Type
   {
     eChrome,
     eContent,
     eObsolete
   };
 
@@ -1796,83 +1796,83 @@ private:
 
   void
   HandleToken(const nsDependentCSubstring& aToken);
 
   void
   HandleTrailingSeparator();
 };
 
-class UpgradeOriginDirectoriesHelper
-  : public StorageDirectoryHelper
+class RepositoryOperationBase
+  : public StorageOperationBase
 {
 public:
-  UpgradeOriginDirectoriesHelper(nsIFile* aDirectory,
-                                 bool aPersistent)
-    : StorageDirectoryHelper(aDirectory, aPersistent)
+  RepositoryOperationBase(nsIFile* aDirectory,
+                          bool aPersistent)
+    : StorageOperationBase(aDirectory, aPersistent)
   { }
 
   nsresult
-  DoUpgrade();
+  ProcessRepository();
 
 protected:
-  virtual ~UpgradeOriginDirectoriesHelper()
+  virtual ~RepositoryOperationBase()
   { }
 
 private:
   virtual nsresult
   PrepareOriginDirectory(OriginProps& aOriginProps, bool* aRemoved) = 0;
 };
 
 class CreateOrUpgradeDirectoryMetadataHelper final
-  : public UpgradeOriginDirectoriesHelper
+  : public RepositoryOperationBase
 {
   nsCOMPtr<nsIFile> mPermanentStorageDir;
 
 public:
   CreateOrUpgradeDirectoryMetadataHelper(nsIFile* aDirectory,
                                          bool aPersistent)
-    : UpgradeOriginDirectoriesHelper(aDirectory, aPersistent)
+    : RepositoryOperationBase(aDirectory, aPersistent)
   { }
 
 private:
   nsresult
   MaybeUpgradeOriginDirectory(nsIFile* aDirectory);
 
   nsresult
   PrepareOriginDirectory(OriginProps& aOriginProps, bool* aRemoved) override;
 
   nsresult
   ProcessOriginDirectory(const OriginProps& aOriginProps) override;
 };
 
 class UpgradeStorageFrom0_0To1_0Helper final
-  : public UpgradeOriginDirectoriesHelper
+  : public RepositoryOperationBase
 {
 public:
   UpgradeStorageFrom0_0To1_0Helper(nsIFile* aDirectory,
                                    bool aPersistent)
-    : UpgradeOriginDirectoriesHelper(aDirectory, aPersistent)
+    : RepositoryOperationBase(aDirectory, aPersistent)
   { }
 
 private:
   nsresult
   PrepareOriginDirectory(OriginProps& aOriginProps, bool* aRemoved) override;
 
   nsresult
   ProcessOriginDirectory(const OriginProps& aOriginProps) override;
 };
 
 class UpgradeStorageFrom1_0To2_0Helper final
-  : public UpgradeOriginDirectoriesHelper
+  : public RepositoryOperationBase
 {
 public:
   UpgradeStorageFrom1_0To2_0Helper(nsIFile* aDirectory,
                                    bool aPersistent)
-    : UpgradeOriginDirectoriesHelper(aDirectory, aPersistent)
+    : RepositoryOperationBase(aDirectory, aPersistent)
   { }
 
 private:
   nsresult
   MaybeUpgradeClients(const OriginProps& aOriginProps);
 
   nsresult
   MaybeRemoveAppsData(const OriginProps& aOriginProps,
@@ -1885,42 +1885,42 @@ private:
   nsresult
   PrepareOriginDirectory(OriginProps& aOriginProps, bool* aRemoved) override;
 
   nsresult
   ProcessOriginDirectory(const OriginProps& aOriginProps) override;
 };
 
 class UpgradeStorageFrom2_0To2_1Helper final
-  : public UpgradeOriginDirectoriesHelper
+  : public RepositoryOperationBase
 {
 public:
   UpgradeStorageFrom2_0To2_1Helper(nsIFile* aDirectory,
                                    bool aPersistent)
-    : UpgradeOriginDirectoriesHelper(aDirectory, aPersistent)
+    : RepositoryOperationBase(aDirectory, aPersistent)
   { }
 
 private:
   nsresult
   MaybeUpgradeClients(const OriginProps& aOriginProps);
 
   nsresult
   PrepareOriginDirectory(OriginProps& aOriginProps, bool* aRemoved) override;
 
   nsresult
   ProcessOriginDirectory(const OriginProps& aOriginProps) override;
 };
 
 class RestoreDirectoryMetadata2Helper final
-  : public StorageDirectoryHelper
+  : public StorageOperationBase
 {
 public:
   RestoreDirectoryMetadata2Helper(nsIFile* aDirectory,
                                   bool aPersistent)
-    : StorageDirectoryHelper(aDirectory, aPersistent)
+    : StorageOperationBase(aDirectory, aPersistent)
   { }
 
   nsresult
   RestoreMetadata2File();
 
 private:
   nsresult
   ProcessOriginDirectory(const OriginProps& aOriginProps) override;
@@ -4479,17 +4479,17 @@ QuotaManager::MaybeUpgradePersistentStor
     return NS_OK;
   }
 
   // Create real metadata files for origin directories in persistent storage.
   RefPtr<CreateOrUpgradeDirectoryMetadataHelper> helper =
     new CreateOrUpgradeDirectoryMetadataHelper(persistentStorageDir,
                                                /* aPersistent */ true);
 
-  rv = helper->DoUpgrade();
+  rv = helper->ProcessRepository();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Upgrade metadata files for origin directories in temporary storage.
   nsCOMPtr<nsIFile> temporaryStorageDir;
   rv = NS_NewLocalFile(mTemporaryStoragePath, false,
                        getter_AddRefs(temporaryStorageDir));
@@ -4512,17 +4512,17 @@ QuotaManager::MaybeUpgradePersistentStor
       NS_WARNING("temporary entry is not a directory!");
       return NS_OK;
     }
 
     helper =
       new CreateOrUpgradeDirectoryMetadataHelper(temporaryStorageDir,
                                                  /* aPersistent */ false);
 
-    rv = helper->DoUpgrade();
+    rv = helper->ProcessRepository();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // And finally rename persistent to default.
   rv = persistentStorageDir->RenameTo(nullptr, NS_LITERAL_STRING(DEFAULT_DIRECTORY_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -4626,17 +4626,17 @@ QuotaManager::UpgradeStorageFrom0_0To1_0
     if (!exists) {
       continue;
     }
 
     bool persistent = persistenceType == PERSISTENCE_TYPE_PERSISTENT;
     RefPtr<UpgradeStorageFrom0_0To1_0Helper> helper =
       new UpgradeStorageFrom0_0To1_0Helper(directory, persistent);
 
-    rv = helper->DoUpgrade();
+    rv = helper->ProcessRepository();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
 #ifdef DEBUG
   {
     int32_t storageVersion;
@@ -4749,17 +4749,17 @@ QuotaManager::UpgradeStorageFrom1_0To2_0
     if (!exists) {
       continue;
     }
 
     bool persistent = persistenceType == PERSISTENCE_TYPE_PERSISTENT;
     RefPtr<UpgradeStorageFrom1_0To2_0Helper> helper =
       new UpgradeStorageFrom1_0To2_0Helper(directory, persistent);
 
-    rv = helper->DoUpgrade();
+    rv = helper->ProcessRepository();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
 #ifdef DEBUG
   {
     int32_t storageVersion;
@@ -4808,17 +4808,17 @@ QuotaManager::UpgradeStorageFrom2_0To2_1
     if (!exists) {
       continue;
     }
 
     bool persistent = persistenceType == PERSISTENCE_TYPE_PERSISTENT;
     RefPtr<UpgradeStorageFrom2_0To2_1Helper> helper =
       new UpgradeStorageFrom2_0To2_1Helper(directory, persistent);
 
-    rv = helper->DoUpgrade();
+    rv = helper->ProcessRepository();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
 #ifdef DEBUG
   {
     int32_t storageVersion;
@@ -8130,21 +8130,21 @@ void
 PersistOp::GetResponse(RequestResponse& aResponse)
 {
   AssertIsOnOwningThread();
 
   aResponse = PersistResponse();
 }
 
 nsresult
-StorageDirectoryHelper::GetDirectoryMetadata(nsIFile* aDirectory,
-                                             int64_t& aTimestamp,
-                                             nsACString& aGroup,
-                                             nsACString& aOrigin,
-                                             Nullable<bool>& aIsApp)
+StorageOperationBase::GetDirectoryMetadata(nsIFile* aDirectory,
+                                           int64_t& aTimestamp,
+                                           nsACString& aGroup,
+                                           nsACString& aOrigin,
+                                           Nullable<bool>& aIsApp)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aDirectory);
 
   nsCOMPtr<nsIBinaryInputStream> binaryStream;
   nsresult rv = GetBinaryInputStream(aDirectory,
                                      NS_LITERAL_STRING(METADATA_FILE_NAME),
                                      getter_AddRefs(binaryStream));
@@ -8179,22 +8179,22 @@ StorageDirectoryHelper::GetDirectoryMeta
   aTimestamp = timestamp;
   aGroup = group;
   aOrigin = origin;
   aIsApp = std::move(isApp);
   return NS_OK;
 }
 
 nsresult
-StorageDirectoryHelper::GetDirectoryMetadata2(nsIFile* aDirectory,
-                                              int64_t& aTimestamp,
-                                              nsACString& aSuffix,
-                                              nsACString& aGroup,
-                                              nsACString& aOrigin,
-                                              bool& aIsApp)
+StorageOperationBase::GetDirectoryMetadata2(nsIFile* aDirectory,
+                                            int64_t& aTimestamp,
+                                            nsACString& aSuffix,
+                                            nsACString& aGroup,
+                                            nsACString& aOrigin,
+                                            bool& aIsApp)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aDirectory);
 
   nsCOMPtr<nsIBinaryInputStream> binaryStream;
   nsresult rv = GetBinaryInputStream(aDirectory,
                                      NS_LITERAL_STRING(METADATA_V2_FILE_NAME),
                                      getter_AddRefs(binaryStream));
@@ -8254,34 +8254,34 @@ StorageDirectoryHelper::GetDirectoryMeta
   aSuffix = suffix;
   aGroup = group;
   aOrigin = origin;
   aIsApp = isApp;
   return NS_OK;
 }
 
 nsresult
-StorageDirectoryHelper::RemoveObsoleteOrigin(const OriginProps& aOriginProps)
+StorageOperationBase::RemoveObsoleteOrigin(const OriginProps& aOriginProps)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aOriginProps.mDirectory);
 
   QM_WARNING("Deleting obsolete %s directory that is no longer a legal "
              "origin!", NS_ConvertUTF16toUTF8(aOriginProps.mLeafName).get());
 
   nsresult rv = aOriginProps.mDirectory->Remove(/* recursive */ true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 nsresult
-StorageDirectoryHelper::ProcessOriginDirectories()
+StorageOperationBase::ProcessOriginDirectories()
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(!mOriginProps.IsEmpty());
 
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this));
 
   {
     mozilla::MutexAutoLock autolock(mMutex);
@@ -8321,17 +8321,17 @@ StorageDirectoryHelper::ProcessOriginDir
       return rv;
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-StorageDirectoryHelper::RunOnMainThread()
+StorageOperationBase::RunOnMainThread()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mOriginProps.IsEmpty());
 
   nsresult rv;
 
   for (uint32_t count = mOriginProps.Length(), index = 0;
        index < count;
@@ -8379,17 +8379,17 @@ StorageDirectoryHelper::RunOnMainThread(
         MOZ_CRASH("Bad type!");
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-StorageDirectoryHelper::Run()
+StorageOperationBase::Run()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsresult rv = RunOnMainThread();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mMainThreadResultCode = rv;
   }
 
@@ -8398,18 +8398,17 @@ StorageDirectoryHelper::Run()
 
   mWaiting = false;
   mCondVar.Notify();
 
   return NS_OK;
 }
 
 nsresult
-StorageDirectoryHelper::
-OriginProps::Init(nsIFile* aDirectory)
+StorageOperationBase::OriginProps::Init(nsIFile* aDirectory)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aDirectory);
 
   nsString leafName;
   nsresult rv = aDirectory->GetLeafName(leafName);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -8830,17 +8829,17 @@ OriginParser::HandleTrailingSeparator()
   MOZ_ASSERT(mSchemeType == eFile);
 
   mPathnameComponents.AppendElement(EmptyCString());
 
   mState = eHandledTrailingSeparator;
 }
 
 nsresult
-UpgradeOriginDirectoriesHelper::DoUpgrade()
+RepositoryOperationBase::ProcessRepository()
 {
   AssertIsOnIOThread();
 
   DebugOnly<bool> exists;
   MOZ_ASSERT(NS_SUCCEEDED(mDirectory->Exists(&exists)));
   MOZ_ASSERT(exists);
 
   nsCOMPtr<nsIDirectoryEnumerator> entries;