Bug 1672140 - Rename cache::ClientMetadata to cache::CacheDirectoryMetadata; r=dom-storage-reviewers,janv
☠☠ backed out by 474fe4e3dd24 ☠ ☠
authorHaiyang Xu <hxu@mozilla.com>
Tue, 23 Nov 2021 16:53:50 +0000
changeset 599933 32edbc243607a5ffaf19797c0ac8a89da0b4abba
parent 599932 549556f430a74928d30c46de65e840ffb7aedeb4
child 599934 2b2e11035eccda312c00811b180d337881d2c62f
push id39004
push userabutkovits@mozilla.com
push dateTue, 23 Nov 2021 21:51:13 +0000
treeherdermozilla-central@853874dee29b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-storage-reviewers, janv
bugs1672140
milestone96.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 1672140 - Rename cache::ClientMetadata to cache::CacheDirectoryMetadata; r=dom-storage-reviewers,janv Differential Revision: https://phabricator.services.mozilla.com/D131590
dom/cache/Action.h
dom/cache/Context.cpp
dom/cache/Context.h
dom/cache/DBAction.cpp
dom/cache/DBAction.h
dom/cache/FileUtils.cpp
dom/cache/FileUtils.h
dom/cache/FileUtilsImpl.h
dom/cache/Manager.cpp
dom/cache/QuotaClient.cpp
dom/cache/QuotaClient.h
dom/cache/QuotaClientImpl.h
dom/cache/Types.h
--- a/dom/cache/Action.h
+++ b/dom/cache/Action.h
@@ -50,19 +50,20 @@ class Action : public SafeRefCounted<Act
   // virtual because deleted through base class pointer
   virtual ~Action();
 
   // Execute operations on the target thread.  Once complete call
   // Resolver::Resolve().  This can be done sync or async.
   // Note: Action should hold Resolver ref until its ready to call Resolve().
   // Note: The "target" thread is determined when the Action is scheduled on
   //       Context.  The Action should not assume any particular thread is used.
-  virtual void RunOnTarget(SafeRefPtr<Resolver> aResolver,
-                           const Maybe<ClientMetadata>& aClientMetadata,
-                           Data* aOptionalData) = 0;
+  virtual void RunOnTarget(
+      SafeRefPtr<Resolver> aResolver,
+      const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
+      Data* aOptionalData) = 0;
 
   // Called on initiating thread when the Action is canceled.  The Action is
   // responsible for calling Resolver::Resolve() as normal; either with a
   // normal error code or NS_ERROR_ABORT.  If CancelOnInitiatingThread() is
   // called after Resolve() has already occurred, then the cancel can be
   // ignored.
   //
   // Cancellation is a best effort to stop processing as soon as possible, but
--- a/dom/cache/Context.cpp
+++ b/dom/cache/Context.cpp
@@ -20,24 +20,24 @@
 #include "nsIPrincipal.h"
 #include "nsIRunnable.h"
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 
 namespace {
 
 using mozilla::dom::cache::Action;
-using mozilla::dom::cache::ClientMetadata;
+using mozilla::dom::cache::CacheDirectoryMetadata;
 
 class NullAction final : public Action {
  public:
   NullAction() = default;
 
   virtual void RunOnTarget(mozilla::SafeRefPtr<Resolver> aResolver,
-                           const mozilla::Maybe<ClientMetadata>&,
+                           const mozilla::Maybe<CacheDirectoryMetadata>&,
                            Data*) override {
     // Resolve success immediately.  This Action does no actual work.
     MOZ_DIAGNOSTIC_ASSERT(aResolver);
     aResolver->Resolve(NS_OK);
   }
 };
 
 }  // namespace
@@ -211,36 +211,37 @@ class Context::QuotaInitRunnable final :
   SafeRefPtr<Context> mContext;
   SafeRefPtr<ThreadsafeHandle> mThreadsafeHandle;
   SafeRefPtr<Manager> mManager;
   RefPtr<Data> mData;
   nsCOMPtr<nsISerialEventTarget> mTarget;
   SafeRefPtr<Action> mInitAction;
   nsCOMPtr<nsIEventTarget> mInitiatingEventTarget;
   nsresult mResult;
-  Maybe<ClientMetadata> mClientMetadata;
+  Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
   RefPtr<DirectoryLock> mDirectoryLock;
   State mState;
   Atomic<bool> mCanceled;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
 };
 
 void Context::QuotaInitRunnable::OpenDirectory() {
   NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
   MOZ_DIAGNOSTIC_ASSERT(mState == STATE_CREATE_QUOTA_MANAGER ||
                         mState == STATE_OPEN_DIRECTORY);
   MOZ_DIAGNOSTIC_ASSERT(QuotaManager::Get());
 
   RefPtr<DirectoryLock> directoryLock =
-      QuotaManager::Get()->CreateDirectoryLock(
-          PERSISTENCE_TYPE_DEFAULT, *mClientMetadata, quota::Client::DOMCACHE,
-          /* aExclusive */ false);
+      QuotaManager::Get()->CreateDirectoryLock(PERSISTENCE_TYPE_DEFAULT,
+                                               *mDirectoryMetadata,
+                                               quota::Client::DOMCACHE,
+                                               /* aExclusive */ false);
 
   // DirectoryLock::Acquire() will hold a reference to us as a listener. We will
   // then get DirectoryLockAcquired() on the owning thread when it is safe to
   // access our storage directory.
   mState = STATE_WAIT_FOR_DIRECTORY_LOCK;
   directoryLock->Acquire(this);
 }
 
@@ -248,17 +249,17 @@ void Context::QuotaInitRunnable::Directo
   NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
   MOZ_DIAGNOSTIC_ASSERT(aLock);
   MOZ_DIAGNOSTIC_ASSERT(mState == STATE_WAIT_FOR_DIRECTORY_LOCK);
   MOZ_DIAGNOSTIC_ASSERT(!mDirectoryLock);
 
   mDirectoryLock = aLock;
 
   MOZ_DIAGNOSTIC_ASSERT(mDirectoryLock->Id() >= 0);
-  mClientMetadata->mDirectoryLockId = mDirectoryLock->Id();
+  mDirectoryMetadata->mDirectoryLockId = mDirectoryLock->Id();
 
   if (mCanceled) {
     Complete(NS_ERROR_ABORT);
     return;
   }
 
   QuotaManager* qm = QuotaManager::Get();
   MOZ_DIAGNOSTIC_ASSERT(qm);
@@ -348,17 +349,17 @@ Context::QuotaInitRunnable::Run() {
           return Err(NS_ERROR_ABORT);
         }
 
         nsCOMPtr<nsIPrincipal> principal = mManager->GetManagerId().Principal();
 
         QM_TRY_UNWRAP(auto principalMetadata,
                       QuotaManager::GetInfoFromPrincipal(principal));
 
-        mClientMetadata.emplace(std::move(principalMetadata));
+        mDirectoryMetadata.emplace(std::move(principalMetadata));
 
         mState = STATE_CREATE_QUOTA_MANAGER;
 
         MOZ_ALWAYS_SUCCEEDS(
             mInitiatingEventTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
 
         return Ok{};
       }();
@@ -411,20 +412,20 @@ Context::QuotaInitRunnable::Run() {
         QuotaManager* quotaManager = QuotaManager::Get();
         MOZ_DIAGNOSTIC_ASSERT(quotaManager);
 
         QM_TRY(MOZ_TO_RESULT(quotaManager->EnsureStorageIsInitialized()));
 
         QM_TRY(
             MOZ_TO_RESULT(quotaManager->EnsureTemporaryStorageIsInitialized()));
 
-        QM_TRY_UNWRAP(mClientMetadata->mDir,
+        QM_TRY_UNWRAP(mDirectoryMetadata->mDir,
                       quotaManager
                           ->EnsureTemporaryOriginIsInitialized(
-                              PERSISTENCE_TYPE_DEFAULT, *mClientMetadata)
+                              PERSISTENCE_TYPE_DEFAULT, *mDirectoryMetadata)
                           .map([](const auto& res) { return res.first; }));
 
         mState = STATE_RUN_ON_TARGET;
 
         MOZ_ALWAYS_SUCCEEDS(
             mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
 
         return Ok{};
@@ -439,35 +440,36 @@ Context::QuotaInitRunnable::Run() {
     // -------------------
     case STATE_RUN_ON_TARGET: {
       MOZ_ASSERT(mTarget->IsOnCurrentThread());
 
       mState = STATE_RUNNING;
 
       // Execute the provided initialization Action.  The Action must Resolve()
       // before returning.
-      mInitAction->RunOnTarget(resolver.clonePtr(), mClientMetadata, mData);
+      mInitAction->RunOnTarget(resolver.clonePtr(), mDirectoryMetadata, mData);
       MOZ_DIAGNOSTIC_ASSERT(resolver->Resolved());
 
       mData = nullptr;
 
       // If the database was opened, then we should always succeed when creating
       // the marker file.  If it wasn't opened successfully, then no need to
       // create a marker file anyway.
       if (NS_SUCCEEDED(resolver->Result())) {
-        MOZ_ALWAYS_SUCCEEDS(CreateMarkerFile(*mClientMetadata));
+        MOZ_ALWAYS_SUCCEEDS(CreateMarkerFile(*mDirectoryMetadata));
       }
 
       break;
     }
     // -------------------
     case STATE_COMPLETING: {
       NS_ASSERT_OWNINGTHREAD(QuotaInitRunnable);
       mInitAction->CompleteOnInitiatingThread(mResult);
-      mContext->OnQuotaInit(mResult, mClientMetadata, mDirectoryLock.forget());
+      mContext->OnQuotaInit(mResult, mDirectoryMetadata,
+                            mDirectoryLock.forget());
       mState = STATE_COMPLETE;
 
       // Explicitly cleanup here as the destructor could fire on any of
       // the threads we have bounced through.
       Clear();
       break;
     }
     // -----
@@ -488,31 +490,31 @@ Context::QuotaInitRunnable::Run() {
 // runnable executes the Action on the appropriate threads while the Context
 // is initialized.
 class Context::ActionRunnable final : public nsIRunnable,
                                       public Action::Resolver,
                                       public Context::Activity {
  public:
   ActionRunnable(SafeRefPtr<Context> aContext, Data* aData,
                  nsISerialEventTarget* aTarget, SafeRefPtr<Action> aAction,
-                 const Maybe<ClientMetadata>& aClientMetadata)
+                 const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata)
       : mContext(std::move(aContext)),
         mData(aData),
         mTarget(aTarget),
         mAction(std::move(aAction)),
-        mClientMetadata(aClientMetadata),
+        mDirectoryMetadata(aDirectoryMetadata),
         mInitiatingThread(GetCurrentEventTarget()),
         mState(STATE_INIT),
         mResult(NS_OK),
         mExecutingRunOnTarget(false) {
     MOZ_DIAGNOSTIC_ASSERT(mContext);
     // mData may be nullptr
     MOZ_DIAGNOSTIC_ASSERT(mTarget);
     MOZ_DIAGNOSTIC_ASSERT(mAction);
-    // mClientMetadata.mDir may be nullptr if QuotaInitRunnable failed
+    // mDirectoryMetadata.mDir may be nullptr if QuotaInitRunnable failed
     MOZ_DIAGNOSTIC_ASSERT(mInitiatingThread);
   }
 
   nsresult Dispatch() {
     NS_ASSERT_OWNINGTHREAD(ActionRunnable);
     MOZ_DIAGNOSTIC_ASSERT(mState == STATE_INIT);
 
     mState = STATE_RUN_ON_TARGET;
@@ -582,17 +584,17 @@ class Context::ActionRunnable final : pu
     STATE_COMPLETING,
     STATE_COMPLETE
   };
 
   SafeRefPtr<Context> mContext;
   RefPtr<Data> mData;
   nsCOMPtr<nsISerialEventTarget> mTarget;
   SafeRefPtr<Action> mAction;
-  const Maybe<ClientMetadata> mClientMetadata;
+  const Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
   nsCOMPtr<nsIEventTarget> mInitiatingThread;
   State mState;
   nsresult mResult;
 
   // Only accessible on target thread;
   bool mExecutingRunOnTarget;
 
  public:
@@ -644,17 +646,17 @@ Context::ActionRunnable::Run() {
       MOZ_DIAGNOSTIC_ASSERT(!mExecutingRunOnTarget);
 
       // Note that we are calling RunOnTarget().  This lets us detect
       // if Resolve() is called synchronously.
       AutoRestore<bool> executingRunOnTarget(mExecutingRunOnTarget);
       mExecutingRunOnTarget = true;
 
       mState = STATE_RUNNING;
-      mAction->RunOnTarget(SafeRefPtrFromThis(), mClientMetadata, mData);
+      mAction->RunOnTarget(SafeRefPtrFromThis(), mDirectoryMetadata, mData);
 
       mData = nullptr;
 
       // Resolve was called synchronously from RunOnTarget().  We can
       // immediately move to completing now since we are sure RunOnTarget()
       // completed.
       if (mState == STATE_RESOLVING) {
         // Use recursion instead of switch case fall-through...  Seems slightly
@@ -916,18 +918,18 @@ Context::~Context() {
 
   if (mThreadsafeHandle) {
     mThreadsafeHandle->ContextDestroyed(*this);
   }
 
   // Note, this may set the mOrphanedData flag.
   mManager->RemoveContext(*this);
 
-  if (mClientMetadata && mClientMetadata->mDir && !mOrphanedData) {
-    MOZ_ALWAYS_SUCCEEDS(DeleteMarkerFile(*mClientMetadata));
+  if (mDirectoryMetadata && mDirectoryMetadata->mDir && !mOrphanedData) {
+    MOZ_ALWAYS_SUCCEEDS(DeleteMarkerFile(*mDirectoryMetadata));
   }
 
   if (mNextContext) {
     mNextContext->Start();
   }
 }
 
 void Context::Init(Maybe<Context&> aOldContext) {
@@ -974,41 +976,41 @@ void Context::Start() {
   }
 }
 
 void Context::DispatchAction(SafeRefPtr<Action> aAction, bool aDoomData) {
   NS_ASSERT_OWNINGTHREAD(Context);
 
   auto runnable =
       MakeSafeRefPtr<ActionRunnable>(SafeRefPtrFromThis(), mData, mTarget,
-                                     std::move(aAction), mClientMetadata);
+                                     std::move(aAction), mDirectoryMetadata);
 
   if (aDoomData) {
     mData = nullptr;
   }
 
   nsresult rv = runnable->Dispatch();
   if (NS_FAILED(rv)) {
     // Shutdown must be delayed until all Contexts are destroyed.  Crash
     // for this invariant violation.
     MOZ_CRASH("Failed to dispatch ActionRunnable to target thread.");
   }
   AddActivity(*runnable);
 }
 
-void Context::OnQuotaInit(nsresult aRv,
-                          const Maybe<ClientMetadata>& aClientMetadata,
-                          already_AddRefed<DirectoryLock> aDirectoryLock) {
+void Context::OnQuotaInit(
+    nsresult aRv, const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
+    already_AddRefed<DirectoryLock> aDirectoryLock) {
   NS_ASSERT_OWNINGTHREAD(Context);
 
   MOZ_DIAGNOSTIC_ASSERT(mInitRunnable);
   mInitRunnable = nullptr;
 
-  if (aClientMetadata) {
-    mClientMetadata.emplace(*aClientMetadata);
+  if (aDirectoryMetadata) {
+    mDirectoryMetadata.emplace(*aDirectoryMetadata);
   }
 
   // Always save the directory lock to ensure QuotaManager does not shutdown
   // before the Context has gone away.
   MOZ_DIAGNOSTIC_ASSERT(!mDirectoryLock);
   mDirectoryLock = aDirectoryLock;
 
   // If we opening the context failed, but we were not explicitly canceled,
--- a/dom/cache/Context.h
+++ b/dom/cache/Context.h
@@ -172,31 +172,32 @@ class Context final : public SafeRefCoun
   struct PendingAction {
     nsCOMPtr<nsIEventTarget> mTarget;
     SafeRefPtr<Action> mAction;
   };
 
   void Init(Maybe<Context&> aOldContext);
   void Start();
   void DispatchAction(SafeRefPtr<Action> aAction, bool aDoomData = false);
-  void OnQuotaInit(nsresult aRv, const Maybe<ClientMetadata>& aClientMetadata,
+  void OnQuotaInit(nsresult aRv,
+                   const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
                    already_AddRefed<DirectoryLock> aDirectoryLock);
 
   SafeRefPtr<ThreadsafeHandle> CreateThreadsafeHandle();
 
   void SetNextContext(SafeRefPtr<Context> aNextContext);
 
   void DoomTargetData();
 
   SafeRefPtr<Manager> mManager;
   nsCOMPtr<nsISerialEventTarget> mTarget;
   RefPtr<Data> mData;
   State mState;
   bool mOrphanedData;
-  Maybe<ClientMetadata> mClientMetadata;
+  Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
   RefPtr<QuotaInitRunnable> mInitRunnable;
   SafeRefPtr<Action> mInitAction;
   nsTArray<PendingAction> mPendingActions;
 
   // Weak refs since activites must remove themselves from this list before
   // being destroyed by calling RemoveActivity().
   nsTObserverArray<NotNull<Activity*>> mActivityList;
 
--- a/dom/cache/DBAction.cpp
+++ b/dom/cache/DBAction.cpp
@@ -27,143 +27,145 @@ using mozilla::dom::quota::AssertIsOnIOT
 using mozilla::dom::quota::Client;
 using mozilla::dom::quota::CloneFileAndAppend;
 using mozilla::dom::quota::IsDatabaseCorruptionError;
 using mozilla::dom::quota::PERSISTENCE_TYPE_DEFAULT;
 using mozilla::dom::quota::PersistenceType;
 
 namespace {
 
-nsresult WipeDatabase(const ClientMetadata& aClientMetadata, nsIFile& aDBFile) {
+nsresult WipeDatabase(const CacheDirectoryMetadata& aDirectoryMetadata,
+                      nsIFile& aDBFile) {
   QM_TRY_INSPECT(const auto& dbDir, MOZ_TO_RESULT_INVOKE_TYPED(
                                         nsCOMPtr<nsIFile>, aDBFile, GetParent));
 
-  QM_TRY(MOZ_TO_RESULT(RemoveNsIFile(aClientMetadata, aDBFile)));
+  QM_TRY(MOZ_TO_RESULT(RemoveNsIFile(aDirectoryMetadata, aDBFile)));
 
   // Note, the -wal journal file will be automatically deleted by sqlite when
   // the new database is created.  No need to explicitly delete it here.
 
   // Delete the morgue as well.
-  QM_TRY(MOZ_TO_RESULT(BodyDeleteDir(aClientMetadata, *dbDir)));
+  QM_TRY(MOZ_TO_RESULT(BodyDeleteDir(aDirectoryMetadata, *dbDir)));
 
-  QM_TRY(MOZ_TO_RESULT(WipePaddingFile(aClientMetadata, dbDir)));
+  QM_TRY(MOZ_TO_RESULT(WipePaddingFile(aDirectoryMetadata, dbDir)));
 
   return NS_OK;
 }
 
 }  // namespace
 
 DBAction::DBAction(Mode aMode) : mMode(aMode) {}
 
 DBAction::~DBAction() = default;
 
-void DBAction::RunOnTarget(SafeRefPtr<Resolver> aResolver,
-                           const Maybe<ClientMetadata>& aClientMetadata,
-                           Data* aOptionalData) {
+void DBAction::RunOnTarget(
+    SafeRefPtr<Resolver> aResolver,
+    const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
+    Data* aOptionalData) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aResolver);
-  MOZ_DIAGNOSTIC_ASSERT(aClientMetadata);
-  MOZ_DIAGNOSTIC_ASSERT(aClientMetadata->mDir);
+  MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata);
+  MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata->mDir);
 
   if (IsCanceled()) {
     aResolver->Resolve(NS_ERROR_ABORT);
     return;
   }
 
   const auto resolveErr = [&aResolver](const nsresult rv) {
     aResolver->Resolve(rv);
   };
 
   QM_TRY_INSPECT(const auto& dbDir,
-                 CloneFileAndAppend(*(aClientMetadata->mDir), u"cache"_ns),
+                 CloneFileAndAppend(*(aDirectoryMetadata->mDir), u"cache"_ns),
                  QM_VOID, resolveErr);
 
   nsCOMPtr<mozIStorageConnection> conn;
 
   // Attempt to reuse the connection opened by a previous Action.
   if (aOptionalData) {
     conn = aOptionalData->GetConnection();
   }
 
   // If there is no previous Action, then we must open one.
   if (!conn) {
-    QM_TRY_UNWRAP(conn, OpenConnection(*aClientMetadata, *dbDir), QM_VOID,
+    QM_TRY_UNWRAP(conn, OpenConnection(*aDirectoryMetadata, *dbDir), QM_VOID,
                   resolveErr);
     MOZ_DIAGNOSTIC_ASSERT(conn);
 
     // Save this connection in the shared Data object so later Actions can
     // use it.  This avoids opening a new connection for every Action.
     if (aOptionalData) {
       // Since we know this connection will be around for as long as the
       // Cache is open, use our special wrapped connection class.  This
       // will let us perform certain operations once the Cache origin
       // is closed.
       nsCOMPtr<mozIStorageConnection> wrapped = new Connection(conn);
       aOptionalData->SetConnection(wrapped);
     }
   }
 
-  RunWithDBOnTarget(std::move(aResolver), *aClientMetadata, dbDir, conn);
+  RunWithDBOnTarget(std::move(aResolver), *aDirectoryMetadata, dbDir, conn);
 }
 
 Result<nsCOMPtr<mozIStorageConnection>, nsresult> DBAction::OpenConnection(
-    const ClientMetadata& aClientMetadata, nsIFile& aDBDir) {
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aDBDir) {
   MOZ_ASSERT(!NS_IsMainThread());
-  MOZ_DIAGNOSTIC_ASSERT(aClientMetadata.mDirectoryLockId >= 0);
+  MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata.mDirectoryLockId >= 0);
 
   QM_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(aDBDir, Exists));
 
   if (!exists) {
     QM_TRY(OkIf(mMode == Create), Err(NS_ERROR_FILE_NOT_FOUND));
     QM_TRY(MOZ_TO_RESULT(aDBDir.Create(nsIFile::DIRECTORY_TYPE, 0755)));
   }
 
   QM_TRY_INSPECT(const auto& dbFile,
                  CloneFileAndAppend(aDBDir, kCachesSQLiteFilename));
 
-  QM_TRY_RETURN(OpenDBConnection(aClientMetadata, *dbFile));
+  QM_TRY_RETURN(OpenDBConnection(aDirectoryMetadata, *dbFile));
 }
 
 SyncDBAction::SyncDBAction(Mode aMode) : DBAction(aMode) {}
 
 SyncDBAction::~SyncDBAction() = default;
 
-void SyncDBAction::RunWithDBOnTarget(SafeRefPtr<Resolver> aResolver,
-                                     const ClientMetadata& aClientMetadata,
-                                     nsIFile* aDBDir,
-                                     mozIStorageConnection* aConn) {
+void SyncDBAction::RunWithDBOnTarget(
+    SafeRefPtr<Resolver> aResolver,
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
+    mozIStorageConnection* aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aResolver);
   MOZ_DIAGNOSTIC_ASSERT(aDBDir);
   MOZ_DIAGNOSTIC_ASSERT(aConn);
 
-  nsresult rv = RunSyncWithDBOnTarget(aClientMetadata, aDBDir, aConn);
+  nsresult rv = RunSyncWithDBOnTarget(aDirectoryMetadata, aDBDir, aConn);
   aResolver->Resolve(rv);
 }
 
 Result<nsCOMPtr<mozIStorageConnection>, nsresult> OpenDBConnection(
-    const ClientMetadata& aClientMetadata, nsIFile& aDBFile) {
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aDBFile) {
   MOZ_ASSERT(!NS_IsMainThread());
-  MOZ_DIAGNOSTIC_ASSERT(aClientMetadata.mDirectoryLockId >= -1);
+  MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata.mDirectoryLockId >= -1);
 
   // Use our default file:// protocol handler directly to construct the database
   // URL.  This avoids any problems if a plugin registers a custom file://
   // handler.  If such a custom handler used javascript, then we would have a
   // bad time running off the main thread here.
   auto handler = MakeRefPtr<nsFileProtocolHandler>();
   QM_TRY(MOZ_TO_RESULT(handler->Init()));
 
   QM_TRY_INSPECT(const auto& mutator,
                  MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIURIMutator>, handler,
                                             NewFileURIMutator, &aDBFile));
 
   const nsCString directoryLockIdClause =
-      aClientMetadata.mDirectoryLockId >= 0
+      aDirectoryMetadata.mDirectoryLockId >= 0
           ? "&directoryLockId="_ns +
-                IntToCString(aClientMetadata.mDirectoryLockId)
+                IntToCString(aDirectoryMetadata.mDirectoryLockId)
           : EmptyCString();
 
   nsCOMPtr<nsIFileURL> dbFileUrl;
   QM_TRY(MOZ_TO_RESULT(NS_MutateURI(mutator)
                            .SetQuery("cache=private"_ns + directoryLockIdClause)
                            .Finalize(dbFileUrl)));
 
   QM_TRY_INSPECT(const auto& storageService,
@@ -177,38 +179,38 @@ Result<nsCOMPtr<mozIStorageConnection>, 
       QM_OR_ELSE_WARN_IF(
           // Expression.
           MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>,
                                      storageService, OpenDatabaseWithFileURL,
                                      dbFileUrl, ""_ns),
           // Predicate.
           IsDatabaseCorruptionError,
           // Fallback.
-          ([&aClientMetadata, &aDBFile, &storageService,
+          ([&aDirectoryMetadata, &aDBFile, &storageService,
             &dbFileUrl](const nsresult rv)
                -> Result<nsCOMPtr<mozIStorageConnection>, nsresult> {
             NS_WARNING("Cache database corrupted. Recreating empty database.");
 
             // There is nothing else we can do to recover.  Also, this data
             // can be deleted by QuotaManager at any time anyways.
-            QM_TRY(MOZ_TO_RESULT(WipeDatabase(aClientMetadata, aDBFile)));
+            QM_TRY(MOZ_TO_RESULT(WipeDatabase(aDirectoryMetadata, aDBFile)));
 
             QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
                 nsCOMPtr<mozIStorageConnection>, storageService,
                 OpenDatabaseWithFileURL, dbFileUrl, ""_ns));
           })));
 
   // Check the schema to make sure it is not too old.
   QM_TRY_INSPECT(const int32_t& schemaVersion,
                  MOZ_TO_RESULT_INVOKE(conn, GetSchemaVersion));
   if (schemaVersion > 0 && schemaVersion < db::kFirstShippedSchemaVersion) {
     // Close existing connection before wiping database.
     conn = nullptr;
 
-    QM_TRY(MOZ_TO_RESULT(WipeDatabase(aClientMetadata, aDBFile)));
+    QM_TRY(MOZ_TO_RESULT(WipeDatabase(aDirectoryMetadata, aDBFile)));
 
     QM_TRY_UNWRAP(conn, MOZ_TO_RESULT_INVOKE_TYPED(
                             nsCOMPtr<mozIStorageConnection>, storageService,
                             OpenDatabaseWithFileURL, dbFileUrl, ""_ns));
   }
 
   QM_TRY(MOZ_TO_RESULT(db::InitializeConnection(*conn)));
 
--- a/dom/cache/DBAction.h
+++ b/dom/cache/DBAction.h
@@ -14,63 +14,63 @@
 class mozIStorageConnection;
 class nsIFile;
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 Result<nsCOMPtr<mozIStorageConnection>, nsresult> OpenDBConnection(
-    const ClientMetadata& aClientMetadata, nsIFile& aDBFile);
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aDBFile);
 
 class DBAction : public Action {
  protected:
   // The mode specifies whether the database should already exist or if its
   // ok to create a new database.
   enum Mode { Existing, Create };
 
   explicit DBAction(Mode aMode);
 
   // Action objects are deleted through their base pointer
   virtual ~DBAction();
 
   // Just as the resolver must be ref'd until resolve, you may also
   // ref the DB connection.  The connection can only be referenced from the
   // target thread and must be released upon resolve.
-  virtual void RunWithDBOnTarget(SafeRefPtr<Resolver> aResolver,
-                                 const ClientMetadata& aClientMetadata,
-                                 nsIFile* aDBDir,
-                                 mozIStorageConnection* aConn) = 0;
+  virtual void RunWithDBOnTarget(
+      SafeRefPtr<Resolver> aResolver,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
+      mozIStorageConnection* aConn) = 0;
 
  private:
   void RunOnTarget(SafeRefPtr<Resolver> aResolver,
-                   const Maybe<ClientMetadata>& aClientMetadata,
+                   const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
                    Data* aOptionalData) override;
 
   Result<nsCOMPtr<mozIStorageConnection>, nsresult> OpenConnection(
-      const ClientMetadata& aClientMetadata, nsIFile& aDBDir);
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aDBDir);
 
   const Mode mMode;
 };
 
 class SyncDBAction : public DBAction {
  protected:
   explicit SyncDBAction(Mode aMode);
 
   // Action objects are deleted through their base pointer
   virtual ~SyncDBAction();
 
-  virtual nsresult RunSyncWithDBOnTarget(const ClientMetadata& aClientMetadata,
-                                         nsIFile* aDBDir,
-                                         mozIStorageConnection* aConn) = 0;
+  virtual nsresult RunSyncWithDBOnTarget(
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
+      mozIStorageConnection* aConn) = 0;
 
  private:
-  virtual void RunWithDBOnTarget(SafeRefPtr<Resolver> aResolver,
-                                 const ClientMetadata& aClientMetadata,
-                                 nsIFile* aDBDir,
-                                 mozIStorageConnection* aConn) override;
+  virtual void RunWithDBOnTarget(
+      SafeRefPtr<Resolver> aResolver,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
+      mozIStorageConnection* aConn) override;
 };
 
 }  // namespace cache
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // mozilla_dom_cache_DBAction_h
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -111,28 +111,28 @@ nsresult BodyCreateDir(nsIFile& aBaseDir
       // Predicate.
       IsSpecificError<NS_ERROR_FILE_ALREADY_EXISTS>,
       // Fallback.
       ErrToDefaultOk<>));
 
   return NS_OK;
 }
 
-nsresult BodyDeleteDir(const ClientMetadata& aClientMetadata,
+nsresult BodyDeleteDir(const CacheDirectoryMetadata& aDirectoryMetadata,
                        nsIFile& aBaseDir) {
   QM_TRY_INSPECT(const auto& bodyDir,
                  CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
-  QM_TRY(MOZ_TO_RESULT(RemoveNsIFileRecursively(aClientMetadata, *bodyDir)));
+  QM_TRY(MOZ_TO_RESULT(RemoveNsIFileRecursively(aDirectoryMetadata, *bodyDir)));
 
   return NS_OK;
 }
 
 Result<std::pair<nsID, nsCOMPtr<nsISupports>>, nsresult> BodyStartWriteStream(
-    const ClientMetadata& aClientMetadata, nsIFile& aBaseDir,
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
     nsIInputStream& aSource, void* aClosure, nsAsyncCopyCallbackFun aCallback) {
   MOZ_DIAGNOSTIC_ASSERT(aClosure);
   MOZ_DIAGNOSTIC_ASSERT(aCallback);
 
   QM_TRY_INSPECT(const auto& idGen,
                  MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<nsIUUIDGenerator>,
                                          MOZ_SELECT_OVERLOAD(do_GetService),
                                          "@mozilla.org/uuid-generator;1"));
@@ -150,17 +150,17 @@ Result<std::pair<nsID, nsCOMPtr<nsISuppo
     QM_TRY(OkIf(!exists), Err(NS_ERROR_FILE_ALREADY_EXISTS));
   }
 
   QM_TRY_INSPECT(const auto& tmpFile,
                  BodyIdToFile(aBaseDir, id, BODY_FILE_TMP));
 
   QM_TRY_INSPECT(
       const auto& fileStream,
-      CreateFileOutputStream(PERSISTENCE_TYPE_DEFAULT, aClientMetadata,
+      CreateFileOutputStream(PERSISTENCE_TYPE_DEFAULT, aDirectoryMetadata,
                              Client::DOMCACHE, tmpFile.get()));
 
   const auto compressed =
       MakeRefPtr<SnappyCompressOutputStream>(fileStream.get());
 
   const nsCOMPtr<nsIEventTarget> target =
       do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
 
@@ -196,43 +196,43 @@ nsresult BodyFinalizeWrite(nsIFile& aBas
   // because its path will be updated and its size will be recalculated when
   // opening file next time.
   QM_TRY(MOZ_TO_RESULT(tmpFile->RenameTo(nullptr, finalFileName)));
 
   return NS_OK;
 }
 
 Result<NotNull<nsCOMPtr<nsIInputStream>>, nsresult> BodyOpen(
-    const ClientMetadata& aClientMetadata, nsIFile& aBaseDir, const nsID& aId) {
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsID& aId) {
   QM_TRY_INSPECT(const auto& finalFile,
                  BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL));
 
-  QM_TRY_RETURN(CreateFileInputStream(PERSISTENCE_TYPE_DEFAULT, aClientMetadata,
-                                      Client::DOMCACHE, finalFile.get())
-                    .map([](NotNull<RefPtr<FileInputStream>>&& stream) {
-                      return WrapNotNullUnchecked(
-                          nsCOMPtr<nsIInputStream>{stream.get()});
-                    }));
+  QM_TRY_RETURN(
+      CreateFileInputStream(PERSISTENCE_TYPE_DEFAULT, aDirectoryMetadata,
+                            Client::DOMCACHE, finalFile.get())
+          .map([](NotNull<RefPtr<FileInputStream>>&& stream) {
+            return WrapNotNullUnchecked(nsCOMPtr<nsIInputStream>{stream.get()});
+          }));
 }
 
-nsresult BodyMaybeUpdatePaddingSize(const ClientMetadata& aClientMetadata,
-                                    nsIFile& aBaseDir, const nsID& aId,
-                                    const uint32_t aPaddingInfo,
-                                    int64_t* aPaddingSizeInOut) {
+nsresult BodyMaybeUpdatePaddingSize(
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsID& aId, const uint32_t aPaddingInfo, int64_t* aPaddingSizeInOut) {
   MOZ_DIAGNOSTIC_ASSERT(aPaddingSizeInOut);
 
   QM_TRY_INSPECT(const auto& bodyFile,
                  BodyIdToFile(aBaseDir, aId, BODY_FILE_TMP));
 
   QuotaManager* quotaManager = QuotaManager::Get();
   MOZ_DIAGNOSTIC_ASSERT(quotaManager);
 
   int64_t fileSize = 0;
   RefPtr<QuotaObject> quotaObject = quotaManager->GetQuotaObject(
-      PERSISTENCE_TYPE_DEFAULT, aClientMetadata, Client::DOMCACHE,
+      PERSISTENCE_TYPE_DEFAULT, aDirectoryMetadata, Client::DOMCACHE,
       bodyFile.get(), -1, &fileSize);
   MOZ_DIAGNOSTIC_ASSERT(quotaObject);
   MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
   // XXXtt: bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1422815
   if (!quotaObject) {
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -244,42 +244,43 @@ nsresult BodyMaybeUpdatePaddingSize(cons
 
   if (!quotaObject->IncreaseSize(*aPaddingSizeInOut)) {
     return NS_ERROR_FILE_NO_DEVICE_SPACE;
   }
 
   return NS_OK;
 }
 
-nsresult BodyDeleteFiles(const ClientMetadata& aClientMetadata,
+nsresult BodyDeleteFiles(const CacheDirectoryMetadata& aDirectoryMetadata,
                          nsIFile& aBaseDir, const nsTArray<nsID>& aIdList) {
   for (const auto id : aIdList) {
     QM_TRY_INSPECT(const auto& bodyDir, BodyGetCacheDir(aBaseDir, id));
 
     const auto removeFileForId =
-        [&aClientMetadata, &id](
+        [&aDirectoryMetadata, &id](
             nsIFile& bodyFile,
             const nsACString& leafName) -> Result<bool, nsresult> {
       nsID fileId;
       QM_TRY(OkIf(fileId.Parse(leafName.BeginReading())), true,
-             ([&aClientMetadata, &bodyFile](const auto) {
+             ([&aDirectoryMetadata, &bodyFile](const auto) {
                DebugOnly<nsresult> result = RemoveNsIFile(
-                   aClientMetadata, bodyFile, /* aTrackQuota */ false);
+                   aDirectoryMetadata, bodyFile, /* aTrackQuota */ false);
                MOZ_ASSERT(NS_SUCCEEDED(result));
              }));
 
       if (id.Equals(fileId)) {
-        DebugOnly<nsresult> result = RemoveNsIFile(aClientMetadata, bodyFile);
+        DebugOnly<nsresult> result =
+            RemoveNsIFile(aDirectoryMetadata, bodyFile);
         MOZ_ASSERT(NS_SUCCEEDED(result));
         return true;
       }
 
       return false;
     };
-    QM_TRY(MOZ_TO_RESULT(BodyTraverseFiles(aClientMetadata, *bodyDir,
+    QM_TRY(MOZ_TO_RESULT(BodyTraverseFiles(aDirectoryMetadata, *bodyDir,
                                            removeFileForId,
                                            /* aCanRemoveFiles */ false,
                                            /* aTrackQuota */ true)));
   }
 
   return NS_OK;
 }
 
@@ -341,45 +342,45 @@ nsresult DirectoryPaddingWrite(nsIFile& 
 
   QM_TRY(MOZ_TO_RESULT(objectStream->Write64(aPaddingSize)));
 
   return NS_OK;
 }
 
 }  // namespace
 
-nsresult BodyDeleteOrphanedFiles(const ClientMetadata& aClientMetadata,
-                                 nsIFile& aBaseDir,
-                                 const nsTArray<nsID>& aKnownBodyIdList) {
+nsresult BodyDeleteOrphanedFiles(
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsTArray<nsID>& aKnownBodyIdList) {
   // body files are stored in a directory structure like:
   //
   //  /morgue/01/{01fdddb2-884d-4c3d-95ba-0c8062f6c325}.final
   //  /morgue/02/{02fdddb2-884d-4c3d-95ba-0c8062f6c325}.tmp
 
   QM_TRY_INSPECT(const auto& dir,
                  CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
   // Iterate over all the intermediate morgue subdirs
   QM_TRY(quota::CollectEachFile(
       *dir,
-      [&aClientMetadata, &aKnownBodyIdList](
+      [&aDirectoryMetadata, &aKnownBodyIdList](
           const nsCOMPtr<nsIFile>& subdir) -> Result<Ok, nsresult> {
         QM_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*subdir));
 
         switch (dirEntryKind) {
           case nsIFileKind::ExistsAsDirectory: {
             const auto removeOrphanedFiles =
-                [&aClientMetadata, &aKnownBodyIdList](
+                [&aDirectoryMetadata, &aKnownBodyIdList](
                     nsIFile& bodyFile,
                     const nsACString& leafName) -> Result<bool, nsresult> {
               // Finally, parse the uuid out of the name.  If it fails to parse,
               // then ignore the file.
-              auto cleanup = MakeScopeExit([&aClientMetadata, &bodyFile] {
+              auto cleanup = MakeScopeExit([&aDirectoryMetadata, &bodyFile] {
                 DebugOnly<nsresult> result =
-                    RemoveNsIFile(aClientMetadata, bodyFile);
+                    RemoveNsIFile(aDirectoryMetadata, bodyFile);
                 MOZ_ASSERT(NS_SUCCEEDED(result));
               });
 
               nsID id;
               QM_TRY(OkIf(id.Parse(leafName.BeginReading())), true);
 
               if (!aKnownBodyIdList.Contains(id)) {
                 return true;
@@ -390,32 +391,33 @@ nsresult BodyDeleteOrphanedFiles(const C
               return false;
             };
 
             // QM_OR_ELSE_WARN_IF is not used here since we just want to log
             // NS_ERROR_FILE_FS_CORRUPTED result and not spam the reports (even
             // a warning in the reports is not desired).
             QM_TRY(QM_OR_ELSE_LOG_VERBOSE_IF(
                 // Expression.
-                MOZ_TO_RESULT(BodyTraverseFiles(aClientMetadata, *subdir,
+                MOZ_TO_RESULT(BodyTraverseFiles(aDirectoryMetadata, *subdir,
                                                 removeOrphanedFiles,
                                                 /* aCanRemoveFiles */ true,
                                                 /* aTrackQuota */ true)),
                 // Predicate.
                 IsSpecificError<NS_ERROR_FILE_FS_CORRUPTED>,
                 // Fallback. We treat NS_ERROR_FILE_FS_CORRUPTED as if the
                 // directory did not exist at all.
                 ErrToDefaultOk<>));
             break;
           }
 
           case nsIFileKind::ExistsAsFile: {
             // If a file got in here somehow, try to remove it and move on
-            DebugOnly<nsresult> result = RemoveNsIFile(aClientMetadata, *subdir,
-                                                       /* aTrackQuota */ false);
+            DebugOnly<nsresult> result =
+                RemoveNsIFile(aDirectoryMetadata, *subdir,
+                              /* aTrackQuota */ false);
             MOZ_ASSERT(NS_SUCCEEDED(result));
             break;
           }
 
           case nsIFileKind::DoesNotExist:
             // Ignore files that got removed externally while iterating.
             break;
         }
@@ -424,29 +426,29 @@ nsresult BodyDeleteOrphanedFiles(const C
       }));
 
   return NS_OK;
 }
 
 namespace {
 
 Result<nsCOMPtr<nsIFile>, nsresult> GetMarkerFileHandle(
-    const ClientMetadata& aClientMetadata) {
+    const CacheDirectoryMetadata& aDirectoryMetadata) {
   QM_TRY_UNWRAP(auto marker,
-                CloneFileAndAppend(*aClientMetadata.mDir, u"cache"_ns));
+                CloneFileAndAppend(*aDirectoryMetadata.mDir, u"cache"_ns));
 
   QM_TRY(MOZ_TO_RESULT(marker->Append(u"context_open.marker"_ns)));
 
   return marker;
 }
 
 }  // namespace
 
-nsresult CreateMarkerFile(const ClientMetadata& aClientMetadata) {
-  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aClientMetadata));
+nsresult CreateMarkerFile(const CacheDirectoryMetadata& aDirectoryMetadata) {
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aDirectoryMetadata));
 
   // Callers call this function without checking if the file already exists
   // (idempotent usage). QM_OR_ELSE_WARN_IF is not used here since we just want
   // to log NS_ERROR_FILE_ALREADY_EXISTS result and not spam the reports.
   //
   // TODO: In theory if this file exists, then Context::~Context should have
   // cleaned it up, but obviously we can crash and not clean it up, which is
   // the whole point of the marker file. In that case, we'll realize the marker
@@ -469,82 +471,83 @@ nsresult CreateMarkerFile(const ClientMe
   // writing the marker if later modifications to the Cache are
   // actually flushed to the disk.  If the OS crashes before the marker
   // is written then we are ensured no other changes to the Cache were
   // flushed either.
 
   return NS_OK;
 }
 
-nsresult DeleteMarkerFile(const ClientMetadata& aClientMetadata) {
-  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aClientMetadata));
+nsresult DeleteMarkerFile(const CacheDirectoryMetadata& aDirectoryMetadata) {
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aDirectoryMetadata));
 
   DebugOnly<nsresult> result =
-      RemoveNsIFile(aClientMetadata, *marker, /* aTrackQuota */ false);
+      RemoveNsIFile(aDirectoryMetadata, *marker, /* aTrackQuota */ false);
   MOZ_ASSERT(NS_SUCCEEDED(result));
 
   // Again, no fsync is necessary.  If the OS crashes before the file
   // removal is flushed, then the Cache will search for stale data on
   // startup.  This will cause the next Cache access to be a bit slow, but
   // it seems appropriate after an OS crash.
 
   return NS_OK;
 }
 
-bool MarkerFileExists(const ClientMetadata& aClientMetadata) {
-  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aClientMetadata),
+bool MarkerFileExists(const CacheDirectoryMetadata& aDirectoryMetadata) {
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aDirectoryMetadata),
                  false);
 
   QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(marker, Exists), false);
 }
 
-nsresult RemoveNsIFileRecursively(const Maybe<ClientMetadata>& aClientMetadata,
-                                  nsIFile& aFile, const bool aTrackQuota) {
+nsresult RemoveNsIFileRecursively(
+    const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata, nsIFile& aFile,
+    const bool aTrackQuota) {
   // XXX This assertion proves that we can remove aTrackQuota and just check
   // aClientMetadata
-  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aClientMetadata);
+  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aDirectoryMetadata);
 
   QM_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(aFile));
 
   switch (dirEntryKind) {
     case nsIFileKind::ExistsAsDirectory:
       // Unfortunately, we need to traverse all the entries and delete files one
       // by
       // one to update their usages to the QuotaManager.
       QM_TRY(quota::CollectEachFile(
           aFile,
-          [&aClientMetadata, &aTrackQuota](
+          [&aDirectoryMetadata, &aTrackQuota](
               const nsCOMPtr<nsIFile>& file) -> Result<Ok, nsresult> {
-            QM_TRY(MOZ_TO_RESULT(
-                RemoveNsIFileRecursively(aClientMetadata, *file, aTrackQuota)));
+            QM_TRY(MOZ_TO_RESULT(RemoveNsIFileRecursively(aDirectoryMetadata,
+                                                          *file, aTrackQuota)));
 
             return Ok{};
           }));
 
       // In the end, remove the folder
       QM_TRY(MOZ_TO_RESULT(aFile.Remove(/* recursive */ false)));
 
       break;
 
     case nsIFileKind::ExistsAsFile:
-      return RemoveNsIFile(aClientMetadata, aFile, aTrackQuota);
+      return RemoveNsIFile(aDirectoryMetadata, aFile, aTrackQuota);
 
     case nsIFileKind::DoesNotExist:
       // Ignore files that got removed externally while iterating.
       break;
   }
 
   return NS_OK;
 }
 
-nsresult RemoveNsIFile(const Maybe<ClientMetadata>& aClientMetadata,
+nsresult RemoveNsIFile(const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
                        nsIFile& aFile, const bool aTrackQuota) {
   // XXX This assertion proves that we can remove aTrackQuota and just check
   // aClientMetadata
-  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aClientMetadata);
+  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aDirectoryMetadata);
 
   int64_t fileSize = 0;
   if (aTrackQuota) {
     QM_TRY_INSPECT(
         const auto& maybeFileSize,
         QM_OR_ELSE_WARN_IF(
             // Expression.
             MOZ_TO_RESULT_INVOKE(aFile, GetFileSize).map(Some<int64_t>),
@@ -565,31 +568,33 @@ nsresult RemoveNsIFile(const Maybe<Clien
       MOZ_TO_RESULT(aFile.Remove(/* recursive */ false)),
       // Predicate.
       IsFileNotFoundError,
       // Fallback.
       ErrToDefaultOk<>));
 
   if (fileSize > 0) {
     MOZ_ASSERT(aTrackQuota);
-    DecreaseUsageForClientMetadata(*aClientMetadata, fileSize);
+    DecreaseUsageForDirectoryMetadata(*aDirectoryMetadata, fileSize);
   }
 
   return NS_OK;
 }
 
-void DecreaseUsageForClientMetadata(const ClientMetadata& aClientMetadata,
-                                    const int64_t aUpdatingSize) {
+void DecreaseUsageForDirectoryMetadata(
+    const CacheDirectoryMetadata& aDirectoryMetadata,
+    const int64_t aUpdatingSize) {
   MOZ_DIAGNOSTIC_ASSERT(aUpdatingSize > 0);
 
   QuotaManager* quotaManager = QuotaManager::Get();
   MOZ_DIAGNOSTIC_ASSERT(quotaManager);
 
   quotaManager->DecreaseUsageForClient(
-      quota::ClientMetadata{aClientMetadata, Client::DOMCACHE}, aUpdatingSize);
+      quota::ClientMetadata{aDirectoryMetadata, Client::DOMCACHE},
+      aUpdatingSize);
 }
 
 bool DirectoryPaddingFileExists(nsIFile& aBaseDir,
                                 DirPaddingFile aPaddingFileType) {
   QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, aPaddingFileType == DirPaddingFile::TMP_FILE
                                        ? nsLiteralString(PADDING_TMP_FILE_NAME)
--- a/dom/cache/FileUtils.h
+++ b/dom/cache/FileUtils.h
@@ -26,96 +26,98 @@ namespace cache {
 
 enum class DirPaddingFile { FILE, TMP_FILE };
 
 nsresult BodyCreateDir(nsIFile& aBaseDir);
 
 // Note that this function can only be used during the initialization of the
 // database.  We're unlikely to be able to delete the DB successfully past
 // that point due to the file being in use.
-nsresult BodyDeleteDir(const ClientMetadata& aClientMetadata,
+nsresult BodyDeleteDir(const CacheDirectoryMetadata& aDirectoryMetadata,
                        nsIFile& aBaseDir);
 
 // Returns a Result with a success value with the body id and, optionally, the
 // copy context.
 Result<std::pair<nsID, nsCOMPtr<nsISupports>>, nsresult> BodyStartWriteStream(
-    const ClientMetadata& aClientMetadata, nsIFile& aBaseDir,
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
     nsIInputStream& aSource, void* aClosure, nsAsyncCopyCallbackFun aCallback);
 
 void BodyCancelWrite(nsISupports& aCopyContext);
 
 nsresult BodyFinalizeWrite(nsIFile& aBaseDir, const nsID& aId);
 
 Result<NotNull<nsCOMPtr<nsIInputStream>>, nsresult> BodyOpen(
-    const ClientMetadata& aClientMetadata, nsIFile& aBaseDir, const nsID& aId);
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsID& aId);
 
-nsresult BodyMaybeUpdatePaddingSize(const ClientMetadata& aClientMetadata,
-                                    nsIFile& aBaseDir, const nsID& aId,
-                                    uint32_t aPaddingInfo,
-                                    int64_t* aPaddingSizeInOut);
+nsresult BodyMaybeUpdatePaddingSize(
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsID& aId, uint32_t aPaddingInfo, int64_t* aPaddingSizeInOut);
 
-nsresult BodyDeleteFiles(const ClientMetadata& aClientMetadata,
+nsresult BodyDeleteFiles(const CacheDirectoryMetadata& aDirectoryMetadata,
                          nsIFile& aBaseDir, const nsTArray<nsID>& aIdList);
 
-nsresult BodyDeleteOrphanedFiles(const ClientMetadata& aClientMetadata,
-                                 nsIFile& aBaseDir,
-                                 const nsTArray<nsID>& aKnownBodyIdList);
+nsresult BodyDeleteOrphanedFiles(
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aBaseDir,
+    const nsTArray<nsID>& aKnownBodyIdList);
 
 // If aCanRemoveFiles is true, that means we are safe to touch the files which
 // can be accessed in other threads.
 // If it's not, that means we cannot remove the files which are possible to
 // created by other threads. Note that if the files are not expected, we should
 // be safe to remove them in any case.
 template <typename Func>
-nsresult BodyTraverseFiles(const Maybe<ClientMetadata>& aClientMetadata,
-                           nsIFile& aBodyDir, const Func& aHandleFileFunc,
-                           bool aCanRemoveFiles, bool aTrackQuota = true);
+nsresult BodyTraverseFiles(
+    const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata, nsIFile& aBodyDir,
+    const Func& aHandleFileFunc, bool aCanRemoveFiles, bool aTrackQuota = true);
 
 // XXX Remove this method when all callers properly wrap aClientMetadata with
 // Some/Nothing
 template <typename Func>
-nsresult BodyTraverseFiles(const ClientMetadata& aClientMetadata,
+nsresult BodyTraverseFiles(const CacheDirectoryMetadata& aDirectoryMetadata,
                            nsIFile& aBodyDir, const Func& aHandleFileFunc,
                            bool aCanRemoveFiles, bool aTrackQuota = true) {
-  return BodyTraverseFiles(Some(aClientMetadata), aBodyDir, aHandleFileFunc,
+  return BodyTraverseFiles(Some(aDirectoryMetadata), aBodyDir, aHandleFileFunc,
                            aCanRemoveFiles, aTrackQuota);
 }
 
-nsresult CreateMarkerFile(const ClientMetadata& aClientMetadata);
+nsresult CreateMarkerFile(const CacheDirectoryMetadata& aDirectoryMetadata);
 
-nsresult DeleteMarkerFile(const ClientMetadata& aClientMetadata);
+nsresult DeleteMarkerFile(const CacheDirectoryMetadata& aDirectoryMetadata);
 
-bool MarkerFileExists(const ClientMetadata& aClientMetadata);
+bool MarkerFileExists(const CacheDirectoryMetadata& aDirectoryMetadata);
 
-nsresult RemoveNsIFileRecursively(const Maybe<ClientMetadata>& aClientMetadata,
-                                  nsIFile& aFile, bool aTrackQuota = true);
+nsresult RemoveNsIFileRecursively(
+    const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata, nsIFile& aFile,
+    bool aTrackQuota = true);
 
 // XXX Remove this method when all callers properly wrap aClientMetadata with
 // Some/Nothing
-nsresult RemoveNsIFileRecursively(const ClientMetadata& aClientMetadata,
-                                  nsIFile& aFile, bool aTrackQuota = true) {
-  return RemoveNsIFileRecursively(Some(aClientMetadata), aFile, aTrackQuota);
+nsresult RemoveNsIFileRecursively(
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile& aFile,
+    bool aTrackQuota = true) {
+  return RemoveNsIFileRecursively(Some(aDirectoryMetadata), aFile, aTrackQuota);
 }
 
 // Delete a file that you think exists. If the file doesn't exist, an error
 // will not be returned, but warning telemetry will be generated! So only call
 // this on files that you know exist (idempotent usage, but it's not
 // recommended).
-nsresult RemoveNsIFile(const Maybe<ClientMetadata>& aClientMetadata,
+nsresult RemoveNsIFile(const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
                        nsIFile& aFile, bool aTrackQuota = true);
 
 // XXX Remove this method when all callers properly wrap aClientMetadata with
 // Some/Nothing
-nsresult RemoveNsIFile(const ClientMetadata& aClientMetadata, nsIFile& aFile,
-                       bool aTrackQuota = true) {
-  return RemoveNsIFile(Some(aClientMetadata), aFile, aTrackQuota);
+nsresult RemoveNsIFile(const CacheDirectoryMetadata& aDirectoryMetadata,
+                       nsIFile& aFile, bool aTrackQuota = true) {
+  return RemoveNsIFile(Some(aDirectoryMetadata), aFile, aTrackQuota);
 }
 
-void DecreaseUsageForClientMetadata(const ClientMetadata& aClientMetadata,
-                                    int64_t aUpdatingSize);
+void DecreaseUsageForDirectoryMetadata(
+    const CacheDirectoryMetadata& aDirectoryMetadata, int64_t aUpdatingSize);
 
 /**
  * This function is used to check if the directory padding file is existed.
  */
 bool DirectoryPaddingFileExists(nsIFile& aBaseDir,
                                 DirPaddingFile aPaddingFileType);
 
 /**
--- a/dom/cache/FileUtilsImpl.h
+++ b/dom/cache/FileUtilsImpl.h
@@ -10,22 +10,23 @@
 #include "mozilla/dom/FlippedOnce.h"
 #include "mozilla/dom/cache/FileUtils.h"
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 template <typename Func>
-nsresult BodyTraverseFiles(const Maybe<ClientMetadata>& aClientMetadata,
-                           nsIFile& aBodyDir, const Func& aHandleFileFunc,
-                           const bool aCanRemoveFiles, const bool aTrackQuota) {
+nsresult BodyTraverseFiles(
+    const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata, nsIFile& aBodyDir,
+    const Func& aHandleFileFunc, const bool aCanRemoveFiles,
+    const bool aTrackQuota) {
   // XXX This assertion proves that we can remove aTrackQuota and just check
   // aClientMetadata.isSome()
-  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aClientMetadata);
+  MOZ_DIAGNOSTIC_ASSERT_IF(aTrackQuota, aDirectoryMetadata);
 
 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
   {
     nsCOMPtr<nsIFile> parentFile;
     nsresult rv = aBodyDir.GetParent(getter_AddRefs(parentFile));
     MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
     MOZ_DIAGNOSTIC_ASSERT(parentFile);
 
@@ -35,52 +36,52 @@ nsresult BodyTraverseFiles(const Maybe<C
 
     MOZ_DIAGNOSTIC_ASSERT(StringEndsWith(nativeLeafName, "morgue"_ns));
   }
 #endif
 
   FlippedOnce<true> isEmpty;
   QM_TRY(quota::CollectEachFile(
       aBodyDir,
-      [&isEmpty, &aClientMetadata, aTrackQuota, &aHandleFileFunc,
+      [&isEmpty, &aDirectoryMetadata, aTrackQuota, &aHandleFileFunc,
        aCanRemoveFiles](const nsCOMPtr<nsIFile>& file) -> Result<Ok, nsresult> {
         QM_TRY_INSPECT(const auto& dirEntryKind, quota::GetDirEntryKind(*file));
 
         switch (dirEntryKind) {
           case quota::nsIFileKind::ExistsAsDirectory: {
             // If it's a directory somehow, try to remove it and move on
             DebugOnly<nsresult> result = RemoveNsIFileRecursively(
-                aClientMetadata, *file, /* aTrackQuota */ false);
+                aDirectoryMetadata, *file, /* aTrackQuota */ false);
             MOZ_ASSERT(NS_SUCCEEDED(result));
             break;
           }
 
           case quota::nsIFileKind::ExistsAsFile: {
             nsAutoCString leafName;
             QM_TRY(MOZ_TO_RESULT(file->GetNativeLeafName(leafName)));
 
             // Delete all tmp files regardless of known bodies. These are all
             // considered orphans.
             if (StringEndsWith(leafName, ".tmp"_ns)) {
               if (aCanRemoveFiles) {
                 DebugOnly<nsresult> result =
-                    RemoveNsIFile(aClientMetadata, *file, aTrackQuota);
+                    RemoveNsIFile(aDirectoryMetadata, *file, aTrackQuota);
                 MOZ_ASSERT(NS_SUCCEEDED(result));
                 return Ok{};
               }
             } else {
               // Otherwise, it must be a .final file.
               QM_WARNONLY_TRY_UNWRAP(
                   const auto maybeEndingOk,
                   OkIf(StringEndsWith(leafName, ".final"_ns)));
 
               // If its not, try to remove it and move on.
               if (!maybeEndingOk) {
                 DebugOnly<nsresult> result = RemoveNsIFile(
-                    aClientMetadata, *file, /* aTrackQuota */ false);
+                    aDirectoryMetadata, *file, /* aTrackQuota */ false);
                 MOZ_ASSERT(NS_SUCCEEDED(result));
                 return Ok{};
               }
             }
 
             QM_TRY_INSPECT(const bool& fileDeleted,
                            aHandleFileFunc(*file, leafName));
             if (fileDeleted) {
@@ -96,17 +97,17 @@ nsresult BodyTraverseFiles(const Maybe<C
             break;
         }
 
         return Ok{};
       }));
 
   if (isEmpty && aCanRemoveFiles) {
     DebugOnly<nsresult> result = RemoveNsIFileRecursively(
-        aClientMetadata, aBodyDir, /* aTrackQuota */ false);
+        aDirectoryMetadata, aBodyDir, /* aTrackQuota */ false);
     MOZ_ASSERT(NS_SUCCEEDED(result));
   }
 
   return NS_OK;
 }
 
 }  // namespace cache
 }  // namespace dom
--- a/dom/cache/Manager.cpp
+++ b/dom/cache/Manager.cpp
@@ -70,17 +70,17 @@ nsresult MaybeUpdatePaddingFile(nsIFile*
 // An Action that is executed when a Context is first created.  It ensures that
 // the directory and database are setup properly.  This lets other actions
 // not worry about these details.
 class SetupAction final : public SyncDBAction {
  public:
   SetupAction() : SyncDBAction(DBAction::Create) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
     QM_TRY(MOZ_TO_RESULT(BodyCreateDir(*aDBDir)));
 
     // executes in its own transaction
     QM_TRY(MOZ_TO_RESULT(db::CreateOrMigrateSchema(*aConn)));
 
@@ -89,54 +89,54 @@ class SetupAction final : public SyncDBA
     // the database is valid, but we might still orphan data.  Both
     // Cache objects and body files can be referenced by DOM objects
     // after they are "removed" from their parent.  So we need to
     // look and see if any of these late access objects have been
     // orphaned.
     //
     // Note, this must be done after any schema version updates to
     // ensure our DBSchema methods work correctly.
-    if (MarkerFileExists(aClientMetadata)) {
+    if (MarkerFileExists(aDirectoryMetadata)) {
       NS_WARNING("Cache not shutdown cleanly! Cleaning up stale data...");
       mozStorageTransaction trans(aConn, false,
                                   mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
       QM_TRY(MOZ_TO_RESULT(trans.Start()));
 
       // Clean up orphaned Cache objects
       QM_TRY_INSPECT(const auto& orphanedCacheIdList,
                      db::FindOrphanedCacheIds(*aConn));
 
       QM_TRY_INSPECT(
           const CheckedInt64& overallDeletedPaddingSize,
           Reduce(
               orphanedCacheIdList, CheckedInt64(0),
-              [aConn, &aClientMetadata, &aDBDir](
+              [aConn, &aDirectoryMetadata, &aDBDir](
                   CheckedInt64 oldValue, const Maybe<const CacheId&>& element)
                   -> Result<CheckedInt64, nsresult> {
                 QM_TRY_INSPECT(const auto& deletionInfo,
                                db::DeleteCacheId(*aConn, *element));
 
                 QM_TRY(MOZ_TO_RESULT(
-                    BodyDeleteFiles(aClientMetadata, *aDBDir,
+                    BodyDeleteFiles(aDirectoryMetadata, *aDBDir,
                                     deletionInfo.mDeletedBodyIdList)));
 
                 if (deletionInfo.mDeletedPaddingSize > 0) {
-                  DecreaseUsageForClientMetadata(
-                      aClientMetadata, deletionInfo.mDeletedPaddingSize);
+                  DecreaseUsageForDirectoryMetadata(
+                      aDirectoryMetadata, deletionInfo.mDeletedPaddingSize);
                 }
 
                 return oldValue + deletionInfo.mDeletedPaddingSize;
               }));
 
       // Clean up orphaned body objects
       QM_TRY_INSPECT(const auto& knownBodyIdList, db::GetKnownBodyIds(*aConn));
 
-      QM_TRY(MOZ_TO_RESULT(
-          BodyDeleteOrphanedFiles(aClientMetadata, *aDBDir, knownBodyIdList)));
+      QM_TRY(MOZ_TO_RESULT(BodyDeleteOrphanedFiles(aDirectoryMetadata, *aDBDir,
+                                                   knownBodyIdList)));
 
       // Commit() explicitly here, because we want to ensure the padding file
       // has the correct content.
       // We'll restore padding file below, so just warn here if failure happens.
       //
       // XXX Before, if MaybeUpdatePaddingFile failed but we didn't enter the if
       // body below, we would have propagated the MaybeUpdatePaddingFile
       // failure, but if we entered it and RestorePaddingFile succeeded, we
@@ -167,35 +167,35 @@ class DeleteOrphanedBodyAction final : p
 
   explicit DeleteOrphanedBodyAction(DeletedBodyIdList&& aDeletedBodyIdList)
       : mDeletedBodyIdList(std::move(aDeletedBodyIdList)) {}
 
   explicit DeleteOrphanedBodyAction(const nsID& aBodyId)
       : mDeletedBodyIdList{aBodyId} {}
 
   void RunOnTarget(SafeRefPtr<Resolver> aResolver,
-                   const Maybe<ClientMetadata>& aClientMetadata,
+                   const Maybe<CacheDirectoryMetadata>& aDirectoryMetadata,
                    Data*) override {
     MOZ_DIAGNOSTIC_ASSERT(aResolver);
-    MOZ_DIAGNOSTIC_ASSERT(aClientMetadata);
-    MOZ_DIAGNOSTIC_ASSERT(aClientMetadata->mDir);
+    MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata);
+    MOZ_DIAGNOSTIC_ASSERT(aDirectoryMetadata->mDir);
 
     // Note that since DeleteOrphanedBodyAction isn't used while the context is
     // being initialized, we don't need to check for cancellation here.
 
     const auto resolve = [&aResolver](const nsresult rv) {
       aResolver->Resolve(rv);
     };
 
     QM_TRY_INSPECT(const auto& dbDir,
-                   CloneFileAndAppend(*aClientMetadata->mDir, u"cache"_ns),
+                   CloneFileAndAppend(*aDirectoryMetadata->mDir, u"cache"_ns),
                    QM_VOID, resolve);
 
-    QM_TRY(MOZ_TO_RESULT(
-               BodyDeleteFiles(*aClientMetadata, *dbDir, mDeletedBodyIdList)),
+    QM_TRY(MOZ_TO_RESULT(BodyDeleteFiles(*aDirectoryMetadata, *dbDir,
+                                         mDeletedBodyIdList)),
            QM_VOID, resolve);
 
     aResolver->Resolve(NS_OK);
   }
 
  private:
   DeletedBodyIdList mDeletedBodyIdList;
 };
@@ -522,19 +522,19 @@ class Manager::BaseAction : public SyncD
 class Manager::DeleteOrphanedCacheAction final : public SyncDBAction {
  public:
   DeleteOrphanedCacheAction(SafeRefPtr<Manager> aManager, CacheId aCacheId)
       : SyncDBAction(DBAction::Existing),
         mManager(std::move(aManager)),
         mCacheId(aCacheId) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
-    mClientMetadata.emplace(aClientMetadata);
+    mDirectoryMetadata.emplace(aDirectoryMetadata);
 
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
     QM_TRY(MOZ_TO_RESULT(trans.Start()));
 
     QM_TRY_UNWRAP(mDeletionInfo, db::DeleteCacheId(*aConn, mCacheId));
 
@@ -551,46 +551,46 @@ class Manager::DeleteOrphanedCacheAction
     if (NS_FAILED(aRv)) {
       mDeletionInfo.mDeletedBodyIdList.Clear();
       mDeletionInfo.mDeletedPaddingSize = 0;
     }
 
     mManager->NoteOrphanedBodyIdList(mDeletionInfo.mDeletedBodyIdList);
 
     if (mDeletionInfo.mDeletedPaddingSize > 0) {
-      DecreaseUsageForClientMetadata(*mClientMetadata,
-                                     mDeletionInfo.mDeletedPaddingSize);
+      DecreaseUsageForDirectoryMetadata(*mDirectoryMetadata,
+                                        mDeletionInfo.mDeletedPaddingSize);
     }
 
     // ensure we release the manager on the initiating thread
     mManager = nullptr;
   }
 
  private:
   SafeRefPtr<Manager> mManager;
   const CacheId mCacheId;
   DeletionInfo mDeletionInfo;
-  Maybe<ClientMetadata> mClientMetadata;
+  Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
 };
 
 // ----------------------------------------------------------------------------
 
 class Manager::CacheMatchAction final : public Manager::BaseAction {
  public:
   CacheMatchAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                    CacheId aCacheId, const CacheMatchArgs& aArgs,
                    SafeRefPtr<StreamList> aStreamList)
       : BaseAction(std::move(aManager), aListenerId),
         mCacheId(aCacheId),
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)),
         mFoundResponse(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
     QM_TRY_INSPECT(
         const auto& maybeResponse,
         db::CacheMatch(*aConn, mCacheId, mArgs.request(), mArgs.params()));
 
     mFoundResponse = maybeResponse.isSome();
@@ -602,17 +602,17 @@ class Manager::CacheMatchAction final : 
         IsHeadRequest(mArgs.request(), mArgs.params())) {
       mResponse.mHasBodyId = false;
       return NS_OK;
     }
 
     nsCOMPtr<nsIInputStream> stream;
     if (mArgs.openMode() == OpenMode::Eager) {
       QM_TRY_UNWRAP(stream,
-                    BodyOpen(aClientMetadata, *aDBDir, mResponse.mBodyId));
+                    BodyOpen(aDirectoryMetadata, *aDBDir, mResponse.mBodyId));
     }
 
     mStreamList->Add(mResponse.mBodyId, std::move(stream));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
@@ -646,34 +646,34 @@ class Manager::CacheMatchAllAction final
                       CacheId aCacheId, const CacheMatchAllArgs& aArgs,
                       SafeRefPtr<StreamList> aStreamList)
       : BaseAction(std::move(aManager), aListenerId),
         mCacheId(aCacheId),
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
     QM_TRY_UNWRAP(mSavedResponses,
                   db::CacheMatchAll(*aConn, mCacheId, mArgs.maybeRequest(),
                                     mArgs.params()));
 
     for (uint32_t i = 0; i < mSavedResponses.Length(); ++i) {
       if (!mSavedResponses[i].mHasBodyId ||
           IsHeadRequest(mArgs.maybeRequest(), mArgs.params())) {
         mSavedResponses[i].mHasBodyId = false;
         continue;
       }
 
       nsCOMPtr<nsIInputStream> stream;
       if (mArgs.openMode() == OpenMode::Eager) {
-        QM_TRY_UNWRAP(stream, BodyOpen(aClientMetadata, *aDBDir,
+        QM_TRY_UNWRAP(stream, BodyOpen(aDirectoryMetadata, *aDBDir,
                                        mSavedResponses[i].mBodyId));
       }
 
       mStreamList->Add(mSavedResponses[i].mBodyId, std::move(stream));
     }
 
     return NS_OK;
   }
@@ -729,20 +729,20 @@ class Manager::CachePutAllAction final :
       entry->mResponse = aPutList[i].response();
       entry->mResponseStream = aResponseStreamList[i];
     }
   }
 
  private:
   ~CachePutAllAction() = default;
 
-  virtual void RunWithDBOnTarget(SafeRefPtr<Resolver> aResolver,
-                                 const ClientMetadata& aClientMetadata,
-                                 nsIFile* aDBDir,
-                                 mozIStorageConnection* aConn) override {
+  virtual void RunWithDBOnTarget(
+      SafeRefPtr<Resolver> aResolver,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
+      mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aResolver);
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
     MOZ_DIAGNOSTIC_ASSERT(aConn);
     MOZ_DIAGNOSTIC_ASSERT(!mResolver);
     MOZ_DIAGNOSTIC_ASSERT(!mDBDir);
     MOZ_DIAGNOSTIC_ASSERT(!mConn);
 
     MOZ_DIAGNOSTIC_ASSERT(!mTarget);
@@ -752,30 +752,30 @@ class Manager::CachePutAllAction final :
     // We should be pre-initialized to expect one async completion.  This is
     // the "manual" completion we call at the end of this method in all
     // cases.
     MOZ_DIAGNOSTIC_ASSERT(mExpectedAsyncCopyCompletions == 1);
 
     mResolver = std::move(aResolver);
     mDBDir = aDBDir;
     mConn = aConn;
-    mClientMetadata.emplace(aClientMetadata);
+    mDirectoryMetadata.emplace(aDirectoryMetadata);
 
     // File bodies are streamed to disk via asynchronous copying.  Start
     // this copying now.  Each copy will eventually result in a call
     // to OnAsyncCopyComplete().
-    const nsresult rv = [this, &aClientMetadata]() -> nsresult {
+    const nsresult rv = [this, &aDirectoryMetadata]() -> nsresult {
       QM_TRY(CollectEachInRange(
-          mList, [this, &aClientMetadata](auto& entry) -> nsresult {
+          mList, [this, &aDirectoryMetadata](auto& entry) -> nsresult {
             QM_TRY(MOZ_TO_RESULT(
-                StartStreamCopy(aClientMetadata, entry, RequestStream,
+                StartStreamCopy(aDirectoryMetadata, entry, RequestStream,
                                 &mExpectedAsyncCopyCompletions)));
 
             QM_TRY(MOZ_TO_RESULT(
-                StartStreamCopy(aClientMetadata, entry, ResponseStream,
+                StartStreamCopy(aDirectoryMetadata, entry, ResponseStream,
                                 &mExpectedAsyncCopyCompletions)));
 
             return NS_OK;
           }));
 
       return NS_OK;
     }();
 
@@ -853,17 +853,17 @@ class Manager::CachePutAllAction final :
         if (e.mRequestStream) {
           QM_TRY(MOZ_TO_RESULT(BodyFinalizeWrite(*mDBDir, e.mRequestBodyId)));
         }
         if (e.mResponseStream) {
           // Gerenate padding size for opaque response if needed.
           if (e.mResponse.type() == ResponseType::Opaque) {
             // It'll generate padding if we've not set it yet.
             QM_TRY(MOZ_TO_RESULT(BodyMaybeUpdatePaddingSize(
-                *mClientMetadata, *mDBDir, e.mResponseBodyId,
+                *mDirectoryMetadata, *mDBDir, e.mResponseBodyId,
                 e.mResponse.paddingInfo(), &e.mResponse.paddingSize())));
 
             MOZ_DIAGNOSTIC_ASSERT(INT64_MAX - e.mResponse.paddingSize() >=
                                   mUpdatedPaddingSize);
             mUpdatedPaddingSize += e.mResponse.paddingSize();
           }
 
           QM_TRY(MOZ_TO_RESULT(BodyFinalizeWrite(*mDBDir, e.mResponseBodyId)));
@@ -910,17 +910,18 @@ class Manager::CachePutAllAction final :
     if (NS_FAILED(aRv)) {
       mDeletedBodyIdList.Clear();
       mDeletedPaddingSize = 0;
     }
 
     mManager->NoteOrphanedBodyIdList(mDeletedBodyIdList);
 
     if (mDeletedPaddingSize > 0) {
-      DecreaseUsageForClientMetadata(*mClientMetadata, mDeletedPaddingSize);
+      DecreaseUsageForDirectoryMetadata(*mDirectoryMetadata,
+                                        mDeletedPaddingSize);
     }
 
     Listener* listener = mManager->GetListener(mListenerId);
     mManager = nullptr;
     if (listener) {
       listener->OnOpComplete(ErrorResult(aRv), CachePutAllResult());
     }
   }
@@ -945,18 +946,19 @@ class Manager::CachePutAllAction final :
     CacheResponse mResponse;
     nsCOMPtr<nsIInputStream> mResponseStream;
     nsID mResponseBodyId;
     nsCOMPtr<nsISupports> mResponseCopyContext;
   };
 
   enum StreamId { RequestStream, ResponseStream };
 
-  nsresult StartStreamCopy(const ClientMetadata& aClientMetadata, Entry& aEntry,
-                           StreamId aStreamId, uint32_t* aCopyCountOut) {
+  nsresult StartStreamCopy(const CacheDirectoryMetadata& aDirectoryMetadata,
+                           Entry& aEntry, StreamId aStreamId,
+                           uint32_t* aCopyCountOut) {
     MOZ_ASSERT(mTarget->IsOnCurrentThread());
     MOZ_DIAGNOSTIC_ASSERT(aCopyCountOut);
 
     if (IsCanceled()) {
       return NS_ERROR_ABORT;
     }
 
     MOZ_DIAGNOSTIC_ASSERT(aStreamId == RequestStream ||
@@ -965,18 +967,18 @@ class Manager::CachePutAllAction final :
     const auto& source = aStreamId == RequestStream ? aEntry.mRequestStream
                                                     : aEntry.mResponseStream;
 
     if (!source) {
       return NS_OK;
     }
 
     QM_TRY_INSPECT((const auto& [bodyId, copyContext]),
-                   BodyStartWriteStream(aClientMetadata, *mDBDir, *source, this,
-                                        AsyncCopyCompleteFunc));
+                   BodyStartWriteStream(aDirectoryMetadata, *mDBDir, *source,
+                                        this, AsyncCopyCompleteFunc));
 
     if (aStreamId == RequestStream) {
       aEntry.mRequestBodyId = bodyId;
     } else {
       aEntry.mResponseBodyId = bodyId;
     }
 
     mBodyIdWrittenList.AppendElement(bodyId);
@@ -1029,19 +1031,20 @@ class Manager::CachePutAllAction final :
     {
       MutexAutoLock lock(mMutex);
       MOZ_ASSERT(mCopyContextList.IsEmpty());
     }
 #endif
 
     // Clean up any files we might have written before hitting the error.
     if (NS_FAILED(aRv)) {
-      BodyDeleteFiles(*mClientMetadata, *mDBDir, mBodyIdWrittenList);
+      BodyDeleteFiles(*mDirectoryMetadata, *mDBDir, mBodyIdWrittenList);
       if (mUpdatedPaddingSize > 0) {
-        DecreaseUsageForClientMetadata(*mClientMetadata, mUpdatedPaddingSize);
+        DecreaseUsageForDirectoryMetadata(*mDirectoryMetadata,
+                                          mUpdatedPaddingSize);
       }
     }
 
     // Must be released on the target thread where it was opened.
     mConn = nullptr;
 
     // Drop our ref to the target thread as we are done with this thread.
     // Also makes our thread assertions catch any incorrect method calls
@@ -1074,17 +1077,17 @@ class Manager::CachePutAllAction final :
   // Written to on target thread, accessed on initiating thread after target
   // thread activity is guaranteed complete
   nsTArray<nsID> mDeletedBodyIdList;
 
   // accessed from any thread while mMutex locked
   Mutex mMutex;
   nsTArray<nsCOMPtr<nsISupports>> mCopyContextList;
 
-  Maybe<ClientMetadata> mClientMetadata;
+  Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
   // Track how much pad amount has been added for new entries so that it can be
   // removed if an error occurs.
   int64_t mUpdatedPaddingSize;
   // Track any pad amount associated with overwritten entries.
   int64_t mDeletedPaddingSize;
 };
 
 // ----------------------------------------------------------------------------
@@ -1094,19 +1097,19 @@ class Manager::CacheDeleteAction final :
   CacheDeleteAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                     CacheId aCacheId, const CacheDeleteArgs& aArgs)
       : BaseAction(std::move(aManager), aListenerId),
         mCacheId(aCacheId),
         mArgs(aArgs),
         mSuccess(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
-    mClientMetadata.emplace(aClientMetadata);
+    mDirectoryMetadata.emplace(aDirectoryMetadata);
 
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
     QM_TRY(MOZ_TO_RESULT(trans.Start()));
 
     QM_TRY_UNWRAP(
         auto maybeDeletionInfo,
@@ -1132,66 +1135,66 @@ class Manager::CacheDeleteAction final :
     if (aRv.Failed()) {
       mDeletionInfo.mDeletedBodyIdList.Clear();
       mDeletionInfo.mDeletedPaddingSize = 0;
     }
 
     mManager->NoteOrphanedBodyIdList(mDeletionInfo.mDeletedBodyIdList);
 
     if (mDeletionInfo.mDeletedPaddingSize > 0) {
-      DecreaseUsageForClientMetadata(*mClientMetadata,
-                                     mDeletionInfo.mDeletedPaddingSize);
+      DecreaseUsageForDirectoryMetadata(*mDirectoryMetadata,
+                                        mDeletionInfo.mDeletedPaddingSize);
     }
 
     aListener->OnOpComplete(std::move(aRv), CacheDeleteResult(mSuccess));
   }
 
   virtual bool MatchesCacheId(CacheId aCacheId) const override {
     return aCacheId == mCacheId;
   }
 
  private:
   const CacheId mCacheId;
   const CacheDeleteArgs mArgs;
   bool mSuccess;
   DeletionInfo mDeletionInfo;
-  Maybe<ClientMetadata> mClientMetadata;
+  Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
 };
 
 // ----------------------------------------------------------------------------
 
 class Manager::CacheKeysAction final : public Manager::BaseAction {
  public:
   CacheKeysAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                   CacheId aCacheId, const CacheKeysArgs& aArgs,
                   SafeRefPtr<StreamList> aStreamList)
       : BaseAction(std::move(aManager), aListenerId),
         mCacheId(aCacheId),
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
     QM_TRY_UNWRAP(
         mSavedRequests,
         db::CacheKeys(*aConn, mCacheId, mArgs.maybeRequest(), mArgs.params()));
 
     for (uint32_t i = 0; i < mSavedRequests.Length(); ++i) {
       if (!mSavedRequests[i].mHasBodyId ||
           IsHeadRequest(mArgs.maybeRequest(), mArgs.params())) {
         mSavedRequests[i].mHasBodyId = false;
         continue;
       }
 
       nsCOMPtr<nsIInputStream> stream;
       if (mArgs.openMode() == OpenMode::Eager) {
-        QM_TRY_UNWRAP(stream, BodyOpen(aClientMetadata, *aDBDir,
+        QM_TRY_UNWRAP(stream, BodyOpen(aDirectoryMetadata, *aDBDir,
                                        mSavedRequests[i].mBodyId));
       }
 
       mStreamList->Add(mSavedRequests[i].mBodyId, std::move(stream));
     }
 
     return NS_OK;
   }
@@ -1223,17 +1226,17 @@ class Manager::StorageMatchAction final 
                      SafeRefPtr<StreamList> aStreamList)
       : BaseAction(std::move(aManager), aListenerId),
         mNamespace(aNamespace),
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)),
         mFoundResponse(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
     auto maybeResponse =
         db::StorageMatch(*aConn, mNamespace, mArgs.request(), mArgs.params());
     if (NS_WARN_IF(maybeResponse.isErr())) {
       return maybeResponse.unwrapErr();
     }
@@ -1246,18 +1249,18 @@ class Manager::StorageMatchAction final 
     if (!mFoundResponse || !mSavedResponse.mHasBodyId ||
         IsHeadRequest(mArgs.request(), mArgs.params())) {
       mSavedResponse.mHasBodyId = false;
       return NS_OK;
     }
 
     nsCOMPtr<nsIInputStream> stream;
     if (mArgs.openMode() == OpenMode::Eager) {
-      QM_TRY_UNWRAP(stream,
-                    BodyOpen(aClientMetadata, *aDBDir, mSavedResponse.mBodyId));
+      QM_TRY_UNWRAP(stream, BodyOpen(aDirectoryMetadata, *aDBDir,
+                                     mSavedResponse.mBodyId));
     }
 
     mStreamList->Add(mSavedResponse.mBodyId, std::move(stream));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
@@ -1286,17 +1289,17 @@ class Manager::StorageHasAction final : 
   StorageHasAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                    Namespace aNamespace, const StorageHasArgs& aArgs)
       : BaseAction(std::move(aManager), aListenerId),
         mNamespace(aNamespace),
         mArgs(aArgs),
         mCacheFound(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     QM_TRY_INSPECT(const auto& maybeCacheId,
                    db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
 
     mCacheFound = maybeCacheId.isSome();
 
     return NS_OK;
   }
@@ -1318,17 +1321,17 @@ class Manager::StorageOpenAction final :
   StorageOpenAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                     Namespace aNamespace, const StorageOpenArgs& aArgs)
       : BaseAction(std::move(aManager), aListenerId),
         mNamespace(aNamespace),
         mArgs(aArgs),
         mCacheId(INVALID_CACHE_ID) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     // Cache does not exist, create it instead
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
     QM_TRY(MOZ_TO_RESULT(trans.Start()));
 
     // Look for existing cache
@@ -1373,17 +1376,17 @@ class Manager::StorageDeleteAction final
                       Namespace aNamespace, const StorageDeleteArgs& aArgs)
       : BaseAction(std::move(aManager), aListenerId),
         mNamespace(aNamespace),
         mArgs(aArgs),
         mCacheDeleted(false),
         mCacheId(INVALID_CACHE_ID) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
     QM_TRY(MOZ_TO_RESULT(trans.Start()));
 
     QM_TRY_INSPECT(const auto& maybeCacheId,
                    db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
@@ -1438,17 +1441,17 @@ class Manager::StorageDeleteAction final
 
 class Manager::StorageKeysAction final : public Manager::BaseAction {
  public:
   StorageKeysAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                     Namespace aNamespace)
       : BaseAction(std::move(aManager), aListenerId), mNamespace(aNamespace) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     QM_TRY_UNWRAP(mKeys, db::StorageGetKeys(*aConn, mNamespace));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     if (aRv.Failed()) {
@@ -1468,21 +1471,21 @@ class Manager::OpenStreamAction final : 
  public:
   OpenStreamAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                    InputStreamResolver&& aResolver, const nsID& aBodyId)
       : BaseAction(std::move(aManager), aListenerId),
         mResolver(std::move(aResolver)),
         mBodyId(aBodyId) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
-      const ClientMetadata& aClientMetadata, nsIFile* aDBDir,
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    QM_TRY_UNWRAP(mBodyStream, BodyOpen(aClientMetadata, *aDBDir, mBodyId));
+    QM_TRY_UNWRAP(mBodyStream, BodyOpen(aDirectoryMetadata, *aDBDir, mBodyId));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     if (aRv.Failed()) {
       // Ignore the reason for fail and just pass a null input stream to let it
       // fail.
--- a/dom/cache/QuotaClient.cpp
+++ b/dom/cache/QuotaClient.cpp
@@ -117,34 +117,35 @@ Result<UsageInfo, nsresult> GetBodyUsage
             // directory did not exist at all.
             ErrToDefaultOk<>));
         return usageInfo;
       }));
 }
 
 Result<int64_t, nsresult> GetPaddingSizeFromDB(
     nsIFile& aDir, nsIFile& aDBFile, const OriginMetadata& aOriginMetadata) {
-  ClientMetadata clientMetadata(aOriginMetadata);
-  // clientMetadata.mDirectoryLockId must be -1 (which is default for new
-  // ClientMetadata) because this method should only be called from
+  CacheDirectoryMetadata directoryMetadata(aOriginMetadata);
+  // directoryMetadata.mDirectoryLockId must be -1 (which is default for new
+  // CacheDirectoryMetadata) because this method should only be called from
   // QuotaClient::InitOrigin when the temporary storage hasn't been initialized
   // yet. At that time, the in-memory objects (e.g. OriginInfo) are only being
   // created so it doesn't make sense to tunnel quota information to
   // TelemetryVFS to get corresponding QuotaObject instance for the SQLite
   // file).
-  MOZ_DIAGNOSTIC_ASSERT(clientMetadata.mDirectoryLockId == -1);
+  MOZ_DIAGNOSTIC_ASSERT(directoryMetadata.mDirectoryLockId == -1);
 
 #ifdef DEBUG
   {
     QM_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(aDBFile, Exists));
     MOZ_ASSERT(exists);
   }
 #endif
 
-  QM_TRY_INSPECT(const auto& conn, OpenDBConnection(clientMetadata, aDBFile));
+  QM_TRY_INSPECT(const auto& conn,
+                 OpenDBConnection(directoryMetadata, aDBFile));
 
   // Make sure that the database has the latest schema before we try to read
   // from it. We have to do this because GetPaddingSizeFromDB is called
   // by InitOrigin. And it means that SetupAction::RunSyncWithDBOnTarget hasn't
   // checked the schema for the given origin yet).
   QM_TRY(MOZ_TO_RESULT(db::CreateOrMigrateSchema(*conn)));
 
   QM_TRY_RETURN(DirectoryPaddingRestore(aDir, *conn,
@@ -429,17 +430,17 @@ nsresult CacheQuotaClient::RestorePaddin
                  DirectoryPaddingRestore(*aBaseDir, *aConn,
                                          /* aMustRestore */ true));
   Unused << dummyPaddingSize;
 
   return NS_OK;
 }
 
 nsresult CacheQuotaClient::WipePaddingFileInternal(
-    const ClientMetadata& aClientMetadata, nsIFile* aBaseDir) {
+    const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aBaseDir) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
 
   MOZ_ASSERT(DirectoryPaddingFileExists(*aBaseDir, DirPaddingFile::FILE));
 
   QM_TRY_INSPECT(
       const int64_t& paddingSize, ([&aBaseDir]() -> Result<int64_t, nsresult> {
         const bool temporaryPaddingFileExist =
@@ -462,17 +463,17 @@ nsresult CacheQuotaClient::WipePaddingFi
           NS_WARNING("Cannnot read padding size from file!");
           return 0;
         }
 
         return *directoryPaddingGetResult;
       }()));
 
   if (paddingSize > 0) {
-    DecreaseUsageForClientMetadata(aClientMetadata, paddingSize);
+    DecreaseUsageForDirectoryMetadata(aDirectoryMetadata, paddingSize);
   }
 
   QM_TRY(MOZ_TO_RESULT(
       DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::FILE)));
 
   // Remove temporary file if we have one.
   QM_TRY(MOZ_TO_RESULT(
       DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::TMP_FILE)));
@@ -511,23 +512,23 @@ nsresult RestorePaddingFile(nsIFile* aBa
 
   QM_TRY(MOZ_TO_RESULT(
       cacheQuotaClient->RestorePaddingFileInternal(aBaseDir, aConn)));
 
   return NS_OK;
 }
 
 // static
-nsresult WipePaddingFile(const ClientMetadata& aClientMetadata,
+nsresult WipePaddingFile(const CacheDirectoryMetadata& aDirectoryMetadata,
                          nsIFile* aBaseDir) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
 
   RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
   MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
 
   QM_TRY(MOZ_TO_RESULT(
-      cacheQuotaClient->WipePaddingFileInternal(aClientMetadata, aBaseDir)));
+      cacheQuotaClient->WipePaddingFileInternal(aDirectoryMetadata, aBaseDir)));
 
   return NS_OK;
 }
 
 }  // namespace mozilla::dom::cache
--- a/dom/cache/QuotaClient.h
+++ b/dom/cache/QuotaClient.h
@@ -34,17 +34,17 @@ already_AddRefed<quota::Client> CreateQu
  * padding size. Besides, we use the temporary padding file to indicate if the
  * previous action is completed successfully. If the temporary file exists, it
  * represents that the previous action is failed and the content of padding file
  * cannot be trusted, and we need to restore the padding file from the database.
  */
 
 nsresult RestorePaddingFile(nsIFile* aBaseDir, mozIStorageConnection* aConn);
 
-nsresult WipePaddingFile(const ClientMetadata& aClientMetadata,
+nsresult WipePaddingFile(const CacheDirectoryMetadata& aDirectoryMetadata,
                          nsIFile* aBaseDir);
 
 extern const nsLiteralString kCachesSQLiteFilename;
 
 }  // namespace cache
 }  // namespace dom
 }  // namespace mozilla
 
--- a/dom/cache/QuotaClientImpl.h
+++ b/dom/cache/QuotaClientImpl.h
@@ -111,18 +111,18 @@ class CacheQuotaClient final : public qu
                     }));
 
     return NS_OK;
   }
 
   nsresult RestorePaddingFileInternal(nsIFile* aBaseDir,
                                       mozIStorageConnection* aConn);
 
-  nsresult WipePaddingFileInternal(const ClientMetadata& aClientMetadata,
-                                   nsIFile* aBaseDir);
+  nsresult WipePaddingFileInternal(
+      const CacheDirectoryMetadata& aDirectoryMetadata, nsIFile* aBaseDir);
 
  private:
   ~CacheQuotaClient();
 
   void InitiateShutdown() override;
   bool IsShutdownCompleted() const override;
   nsCString GetShutdownStatus() const override;
   void ForceKillActors() override;
--- a/dom/cache/Types.h
+++ b/dom/cache/Types.h
@@ -24,27 +24,27 @@ enum Namespace {
   CHROME_ONLY_NAMESPACE,
   NUMBER_OF_NAMESPACES
 };
 static const Namespace INVALID_NAMESPACE = NUMBER_OF_NAMESPACES;
 
 using CacheId = int64_t;
 static const CacheId INVALID_CACHE_ID = -1;
 
-struct ClientMetadata : quota::ClientMetadata {
+struct CacheDirectoryMetadata : quota::ClientMetadata {
   nsCOMPtr<nsIFile> mDir;
   int64_t mDirectoryLockId = -1;
 
-  explicit ClientMetadata(quota::PrincipalMetadata aPrincipalMetadata)
+  explicit CacheDirectoryMetadata(quota::PrincipalMetadata aPrincipalMetadata)
       : quota::ClientMetadata(
             quota::OriginMetadata{std::move(aPrincipalMetadata),
                                   quota::PERSISTENCE_TYPE_DEFAULT},
             quota::Client::Type::DOMCACHE) {}
 
-  explicit ClientMetadata(quota::OriginMetadata aOriginMetadata)
+  explicit CacheDirectoryMetadata(quota::OriginMetadata aOriginMetadata)
       : quota::ClientMetadata(std::move(aOriginMetadata),
                               quota::Client::Type::DOMCACHE) {
     MOZ_DIAGNOSTIC_ASSERT(aOriginMetadata.mPersistenceType ==
                           quota::PERSISTENCE_TYPE_DEFAULT);
   }
 };
 
 struct DeletionInfo {