Bug 1709067 - CACHE: Remove module specific QM_TRY macros; r=dom-storage-reviewers,jstutte
authorJan Varga <jvarga@mozilla.com>
Mon, 03 May 2021 19:44:39 +0000
changeset 578370 5acd53fb30033afb78ce6b0514448121565b3514
parent 578369 6d0d00d6ee458a336111651c15fdd38c7937ece6
child 578371 721b27009831dea9b393b4e949a3ce51de82c904
push id142429
push userjvarga@mozilla.com
push dateMon, 03 May 2021 19:47:14 +0000
treeherderautoland@aad326665558 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-storage-reviewers, jstutte
bugs1709067
milestone90.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 1709067 - CACHE: Remove module specific QM_TRY macros; r=dom-storage-reviewers,jstutte Depends on D114080 Differential Revision: https://phabricator.services.mozilla.com/D114081
dom/cache/Cache.cpp
dom/cache/CacheCommon.h
dom/cache/CacheStorage.cpp
dom/cache/Context.cpp
dom/cache/DBAction.cpp
dom/cache/DBSchema.cpp
dom/cache/FileUtils.cpp
dom/cache/FileUtilsImpl.h
dom/cache/Manager.cpp
dom/cache/ManagerId.cpp
dom/cache/PrincipalVerifier.cpp
dom/cache/QuotaClient.cpp
dom/cache/QuotaClientImpl.h
--- a/dom/cache/Cache.cpp
+++ b/dom/cache/Cache.cpp
@@ -124,40 +124,38 @@ class Cache::FetchHandler final : public
     // JS values back to an nsTArray<RefPtr<Response>>.
 
     AutoTArray<RefPtr<Response>, 256> responseList;
     responseList.SetCapacity(mRequestList.Length());
 
     const auto failOnErr = [this](const auto) { Fail(); };
 
     bool isArray;
-    CACHE_TRY(OkIf(JS::IsArrayObject(aCx, aValue, &isArray)), QM_VOID,
-              failOnErr);
-    CACHE_TRY(OkIf(isArray), QM_VOID, failOnErr);
+    QM_TRY(OkIf(JS::IsArrayObject(aCx, aValue, &isArray)), QM_VOID, failOnErr);
+    QM_TRY(OkIf(isArray), QM_VOID, failOnErr);
 
     JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
 
     uint32_t length;
-    CACHE_TRY(OkIf(JS::GetArrayLength(aCx, obj, &length)), QM_VOID, failOnErr);
+    QM_TRY(OkIf(JS::GetArrayLength(aCx, obj, &length)), QM_VOID, failOnErr);
 
     for (uint32_t i = 0; i < length; ++i) {
       JS::Rooted<JS::Value> value(aCx);
 
-      CACHE_TRY(OkIf(JS_GetElement(aCx, obj, i, &value)), QM_VOID, failOnErr);
+      QM_TRY(OkIf(JS_GetElement(aCx, obj, i, &value)), QM_VOID, failOnErr);
 
-      CACHE_TRY(OkIf(value.isObject()), QM_VOID, failOnErr);
+      QM_TRY(OkIf(value.isObject()), QM_VOID, failOnErr);
 
       JS::Rooted<JSObject*> responseObj(aCx, &value.toObject());
 
       RefPtr<Response> response;
-      CACHE_TRY((UNWRAP_OBJECT(Response, responseObj, response)), QM_VOID,
-                failOnErr);
+      QM_TRY((UNWRAP_OBJECT(Response, responseObj, response)), QM_VOID,
+             failOnErr);
 
-      CACHE_TRY(OkIf(response->Type() != ResponseType::Error), QM_VOID,
-                failOnErr);
+      QM_TRY(OkIf(response->Type() != ResponseType::Error), QM_VOID, failOnErr);
 
       // Do not allow the convenience methods .add()/.addAll() to store failed
       // or invalid responses.  A consequence of this is that these methods
       // cannot be used to store opaque or opaqueredirect responses since they
       // always expose a 0 status value.
       ErrorResult errorResult;
       if (!IsValidPutResponseStatus(*response, PutStatusPolicy::RequireOK,
                                     errorResult)) {
--- a/dom/cache/CacheCommon.h
+++ b/dom/cache/CacheCommon.h
@@ -4,16 +4,9 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_cache_CacheCommon_h
 #define mozilla_dom_cache_CacheCommon_h
 
 #include "mozilla/dom/quota/QuotaCommon.h"
 
-// XXX Replace all uses by the QM_* variants and remove these aliases
-#define CACHE_TRY QM_TRY
-#define CACHE_TRY_UNWRAP QM_TRY_UNWRAP
-#define CACHE_TRY_INSPECT QM_TRY_INSPECT
-#define CACHE_TRY_RETURN QM_TRY_RETURN
-#define CACHE_FAIL QM_FAIL
-
 #endif  // mozilla_dom_cache_CacheCommon_h
--- a/dom/cache/CacheStorage.cpp
+++ b/dom/cache/CacheStorage.cpp
@@ -73,18 +73,18 @@ namespace {
 bool IsTrusted(const PrincipalInfo& aPrincipalInfo, bool aTestingPrefEnabled) {
   // Can happen on main thread or worker thread
 
   if (aPrincipalInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
     return true;
   }
 
   // Require a ContentPrincipal to avoid null principal, etc.
-  CACHE_TRY(OkIf(aPrincipalInfo.type() == PrincipalInfo::TContentPrincipalInfo),
-            false);
+  QM_TRY(OkIf(aPrincipalInfo.type() == PrincipalInfo::TContentPrincipalInfo),
+         false);
 
   // If we're in testing mode, then don't do any more work to determine if
   // the origin is trusted.  We have to run some tests as http.
   if (aTestingPrefEnabled) {
     return true;
   }
 
   // Now parse the scheme of the principal's origin.  This is a short term
@@ -100,17 +100,17 @@ bool IsTrusted(const PrincipalInfo& aPri
 
   // off the main thread URL parsing using nsStdURLParser.
   const nsCOMPtr<nsIURLParser> urlParser = new nsStdURLParser();
 
   uint32_t schemePos;
   int32_t schemeLen;
   uint32_t authPos;
   int32_t authLen;
-  CACHE_TRY(
+  QM_TRY(
       urlParser->ParseURL(url, flatURL.Length(), &schemePos, &schemeLen,
                           &authPos, &authLen, nullptr, nullptr),  // ignore path
       false);
 
   const nsAutoCString scheme(Substring(flatURL, schemePos, schemeLen));
   if (scheme.LowerCaseEqualsLiteral("https") ||
       scheme.LowerCaseEqualsLiteral("file")) {
     return true;
@@ -118,46 +118,46 @@ bool IsTrusted(const PrincipalInfo& aPri
 
   if (StaticPrefs::extensions_backgroundServiceWorker_enabled_AtStartup() &&
       scheme.LowerCaseEqualsLiteral("moz-extension")) {
     return true;
   }
 
   uint32_t hostPos;
   int32_t hostLen;
-  CACHE_TRY(urlParser->ParseAuthority(url + authPos, authLen, nullptr,
-                                      nullptr,           // ignore username
-                                      nullptr, nullptr,  // ignore password
-                                      &hostPos, &hostLen,
-                                      nullptr),  // ignore port
-            false);
+  QM_TRY(urlParser->ParseAuthority(url + authPos, authLen, nullptr,
+                                   nullptr,           // ignore username
+                                   nullptr, nullptr,  // ignore password
+                                   &hostPos, &hostLen,
+                                   nullptr),  // ignore port
+         false);
 
   return nsMixedContentBlocker::IsPotentiallyTrustworthyLoopbackHost(
       nsDependentCSubstring(url + authPos + hostPos, hostLen));
 }
 
 }  // namespace
 
 // static
 already_AddRefed<CacheStorage> CacheStorage::CreateOnMainThread(
     Namespace aNamespace, nsIGlobalObject* aGlobal, nsIPrincipal* aPrincipal,
     bool aForceTrustedOrigin, ErrorResult& aRv) {
   MOZ_DIAGNOSTIC_ASSERT(aGlobal);
   MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
   MOZ_ASSERT(NS_IsMainThread());
 
   PrincipalInfo principalInfo;
-  CACHE_TRY(PrincipalToPrincipalInfo(aPrincipal, &principalInfo), nullptr,
-            [&aRv](const nsresult rv) { aRv.Throw(rv); });
+  QM_TRY(PrincipalToPrincipalInfo(aPrincipal, &principalInfo), nullptr,
+         [&aRv](const nsresult rv) { aRv.Throw(rv); });
 
-  CACHE_TRY(OkIf(QuotaManager::IsPrincipalInfoValid(principalInfo)),
-            RefPtr{new CacheStorage(NS_ERROR_DOM_SECURITY_ERR)}.forget(),
-            [](const auto) {
-              NS_WARNING("CacheStorage not supported on invalid origins.");
-            });
+  QM_TRY(OkIf(QuotaManager::IsPrincipalInfoValid(principalInfo)),
+         RefPtr{new CacheStorage(NS_ERROR_DOM_SECURITY_ERR)}.forget(),
+         [](const auto) {
+           NS_WARNING("CacheStorage not supported on invalid origins.");
+         });
 
   const bool testingEnabled =
       aForceTrustedOrigin ||
       Preferences::GetBool("dom.caches.testing.enabled", false) ||
       StaticPrefs::dom_serviceWorkers_testing_enabled();
 
   if (!IsTrusted(principalInfo, testingEnabled)) {
     NS_WARNING("CacheStorage not supported on untrusted origins.");
@@ -190,18 +190,18 @@ already_AddRefed<CacheStorage> CacheStor
     NS_WARNING("Worker thread is shutting down.");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   const PrincipalInfo& principalInfo =
       aWorkerPrivate->GetEffectiveStoragePrincipalInfo();
 
-  CACHE_TRY(OkIf(QuotaManager::IsPrincipalInfoValid(principalInfo)), nullptr,
-            [&aRv](const auto) { aRv.Throw(NS_ERROR_FAILURE); });
+  QM_TRY(OkIf(QuotaManager::IsPrincipalInfoValid(principalInfo)), nullptr,
+         [&aRv](const auto) { aRv.Throw(NS_ERROR_FAILURE); });
 
   // We have a number of cases where we want to skip the https scheme
   // validation:
   //
   // 1) Any worker when dom.caches.testing.enabled pref is true.
   // 2) Any worker when dom.serviceWorkers.testing.enabled pref is true.  This
   //    is mainly because most sites using SWs will expect Cache to work if
   //    SWs are enabled.
--- a/dom/cache/Context.cpp
+++ b/dom/cache/Context.cpp
@@ -406,25 +406,25 @@ Context::QuotaInitRunnable::Run() {
       auto res = [this]() -> Result<Ok, nsresult> {
         if (mCanceled) {
           return Err(NS_ERROR_ABORT);
         }
 
         QuotaManager* quotaManager = QuotaManager::Get();
         MOZ_DIAGNOSTIC_ASSERT(quotaManager);
 
-        CACHE_TRY(quotaManager->EnsureStorageIsInitialized());
+        QM_TRY(quotaManager->EnsureStorageIsInitialized());
 
-        CACHE_TRY(quotaManager->EnsureTemporaryStorageIsInitialized());
+        QM_TRY(quotaManager->EnsureTemporaryStorageIsInitialized());
 
-        CACHE_TRY_UNWRAP(mQuotaInfo.mDir,
-                         quotaManager
-                             ->EnsureTemporaryOriginIsInitialized(
-                                 PERSISTENCE_TYPE_DEFAULT, mQuotaInfo)
-                             .map([](const auto& res) { return res.first; }));
+        QM_TRY_UNWRAP(mQuotaInfo.mDir,
+                      quotaManager
+                          ->EnsureTemporaryOriginIsInitialized(
+                              PERSISTENCE_TYPE_DEFAULT, mQuotaInfo)
+                          .map([](const auto& res) { return res.first; }));
 
         mState = STATE_RUN_ON_TARGET;
 
         MOZ_ALWAYS_SUCCEEDS(
             mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
 
         return Ok{};
       }();
--- a/dom/cache/DBAction.cpp
+++ b/dom/cache/DBAction.cpp
@@ -28,29 +28,28 @@ 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 QuotaInfo& aQuotaInfo, nsIFile& aDBFile) {
-  CACHE_TRY_INSPECT(
-      const auto& dbDir,
-      MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDBFile, GetParent));
+  QM_TRY_INSPECT(const auto& dbDir, MOZ_TO_RESULT_INVOKE_TYPED(
+                                        nsCOMPtr<nsIFile>, aDBFile, GetParent));
 
-  CACHE_TRY(RemoveNsIFile(aQuotaInfo, aDBFile));
+  QM_TRY(RemoveNsIFile(aQuotaInfo, 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.
-  CACHE_TRY(BodyDeleteDir(aQuotaInfo, *dbDir));
+  QM_TRY(BodyDeleteDir(aQuotaInfo, *dbDir));
 
-  CACHE_TRY(WipePaddingFile(aQuotaInfo, dbDir));
+  QM_TRY(WipePaddingFile(aQuotaInfo, dbDir));
 
   return NS_OK;
 }
 
 }  // namespace
 
 DBAction::DBAction(Mode aMode) : mMode(aMode) {}
 
@@ -66,31 +65,31 @@ void DBAction::RunOnTarget(SafeRefPtr<Re
     aResolver->Resolve(NS_ERROR_ABORT);
     return;
   }
 
   const auto resolveErr = [&aResolver](const nsresult rv) {
     aResolver->Resolve(rv);
   };
 
-  CACHE_TRY_INSPECT(const auto& dbDir,
-                    CloneFileAndAppend(*aQuotaInfo.mDir, u"cache"_ns), QM_VOID,
-                    resolveErr);
+  QM_TRY_INSPECT(const auto& dbDir,
+                 CloneFileAndAppend(*aQuotaInfo.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) {
-    CACHE_TRY_UNWRAP(conn, OpenConnection(aQuotaInfo, *dbDir), QM_VOID,
-                     resolveErr);
+    QM_TRY_UNWRAP(conn, OpenConnection(aQuotaInfo, *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
@@ -103,27 +102,27 @@ void DBAction::RunOnTarget(SafeRefPtr<Re
   RunWithDBOnTarget(std::move(aResolver), aQuotaInfo, dbDir, conn);
 }
 
 Result<nsCOMPtr<mozIStorageConnection>, nsresult> DBAction::OpenConnection(
     const QuotaInfo& aQuotaInfo, nsIFile& aDBDir) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aQuotaInfo.mDirectoryLockId >= 0);
 
-  CACHE_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(aDBDir, Exists));
+  QM_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(aDBDir, Exists));
 
   if (!exists) {
-    CACHE_TRY(OkIf(mMode == Create), Err(NS_ERROR_FILE_NOT_FOUND));
-    CACHE_TRY(aDBDir.Create(nsIFile::DIRECTORY_TYPE, 0755));
+    QM_TRY(OkIf(mMode == Create), Err(NS_ERROR_FILE_NOT_FOUND));
+    QM_TRY(aDBDir.Create(nsIFile::DIRECTORY_TYPE, 0755));
   }
 
-  CACHE_TRY_INSPECT(const auto& dbFile,
-                    CloneFileAndAppend(aDBDir, kCachesSQLiteFilename));
+  QM_TRY_INSPECT(const auto& dbFile,
+                 CloneFileAndAppend(aDBDir, kCachesSQLiteFilename));
 
-  CACHE_TRY_RETURN(OpenDBConnection(aQuotaInfo, *dbFile));
+  QM_TRY_RETURN(OpenDBConnection(aQuotaInfo, *dbFile));
 }
 
 SyncDBAction::SyncDBAction(Mode aMode) : DBAction(aMode) {}
 
 SyncDBAction::~SyncDBAction() = default;
 
 void SyncDBAction::RunWithDBOnTarget(SafeRefPtr<Resolver> aResolver,
                                      const QuotaInfo& aQuotaInfo,
@@ -143,74 +142,74 @@ Result<nsCOMPtr<mozIStorageConnection>, 
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aQuotaInfo.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>();
-  CACHE_TRY(handler->Init());
+  QM_TRY(handler->Init());
 
-  CACHE_TRY_INSPECT(const auto& mutator,
-                    MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIURIMutator>, handler,
-                                               NewFileURIMutator, &aDBFile));
+  QM_TRY_INSPECT(const auto& mutator,
+                 MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIURIMutator>, handler,
+                                            NewFileURIMutator, &aDBFile));
 
   const nsCString directoryLockIdClause =
       aQuotaInfo.mDirectoryLockId >= 0
           ? "&directoryLockId="_ns + IntToCString(aQuotaInfo.mDirectoryLockId)
           : EmptyCString();
 
   nsCOMPtr<nsIFileURL> dbFileUrl;
-  CACHE_TRY(NS_MutateURI(mutator)
-                .SetQuery("cache=private"_ns + directoryLockIdClause)
-                .Finalize(dbFileUrl));
+  QM_TRY(NS_MutateURI(mutator)
+             .SetQuery("cache=private"_ns + directoryLockIdClause)
+             .Finalize(dbFileUrl));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& storageService,
       ToResultGet<nsCOMPtr<mozIStorageService>>(
           MOZ_SELECT_OVERLOAD(do_GetService), MOZ_STORAGE_SERVICE_CONTRACTID),
       Err(NS_ERROR_UNEXPECTED));
 
-  CACHE_TRY_UNWRAP(
+  QM_TRY_UNWRAP(
       auto conn,
       QM_OR_ELSE_WARN(
           MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>,
                                      storageService, OpenDatabaseWithFileURL,
                                      dbFileUrl, ""_ns),
           ([&aQuotaInfo, &aDBFile, &storageService,
             &dbFileUrl](const nsresult rv)
                -> Result<nsCOMPtr<mozIStorageConnection>, nsresult> {
             if (IsDatabaseCorruptionError(rv)) {
               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.
-              CACHE_TRY(WipeDatabase(aQuotaInfo, aDBFile));
+              QM_TRY(WipeDatabase(aQuotaInfo, aDBFile));
 
-              CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
+              QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
                   nsCOMPtr<mozIStorageConnection>, storageService,
                   OpenDatabaseWithFileURL, dbFileUrl, ""_ns));
             }
             return Err(rv);
           })));
 
   // Check the schema to make sure it is not too old.
-  CACHE_TRY_INSPECT(const int32_t& schemaVersion,
-                    MOZ_TO_RESULT_INVOKE(conn, GetSchemaVersion));
+  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;
 
-    CACHE_TRY(WipeDatabase(aQuotaInfo, aDBFile));
+    QM_TRY(WipeDatabase(aQuotaInfo, aDBFile));
 
-    CACHE_TRY_UNWRAP(conn, MOZ_TO_RESULT_INVOKE_TYPED(
-                               nsCOMPtr<mozIStorageConnection>, storageService,
-                               OpenDatabaseWithFileURL, dbFileUrl, ""_ns));
+    QM_TRY_UNWRAP(conn, MOZ_TO_RESULT_INVOKE_TYPED(
+                            nsCOMPtr<mozIStorageConnection>, storageService,
+                            OpenDatabaseWithFileURL, dbFileUrl, ""_ns));
   }
 
-  CACHE_TRY(db::InitializeConnection(*conn));
+  QM_TRY(db::InitializeConnection(*conn));
 
   return conn;
 }
 
 }  // namespace mozilla::dom::cache
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -407,23 +407,23 @@ Result<int32_t, nsresult> GetEffectiveSc
 nsresult Validate(mozIStorageConnection& aConn);
 nsresult Migrate(mozIStorageConnection& aConn);
 }  // namespace
 
 class MOZ_RAII AutoDisableForeignKeyChecking {
  public:
   explicit AutoDisableForeignKeyChecking(mozIStorageConnection* aConn)
       : mConn(aConn), mForeignKeyCheckingDisabled(false) {
-    CACHE_TRY_INSPECT(const auto& state,
-                      quota::CreateAndExecuteSingleStepStatement(
-                          *mConn, "PRAGMA foreign_keys;"_ns),
-                      QM_VOID);
-
-    CACHE_TRY_INSPECT(const int32_t& mode,
-                      MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0), QM_VOID);
+    QM_TRY_INSPECT(const auto& state,
+                   quota::CreateAndExecuteSingleStepStatement(
+                       *mConn, "PRAGMA foreign_keys;"_ns),
+                   QM_VOID);
+
+    QM_TRY_INSPECT(const int32_t& mode,
+                   MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0), QM_VOID);
 
     if (mode) {
       QM_WARNONLY_TRY(
           ToResult(mConn->ExecuteSimpleSQL("PRAGMA foreign_keys = OFF;"_ns))
               .andThen([this](const auto) -> Result<Ok, nsresult> {
                 mForeignKeyCheckingDisabled = true;
                 return Ok{};
               }));
@@ -443,435 +443,432 @@ class MOZ_RAII AutoDisableForeignKeyChec
 
 nsresult IntegrityCheck(mozIStorageConnection& aConn) {
   // CACHE_INTEGRITY_CHECK_COUNT is designed to report at most once.
   static bool reported = false;
   if (reported) {
     return NS_OK;
   }
 
-  CACHE_TRY_INSPECT(const auto& stmt,
-                    quota::CreateAndExecuteSingleStepStatement(
-                        aConn,
-                        "SELECT COUNT(*) FROM pragma_integrity_check() "
-                        "WHERE integrity_check != 'ok';"_ns));
-
-  CACHE_TRY_INSPECT(const auto& result,
-                    MOZ_TO_RESULT_INVOKE_TYPED(nsString, *stmt, GetString, 0));
+  QM_TRY_INSPECT(const auto& stmt,
+                 quota::CreateAndExecuteSingleStepStatement(
+                     aConn,
+                     "SELECT COUNT(*) FROM pragma_integrity_check() "
+                     "WHERE integrity_check != 'ok';"_ns));
+
+  QM_TRY_INSPECT(const auto& result,
+                 MOZ_TO_RESULT_INVOKE_TYPED(nsString, *stmt, GetString, 0));
 
   nsresult rv;
   const uint32_t count = result.ToInteger(&rv);
-  CACHE_TRY(OkIf(NS_SUCCEEDED(rv)), rv);
+  QM_TRY(OkIf(NS_SUCCEEDED(rv)), rv);
 
   Telemetry::ScalarSet(Telemetry::ScalarID::CACHE_INTEGRITY_CHECK_COUNT, count);
 
   reported = true;
 
   return NS_OK;
 }
 
 nsresult CreateOrMigrateSchema(mozIStorageConnection& aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_UNWRAP(int32_t schemaVersion, GetEffectiveSchemaVersion(aConn));
+  QM_TRY_UNWRAP(int32_t schemaVersion, GetEffectiveSchemaVersion(aConn));
 
   if (schemaVersion == kLatestSchemaVersion) {
     // We already have the correct schema version.  Validate it matches
     // our expected schema and then proceed.
-    CACHE_TRY(Validate(aConn));
+    QM_TRY(Validate(aConn));
 
     return NS_OK;
   }
 
   // Turn off checking foreign keys before starting a transaction, and restore
   // it once we're done.
   AutoDisableForeignKeyChecking restoreForeignKeyChecking(&aConn);
   mozStorageTransaction trans(&aConn, false,
                               mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-  CACHE_TRY(trans.Start());
+  QM_TRY(trans.Start());
 
   const bool migrating = schemaVersion != 0;
 
   if (migrating) {
     // A schema exists, but its not the current version.  Attempt to
     // migrate it to our new schema.
-    CACHE_TRY(Migrate(aConn));
+    QM_TRY(Migrate(aConn));
   } else {
     // There is no schema installed.  Create the database from scratch.
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableCaches)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableSecurityInfo)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexSecurityInfoHash)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableEntries)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexEntriesRequest)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableRequestHeaders)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableResponseHeaders)));
-    CACHE_TRY(
-        aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexResponseHeadersName)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableResponseUrlList)));
-    CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableStorage)));
-    CACHE_TRY(aConn.SetSchemaVersion(kLatestSchemaVersion));
-    CACHE_TRY_UNWRAP(schemaVersion, GetEffectiveSchemaVersion(aConn));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableCaches)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableSecurityInfo)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexSecurityInfoHash)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableEntries)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexEntriesRequest)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableRequestHeaders)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableResponseHeaders)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexResponseHeadersName)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableResponseUrlList)));
+    QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kTableStorage)));
+    QM_TRY(aConn.SetSchemaVersion(kLatestSchemaVersion));
+    QM_TRY_UNWRAP(schemaVersion, GetEffectiveSchemaVersion(aConn));
   }
 
-  CACHE_TRY(Validate(aConn));
-  CACHE_TRY(trans.Commit());
+  QM_TRY(Validate(aConn));
+  QM_TRY(trans.Commit());
 
   if (migrating) {
     // Migrations happen infrequently and reflect a chance in DB structure.
     // This is a good time to rebuild the database.  It also helps catch
     // if a new migration is incorrect by fast failing on the corruption.
     // Unfortunately, this must be performed outside of the transaction.
 
-    CACHE_TRY(ToResult(aConn.ExecuteSimpleSQL("VACUUM"_ns))
-                  .orElse([&aConn](const nsresult rv) -> Result<Ok, nsresult> {
-                    if (rv == NS_ERROR_STORAGE_CONSTRAINT) {
-                      CACHE_TRY(IntegrityCheck(aConn));
-                    }
-
-                    return Err(rv);
-                  }));
+    QM_TRY(ToResult(aConn.ExecuteSimpleSQL("VACUUM"_ns))
+               .orElse([&aConn](const nsresult rv) -> Result<Ok, nsresult> {
+                 if (rv == NS_ERROR_STORAGE_CONSTRAINT) {
+                   QM_TRY(IntegrityCheck(aConn));
+                 }
+
+                 return Err(rv);
+               }));
   }
 
   return NS_OK;
 }
 
 nsresult InitializeConnection(mozIStorageConnection& aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // This function needs to perform per-connection initialization tasks that
   // need to happen regardless of the schema.
 
   // Note, the default encoding of UTF-8 is preferred.  mozStorage does all
   // the work necessary to convert UTF-16 nsString values for us.  We don't
   // need ordering and the binary equality operations are correct.  So, do
   // NOT set PRAGMA encoding to UTF-16.
 
-  CACHE_TRY(aConn.ExecuteSimpleSQL(nsPrintfCString(
+  QM_TRY(aConn.ExecuteSimpleSQL(nsPrintfCString(
       // Use a smaller page size to improve perf/footprint; default is too large
       "PRAGMA page_size = %u; "
       // Enable auto_vacuum; this must happen after page_size and before WAL
       "PRAGMA auto_vacuum = INCREMENTAL; "
       "PRAGMA foreign_keys = ON; ",
       kPageSize)));
 
   // Limit fragmentation by growing the database by many pages at once.
   QM_TRY(QM_OR_ELSE_WARN(ToResult(aConn.SetGrowthIncrement(kGrowthSize, ""_ns)),
                          ErrToDefaultOkOrErr<NS_ERROR_FILE_TOO_BIG>));
 
   // Enable WAL journaling.  This must be performed in a separate transaction
   // after changing the page_size and enabling auto_vacuum.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(nsPrintfCString(
+  QM_TRY(aConn.ExecuteSimpleSQL(nsPrintfCString(
       // WAL journal can grow to given number of *pages*
       "PRAGMA wal_autocheckpoint = %u; "
       // Always truncate the journal back to given number of *bytes*
       "PRAGMA journal_size_limit = %u; "
       // WAL must be enabled at the end to allow page size to be changed, etc.
       "PRAGMA journal_mode = WAL; ",
       kWalAutoCheckpointPages, kWalAutoCheckpointSize)));
 
   // Verify that we successfully set the vacuum mode to incremental.  It
   // is very easy to put the database in a state where the auto_vacuum
   // pragma above fails silently.
 #ifdef DEBUG
   {
-    CACHE_TRY_INSPECT(const auto& state,
-                      quota::CreateAndExecuteSingleStepStatement(
-                          aConn, "PRAGMA auto_vacuum;"_ns));
-
-    CACHE_TRY_INSPECT(const int32_t& mode,
-                      MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+    QM_TRY_INSPECT(const auto& state,
+                   quota::CreateAndExecuteSingleStepStatement(
+                       aConn, "PRAGMA auto_vacuum;"_ns));
+
+    QM_TRY_INSPECT(const int32_t& mode,
+                   MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
 
     // integer value 2 is incremental mode
-    CACHE_TRY(OkIf(mode == 2), NS_ERROR_UNEXPECTED);
+    QM_TRY(OkIf(mode == 2), NS_ERROR_UNEXPECTED);
   }
 #endif
 
   return NS_OK;
 }
 
 Result<CacheId, nsresult> CreateCacheId(mozIStorageConnection& aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY(aConn.ExecuteSimpleSQL("INSERT INTO caches DEFAULT VALUES;"_ns));
-
-  CACHE_TRY_INSPECT(const auto& state,
-                    quota::CreateAndExecuteSingleStepStatement<
-                        quota::SingleStepResult::ReturnNullIfNoResult>(
-                        aConn, "SELECT last_insert_rowid()"_ns));
-
-  CACHE_TRY(OkIf(state), Err(NS_ERROR_UNEXPECTED));
-
-  CACHE_TRY_INSPECT(const CacheId& id,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt64, 0));
+  QM_TRY(aConn.ExecuteSimpleSQL("INSERT INTO caches DEFAULT VALUES;"_ns));
+
+  QM_TRY_INSPECT(const auto& state,
+                 quota::CreateAndExecuteSingleStepStatement<
+                     quota::SingleStepResult::ReturnNullIfNoResult>(
+                     aConn, "SELECT last_insert_rowid()"_ns));
+
+  QM_TRY(OkIf(state), Err(NS_ERROR_UNEXPECTED));
+
+  QM_TRY_INSPECT(const CacheId& id, MOZ_TO_RESULT_INVOKE(state, GetInt64, 0));
 
   return id;
 }
 
 Result<DeletionInfo, nsresult> DeleteCacheId(mozIStorageConnection& aConn,
                                              CacheId aCacheId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Delete the bodies explicitly as we need to read out the body IDs
   // anyway.  These body IDs must be deleted one-by-one as content may
   // still be referencing them invidivually.
-  CACHE_TRY_INSPECT(const auto& matches, QueryAll(aConn, aCacheId));
+  QM_TRY_INSPECT(const auto& matches, QueryAll(aConn, aCacheId));
 
   // XXX only deletedBodyIdList needs to be non-const
-  CACHE_TRY_UNWRAP(
+  QM_TRY_UNWRAP(
       (auto [deletedBodyIdList, deletedSecurityIdList, deletedPaddingSize]),
       DeleteEntries(aConn, matches));
 
-  CACHE_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
+  QM_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
 
   // Delete the remainder of the cache using cascade semantics.
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "DELETE FROM caches WHERE id=:id;"_ns));
-
-  CACHE_TRY(state->BindInt64ByName("id"_ns, aCacheId));
-
-  CACHE_TRY(state->Execute());
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "DELETE FROM caches WHERE id=:id;"_ns));
+
+  QM_TRY(state->BindInt64ByName("id"_ns, aCacheId));
+
+  QM_TRY(state->Execute());
 
   return DeletionInfo{std::move(deletedBodyIdList), deletedPaddingSize};
 }
 
 Result<AutoTArray<CacheId, 8>, nsresult> FindOrphanedCacheIds(
     mozIStorageConnection& aConn) {
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "SELECT id FROM caches "
-                        "WHERE id NOT IN (SELECT cache_id from storage);"_ns));
-
-  CACHE_TRY_RETURN(
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "SELECT id FROM caches "
+                     "WHERE id NOT IN (SELECT cache_id from storage);"_ns));
+
+  QM_TRY_RETURN(
       (quota::CollectElementsWhileHasResultTyped<AutoTArray<CacheId, 8>>(
           *state, [](auto& stmt) {
-            CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
+            QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
           })));
 }
 
 Result<int64_t, nsresult> FindOverallPaddingSize(mozIStorageConnection& aConn) {
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "SELECT response_padding_size FROM entries "
-                        "WHERE response_padding_size IS NOT NULL;"_ns));
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "SELECT response_padding_size FROM entries "
+                     "WHERE response_padding_size IS NOT NULL;"_ns));
 
   int64_t overallPaddingSize = 0;
 
-  CACHE_TRY(quota::CollectWhileHasResult(
+  QM_TRY(quota::CollectWhileHasResult(
       *state, [&overallPaddingSize](auto& stmt) -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(const int64_t& padding_size,
-                          MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
+        QM_TRY_INSPECT(const int64_t& padding_size,
+                       MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
 
         MOZ_DIAGNOSTIC_ASSERT(padding_size >= 0);
         MOZ_DIAGNOSTIC_ASSERT(INT64_MAX - padding_size >= overallPaddingSize);
         overallPaddingSize += padding_size;
 
         return Ok{};
       }));
 
   return overallPaddingSize;
 }
 
 Result<nsTArray<nsID>, nsresult> GetKnownBodyIds(mozIStorageConnection& aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           "SELECT request_body_id, response_body_id FROM entries;"_ns));
 
   AutoTArray<nsID, 64> idList;
 
-  CACHE_TRY(quota::CollectWhileHasResult(
+  QM_TRY(quota::CollectWhileHasResult(
       *state, [&idList](auto& stmt) -> Result<Ok, nsresult> {
         // extract 0 to 2 nsID structs per row
         for (uint32_t i = 0; i < 2; ++i) {
-          CACHE_TRY_INSPECT(const bool& isNull,
-                            MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, i));
+          QM_TRY_INSPECT(const bool& isNull,
+                         MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, i));
 
           if (!isNull) {
-            CACHE_TRY_INSPECT(const auto& id, ExtractId(stmt, i));
+            QM_TRY_INSPECT(const auto& id, ExtractId(stmt, i));
 
             idList.AppendElement(id);
           }
         }
 
         return Ok{};
       }));
 
   return std::move(idList);
 }
 
 Result<Maybe<SavedResponse>, nsresult> CacheMatch(
     mozIStorageConnection& aConn, CacheId aCacheId,
     const CacheRequest& aRequest, const CacheQueryParams& aParams) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(const auto& matches,
-                    QueryCache(aConn, aCacheId, aRequest, aParams, 1));
+  QM_TRY_INSPECT(const auto& matches,
+                 QueryCache(aConn, aCacheId, aRequest, aParams, 1));
 
   if (matches.IsEmpty()) {
     return Maybe<SavedResponse>();
   }
 
-  CACHE_TRY_UNWRAP(auto response, ReadResponse(aConn, matches[0]));
+  QM_TRY_UNWRAP(auto response, ReadResponse(aConn, matches[0]));
 
   response.mCacheId = aCacheId;
 
   return Some(std::move(response));
 }
 
 Result<nsTArray<SavedResponse>, nsresult> CacheMatchAll(
     mozIStorageConnection& aConn, CacheId aCacheId,
     const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& matches, ([&aConn, aCacheId, &aMaybeRequest, &aParams] {
         if (aMaybeRequest.isNothing()) {
-          CACHE_TRY_RETURN(QueryAll(aConn, aCacheId));
+          QM_TRY_RETURN(QueryAll(aConn, aCacheId));
         }
 
-        CACHE_TRY_RETURN(
+        QM_TRY_RETURN(
             QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
       }()));
 
   // TODO: replace this with a bulk load using SQL IN clause (bug 1110458)
-  CACHE_TRY_RETURN(TransformIntoNewArrayAbortOnErr(
+  QM_TRY_RETURN(TransformIntoNewArrayAbortOnErr(
       matches,
       [&aConn, aCacheId](const auto match) -> Result<SavedResponse, nsresult> {
-        CACHE_TRY_UNWRAP(auto savedResponse, ReadResponse(aConn, match));
+        QM_TRY_UNWRAP(auto savedResponse, ReadResponse(aConn, match));
 
         savedResponse.mCacheId = aCacheId;
         return savedResponse;
       },
       fallible));
 }
 
 Result<DeletionInfo, nsresult> CachePut(mozIStorageConnection& aConn,
                                         CacheId aCacheId,
                                         const CacheRequest& aRequest,
                                         const nsID* aRequestBodyId,
                                         const CacheResponse& aResponse,
                                         const nsID* aResponseBodyId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& matches,
       QueryCache(aConn, aCacheId, aRequest,
                  CacheQueryParams(false, false, false, false, u""_ns)));
 
   // XXX only deletedBodyIdList needs to be non-const
-  CACHE_TRY_UNWRAP(
+  QM_TRY_UNWRAP(
       (auto [deletedBodyIdList, deletedSecurityIdList, deletedPaddingSize]),
       DeleteEntries(aConn, matches));
 
-  CACHE_TRY(InsertEntry(aConn, aCacheId, aRequest, aRequestBodyId, aResponse,
-                        aResponseBodyId));
+  QM_TRY(InsertEntry(aConn, aCacheId, aRequest, aRequestBodyId, aResponse,
+                     aResponseBodyId));
 
   // Delete the security values after doing the insert to avoid churning
   // the security table when its not necessary.
-  CACHE_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
+  QM_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
 
   return DeletionInfo{std::move(deletedBodyIdList), deletedPaddingSize};
 }
 
 Result<Maybe<DeletionInfo>, nsresult> CacheDelete(
     mozIStorageConnection& aConn, CacheId aCacheId,
     const CacheRequest& aRequest, const CacheQueryParams& aParams) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(const auto& matches,
-                    QueryCache(aConn, aCacheId, aRequest, aParams));
+  QM_TRY_INSPECT(const auto& matches,
+                 QueryCache(aConn, aCacheId, aRequest, aParams));
 
   if (matches.IsEmpty()) {
     return Maybe<DeletionInfo>();
   }
 
   // XXX only deletedBodyIdList needs to be non-const
-  CACHE_TRY_UNWRAP(
+  QM_TRY_UNWRAP(
       (auto [deletedBodyIdList, deletedSecurityIdList, deletedPaddingSize]),
       DeleteEntries(aConn, matches));
 
-  CACHE_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
+  QM_TRY(DeleteSecurityInfoList(aConn, deletedSecurityIdList));
 
   return Some(DeletionInfo{std::move(deletedBodyIdList), deletedPaddingSize});
 }
 
 Result<nsTArray<SavedRequest>, nsresult> CacheKeys(
     mozIStorageConnection& aConn, CacheId aCacheId,
     const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& matches, ([&aConn, aCacheId, &aMaybeRequest, &aParams] {
         if (aMaybeRequest.isNothing()) {
-          CACHE_TRY_RETURN(QueryAll(aConn, aCacheId));
+          QM_TRY_RETURN(QueryAll(aConn, aCacheId));
         }
 
-        CACHE_TRY_RETURN(
+        QM_TRY_RETURN(
             QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
       }()));
 
   // TODO: replace this with a bulk load using SQL IN clause (bug 1110458)
-  CACHE_TRY_RETURN(TransformIntoNewArrayAbortOnErr(
+  QM_TRY_RETURN(TransformIntoNewArrayAbortOnErr(
       matches,
       [&aConn, aCacheId](const auto match) -> Result<SavedRequest, nsresult> {
-        CACHE_TRY_UNWRAP(auto savedRequest, ReadRequest(aConn, match));
+        QM_TRY_UNWRAP(auto savedRequest, ReadRequest(aConn, match));
 
         savedRequest.mCacheId = aCacheId;
         return savedRequest;
       },
       fallible));
 }
 
 Result<Maybe<SavedResponse>, nsresult> StorageMatch(
     mozIStorageConnection& aConn, Namespace aNamespace,
     const CacheRequest& aRequest, const CacheQueryParams& aParams) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // If we are given a cache to check, then simply find its cache ID
   // and perform the match.
   if (aParams.cacheNameSet()) {
-    CACHE_TRY_INSPECT(
-        const auto& maybeCacheId,
-        StorageGetCacheId(aConn, aNamespace, aParams.cacheName()));
+    QM_TRY_INSPECT(const auto& maybeCacheId,
+                   StorageGetCacheId(aConn, aNamespace, aParams.cacheName()));
     if (maybeCacheId.isNothing()) {
       return Maybe<SavedResponse>();
     }
 
     return CacheMatch(aConn, maybeCacheId.ref(), aRequest, aParams);
   }
 
   // Otherwise we need to get a list of all the cache IDs in this namespace.
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "SELECT cache_id FROM storage WHERE "
-                        "namespace=:namespace ORDER BY rowid;"_ns));
-
-  CACHE_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
-
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "SELECT cache_id FROM storage WHERE "
+                     "namespace=:namespace ORDER BY rowid;"_ns));
+
+  QM_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
+
+  QM_TRY_INSPECT(
       const auto& cacheIdList,
       (quota::CollectElementsWhileHasResultTyped<AutoTArray<CacheId, 32>>(
           *state, [](auto& stmt) {
-            CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
+            QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 0));
           })));
 
   // Now try to find a match in each cache in order
   for (const auto cacheId : cacheIdList) {
-    CACHE_TRY_UNWRAP(auto matchedResponse,
-                     CacheMatch(aConn, cacheId, aRequest, aParams));
+    QM_TRY_UNWRAP(auto matchedResponse,
+                  CacheMatch(aConn, cacheId, aRequest, aParams));
 
     if (matchedResponse.isSome()) {
       return matchedResponse;
     }
   }
 
   return Maybe<SavedResponse>();
 }
@@ -884,105 +881,104 @@ Result<Maybe<CacheId>, nsresult> Storage
   // How we constrain the key column depends on the value of our key.  Use
   // a format string for the query and let CreateAndBindKeyStatement() fill
   // it in for us.
   const char* const query =
       "SELECT cache_id FROM storage "
       "WHERE namespace=:namespace AND %s "
       "ORDER BY rowid;";
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    CreateAndBindKeyStatement(aConn, query, aKey));
-
-  CACHE_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
-
-  CACHE_TRY_INSPECT(const bool& hasMoreData,
-                    MOZ_TO_RESULT_INVOKE(*state, ExecuteStep));
+  QM_TRY_INSPECT(const auto& state,
+                 CreateAndBindKeyStatement(aConn, query, aKey));
+
+  QM_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
+
+  QM_TRY_INSPECT(const bool& hasMoreData,
+                 MOZ_TO_RESULT_INVOKE(*state, ExecuteStep));
 
   if (!hasMoreData) {
     return Maybe<CacheId>();
   }
 
-  CACHE_TRY_RETURN(
-      MOZ_TO_RESULT_INVOKE(*state, GetInt64, 0).map(Some<CacheId>));
+  QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt64, 0).map(Some<CacheId>));
 }
 
 nsresult StoragePutCache(mozIStorageConnection& aConn, Namespace aNamespace,
                          const nsAString& aKey, CacheId aCacheId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "INSERT INTO storage (namespace, key, cache_id) "
-                        "VALUES (:namespace, :key, :cache_id);"_ns));
-
-  CACHE_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
-  CACHE_TRY(state->BindStringAsBlobByName("key"_ns, aKey));
-  CACHE_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
-  CACHE_TRY(state->Execute());
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "INSERT INTO storage (namespace, key, cache_id) "
+                     "VALUES (:namespace, :key, :cache_id);"_ns));
+
+  QM_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
+  QM_TRY(state->BindStringAsBlobByName("key"_ns, aKey));
+  QM_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
+  QM_TRY(state->Execute());
 
   return NS_OK;
 }
 
 nsresult StorageForgetCache(mozIStorageConnection& aConn, Namespace aNamespace,
                             const nsAString& aKey) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // How we constrain the key column depends on the value of our key.  Use
   // a format string for the query and let CreateAndBindKeyStatement() fill
   // it in for us.
   const char* const query =
       "DELETE FROM storage WHERE namespace=:namespace AND %s;";
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    CreateAndBindKeyStatement(aConn, query, aKey));
-
-  CACHE_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
-
-  CACHE_TRY(state->Execute());
+  QM_TRY_INSPECT(const auto& state,
+                 CreateAndBindKeyStatement(aConn, query, aKey));
+
+  QM_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
+
+  QM_TRY(state->Execute());
 
   return NS_OK;
 }
 
 Result<nsTArray<nsString>, nsresult> StorageGetKeys(
     mozIStorageConnection& aConn, Namespace aNamespace) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           "SELECT key FROM storage WHERE namespace=:namespace ORDER BY rowid;"_ns));
 
-  CACHE_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
-
-  CACHE_TRY_RETURN(quota::CollectElementsWhileHasResult(*state, [](auto& stmt) {
-    CACHE_TRY_RETURN(
+  QM_TRY(state->BindInt32ByName("namespace"_ns, aNamespace));
+
+  QM_TRY_RETURN(quota::CollectElementsWhileHasResult(*state, [](auto& stmt) {
+    QM_TRY_RETURN(
         MOZ_TO_RESULT_INVOKE_TYPED(nsString, stmt, GetBlobAsString, 0));
   }));
 }
 
 namespace {
 
 Result<EntryIds, nsresult> QueryAll(mozIStorageConnection& aConn,
                                     CacheId aCacheId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           "SELECT id FROM entries WHERE cache_id=:cache_id ORDER BY id;"_ns));
 
-  CACHE_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
-
-  CACHE_TRY_RETURN((quota::CollectElementsWhileHasResultTyped<EntryIds>(
+  QM_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
+
+  QM_TRY_RETURN((quota::CollectElementsWhileHasResultTyped<EntryIds>(
       *state, [](auto& stmt) {
-        CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 0));
+        QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 0));
       })));
 }
 
 Result<EntryIds, nsresult> QueryCache(mozIStorageConnection& aConn,
                                       CacheId aCacheId,
                                       const CacheRequest& aRequest,
                                       const CacheQueryParams& aParams,
                                       uint32_t aMaxResults) {
@@ -1010,68 +1006,67 @@ Result<EntryIds, nsresult> QueryCache(mo
   query.AppendLiteral("AND entries.request_url_no_query=:url_no_query ");
 
   if (!aParams.ignoreSearch()) {
     query.AppendLiteral("AND entries.request_url_query=:url_query ");
   }
 
   query.AppendLiteral("GROUP BY entries.id ORDER BY entries.id;");
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
-                                               aConn, CreateStatement, query));
-
-  CACHE_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
-
-  CACHE_TRY_INSPECT(
-      const auto& crypto,
-      ToResultGet<nsCOMPtr<nsICryptoHash>>(
-          MOZ_SELECT_OVERLOAD(do_CreateInstance), NS_CRYPTO_HASH_CONTRACTID));
-
-  CACHE_TRY_INSPECT(const auto& urlWithoutQueryHash,
-                    HashCString(*crypto, aRequest.urlWithoutQuery()));
-
-  CACHE_TRY(state->BindUTF8StringAsBlobByName("url_no_query_hash"_ns,
-                                              urlWithoutQueryHash));
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                            aConn, CreateStatement, query));
+
+  QM_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
+
+  QM_TRY_INSPECT(const auto& crypto, ToResultGet<nsCOMPtr<nsICryptoHash>>(
+                                         MOZ_SELECT_OVERLOAD(do_CreateInstance),
+                                         NS_CRYPTO_HASH_CONTRACTID));
+
+  QM_TRY_INSPECT(const auto& urlWithoutQueryHash,
+                 HashCString(*crypto, aRequest.urlWithoutQuery()));
+
+  QM_TRY(state->BindUTF8StringAsBlobByName("url_no_query_hash"_ns,
+                                           urlWithoutQueryHash));
 
   if (!aParams.ignoreSearch()) {
-    CACHE_TRY_INSPECT(const auto& urlQueryHash,
-                      HashCString(*crypto, aRequest.urlQuery()));
-
-    CACHE_TRY(
+    QM_TRY_INSPECT(const auto& urlQueryHash,
+                   HashCString(*crypto, aRequest.urlQuery()));
+
+    QM_TRY(
         state->BindUTF8StringAsBlobByName("url_query_hash"_ns, urlQueryHash));
   }
 
-  CACHE_TRY(state->BindUTF8StringByName("url_no_query"_ns,
-                                        aRequest.urlWithoutQuery()));
+  QM_TRY(state->BindUTF8StringByName("url_no_query"_ns,
+                                     aRequest.urlWithoutQuery()));
 
   if (!aParams.ignoreSearch()) {
-    CACHE_TRY(state->BindUTF8StringByName("url_query"_ns, aRequest.urlQuery()));
+    QM_TRY(state->BindUTF8StringByName("url_query"_ns, aRequest.urlQuery()));
   }
 
   EntryIds entryIdList;
 
-  CACHE_TRY(CollectWhile(
+  QM_TRY(CollectWhile(
       [&state, &entryIdList, aMaxResults]() -> Result<bool, nsresult> {
         if (entryIdList.Length() == aMaxResults) {
           return false;
         }
-        CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(state, ExecuteStep));
+        QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(state, ExecuteStep));
       },
       [&state, &entryIdList, ignoreVary = aParams.ignoreVary(), &aConn,
        &aRequest]() -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(const EntryId& entryId,
-                          MOZ_TO_RESULT_INVOKE(state, GetInt32, 0));
-
-        CACHE_TRY_INSPECT(const int32_t& varyCount,
-                          MOZ_TO_RESULT_INVOKE(state, GetInt32, 1));
+        QM_TRY_INSPECT(const EntryId& entryId,
+                       MOZ_TO_RESULT_INVOKE(state, GetInt32, 0));
+
+        QM_TRY_INSPECT(const int32_t& varyCount,
+                       MOZ_TO_RESULT_INVOKE(state, GetInt32, 1));
 
         if (!ignoreVary && varyCount > 0) {
-          CACHE_TRY_INSPECT(const bool& matchedByVary,
-                            MatchByVaryHeader(aConn, aRequest, entryId));
+          QM_TRY_INSPECT(const bool& matchedByVary,
+                         MatchByVaryHeader(aConn, aRequest, entryId));
           if (!matchedByVary) {
             return Ok{};
           }
         }
 
         entryIdList.AppendElement(entryId);
 
         return Ok{};
@@ -1080,57 +1075,57 @@ Result<EntryIds, nsresult> QueryCache(mo
   return entryIdList;
 }
 
 Result<bool, nsresult> MatchByVaryHeader(mozIStorageConnection& aConn,
                                          const CacheRequest& aRequest,
                                          EntryId entryId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& varyValues,
       ([&aConn, entryId]() -> Result<AutoTArray<nsCString, 8>, nsresult> {
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& state,
             MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>, aConn,
                                        CreateStatement,
                                        "SELECT value FROM response_headers "
                                        "WHERE name='vary' COLLATE NOCASE "
                                        "AND entry_id=:entry_id;"_ns));
 
-        CACHE_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
-
-        CACHE_TRY_RETURN((
+        QM_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
+
+        QM_TRY_RETURN((
             quota::CollectElementsWhileHasResultTyped<AutoTArray<nsCString, 8>>(
                 *state, [](auto& stmt) {
-                  CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
-                      nsCString, stmt, GetUTF8String, 0));
+                  QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt,
+                                                           GetUTF8String, 0));
                 })));
       }()));
 
   // Should not have called this function if this was not the case
   MOZ_DIAGNOSTIC_ASSERT(!varyValues.IsEmpty());
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "SELECT name, value FROM request_headers "
-                        "WHERE entry_id=:entry_id;"_ns));
-
-  CACHE_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "SELECT name, value FROM request_headers "
+                     "WHERE entry_id=:entry_id;"_ns));
+
+  QM_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
 
   RefPtr<InternalHeaders> cachedHeaders =
       new InternalHeaders(HeadersGuardEnum::None);
 
-  CACHE_TRY(quota::CollectWhileHasResult(
+  QM_TRY(quota::CollectWhileHasResult(
       *state, [&cachedHeaders](auto& stmt) -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& name,
             MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 0));
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& value,
             MOZ_TO_RESULT_INVOKE_TYPED(nsCString, stmt, GetUTF8String, 1));
 
         ErrorResult errorResult;
 
         cachedHeaders->Append(name, value, errorResult);
         if (errorResult.Failed()) {
           return Err(errorResult.StealNSResult());
@@ -1231,47 +1226,47 @@ static nsresult DeleteEntriesInternal(
       "request_body_id, "
       "response_body_id, "
       "response_security_info_id, "
       "response_padding_size "
       "FROM entries WHERE id IN (");
   AppendListParamsToQuery(query, aEntryIdList, aPos, aLen);
   query.AppendLiteral(")");
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
-                                               aConn, CreateStatement, query));
-
-  CACHE_TRY(BindListParamsToQuery(*state, aEntryIdList, aPos, aLen));
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                            aConn, CreateStatement, query));
+
+  QM_TRY(BindListParamsToQuery(*state, aEntryIdList, aPos, aLen));
 
   int64_t overallPaddingSize = 0;
 
-  CACHE_TRY(quota::CollectWhileHasResult(
+  QM_TRY(quota::CollectWhileHasResult(
       *state,
       [&overallPaddingSize, &aDeletedBodyIdListOut,
        &aDeletedSecurityIdListOut](auto& stmt) -> Result<Ok, nsresult> {
         // extract 0 to 2 nsID structs per row
         for (uint32_t i = 0; i < 2; ++i) {
-          CACHE_TRY_INSPECT(const bool& isNull,
-                            MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, i));
+          QM_TRY_INSPECT(const bool& isNull,
+                         MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, i));
 
           if (!isNull) {
-            CACHE_TRY_INSPECT(const auto& id, ExtractId(stmt, i));
+            QM_TRY_INSPECT(const auto& id, ExtractId(stmt, i));
 
             aDeletedBodyIdListOut.AppendElement(id);
           }
         }
 
         {  // and then a possible third entry for the security id
-          CACHE_TRY_INSPECT(const bool& isNull,
-                            MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, 2));
+          QM_TRY_INSPECT(const bool& isNull,
+                         MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, 2));
 
           if (!isNull) {
-            CACHE_TRY_INSPECT(const int32_t& securityId,
-                              MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 2));
+            QM_TRY_INSPECT(const int32_t& securityId,
+                           MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 2));
 
             // XXXtt: Consider using map for aDeletedSecuityIdListOut.
             auto foundIt =
                 std::find_if(aDeletedSecurityIdListOut.begin(),
                              aDeletedSecurityIdListOut.end(),
                              [securityId](const auto& deletedSecurityId) {
                                return deletedSecurityId.mId == securityId;
                              });
@@ -1284,22 +1279,22 @@ static nsresult DeleteEntriesInternal(
               // Otherwise, increment the count for this ID
               foundIt->mCount += 1;
             }
           }
         }
 
         {
           // It's possible to have null padding size for non-opaque response
-          CACHE_TRY_INSPECT(const bool& isNull,
-                            MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, 3));
+          QM_TRY_INSPECT(const bool& isNull,
+                         MOZ_TO_RESULT_INVOKE(stmt, GetIsNull, 3));
 
           if (!isNull) {
-            CACHE_TRY_INSPECT(const int64_t& paddingSize,
-                              MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 3));
+            QM_TRY_INSPECT(const int64_t& paddingSize,
+                           MOZ_TO_RESULT_INVOKE(stmt, GetInt64, 3));
 
             MOZ_DIAGNOSTIC_ASSERT(paddingSize >= 0);
             MOZ_DIAGNOSTIC_ASSERT(INT64_MAX - overallPaddingSize >=
                                   paddingSize);
             overallPaddingSize += paddingSize;
           }
         }
 
@@ -1310,329 +1305,325 @@ static nsresult DeleteEntriesInternal(
 
   // Dependent records removed via ON DELETE CASCADE
 
   query = "DELETE FROM entries WHERE id IN ("_ns;
   AppendListParamsToQuery(query, aEntryIdList, aPos, aLen);
   query.AppendLiteral(")");
 
   {
-    CACHE_TRY_INSPECT(const auto& state, MOZ_TO_RESULT_INVOKE_TYPED(
-                                             nsCOMPtr<mozIStorageStatement>,
-                                             aConn, CreateStatement, query));
-
-    CACHE_TRY(BindListParamsToQuery(*state, aEntryIdList, aPos, aLen));
-
-    CACHE_TRY(state->Execute());
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement, query));
+
+    QM_TRY(BindListParamsToQuery(*state, aEntryIdList, aPos, aLen));
+
+    QM_TRY(state->Execute());
   }
 
   return NS_OK;
 }
 
 Result<std::tuple<nsTArray<nsID>, AutoTArray<IdCount, 16>, int64_t>, nsresult>
 DeleteEntries(mozIStorageConnection& aConn,
               const nsTArray<EntryId>& aEntryIdList) {
   auto result =
       std::make_tuple(nsTArray<nsID>{}, AutoTArray<IdCount, 16>{}, int64_t{0});
-  CACHE_TRY(DeleteEntriesInternal(aConn, aEntryIdList, std::get<0>(result),
-                                  std::get<1>(result), &std::get<2>(result), 0,
-                                  aEntryIdList.Length()));
+  QM_TRY(DeleteEntriesInternal(aConn, aEntryIdList, std::get<0>(result),
+                               std::get<1>(result), &std::get<2>(result), 0,
+                               aEntryIdList.Length()));
 
   return result;
 }
 
 Result<int32_t, nsresult> InsertSecurityInfo(mozIStorageConnection& aConn,
                                              nsICryptoHash& aCrypto,
                                              const nsACString& aData) {
   MOZ_DIAGNOSTIC_ASSERT(!aData.IsEmpty());
 
   // We want to use an index to find existing security blobs, but indexing
   // the full blob would be quite expensive.  Instead, we index a small
   // hash value.  Calculate this hash as the first 8 bytes of the SHA1 of
   // the full data.
-  CACHE_TRY_INSPECT(const auto& hash, HashCString(aCrypto, aData));
+  QM_TRY_INSPECT(const auto& hash, HashCString(aCrypto, aData));
 
   // Next, search for an existing entry for this blob by comparing the hash
   // value first and then the full data.  SQLite is smart enough to use
   // the index on the hash to search the table before doing the expensive
   // comparison of the large data column.  (This was verified with EXPLAIN.)
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& selectStmt,
       quota::CreateAndExecuteSingleStepStatement<
           quota::SingleStepResult::ReturnNullIfNoResult>(
           aConn,
           // Note that hash and data are blobs, but we can use = here since the
           // columns are NOT NULL.
           "SELECT id, refcount FROM security_info WHERE hash=:hash AND "
           "data=:data;"_ns,
           [&hash, &aData](auto& state) -> Result<Ok, nsresult> {
-            CACHE_TRY(state.BindUTF8StringAsBlobByName("hash"_ns, hash));
-            CACHE_TRY(state.BindUTF8StringAsBlobByName("data"_ns, aData));
+            QM_TRY(state.BindUTF8StringAsBlobByName("hash"_ns, hash));
+            QM_TRY(state.BindUTF8StringAsBlobByName("data"_ns, aData));
 
             return Ok{};
           }));
 
   // This security info blob is already in the database
   if (selectStmt) {
     // get the existing security blob id to return
-    CACHE_TRY_INSPECT(const int32_t& id,
-                      MOZ_TO_RESULT_INVOKE(selectStmt, GetInt32, 0));
-    CACHE_TRY_INSPECT(const int32_t& refcount,
-                      MOZ_TO_RESULT_INVOKE(selectStmt, GetInt32, 1));
+    QM_TRY_INSPECT(const int32_t& id,
+                   MOZ_TO_RESULT_INVOKE(selectStmt, GetInt32, 0));
+    QM_TRY_INSPECT(const int32_t& refcount,
+                   MOZ_TO_RESULT_INVOKE(selectStmt, GetInt32, 1));
 
     // But first, update the refcount in the database.
-    CACHE_TRY_INSPECT(
+    QM_TRY_INSPECT(
         const auto& state,
         MOZ_TO_RESULT_INVOKE_TYPED(
             nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
             "UPDATE security_info SET refcount=:refcount WHERE id=:id;"_ns));
 
-    CACHE_TRY(state->BindInt32ByName("refcount"_ns, refcount + 1));
-    CACHE_TRY(state->BindInt32ByName("id"_ns, id));
-    CACHE_TRY(state->Execute());
+    QM_TRY(state->BindInt32ByName("refcount"_ns, refcount + 1));
+    QM_TRY(state->BindInt32ByName("id"_ns, id));
+    QM_TRY(state->Execute());
 
     return id;
   }
 
   // This is a new security info blob.  Create a new row in the security table
   // with an initial refcount of 1.
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "INSERT INTO security_info (hash, data, refcount) "
-                        "VALUES (:hash, :data, 1);"_ns));
-
-  CACHE_TRY(state->BindUTF8StringAsBlobByName("hash"_ns, hash));
-  CACHE_TRY(state->BindUTF8StringAsBlobByName("data"_ns, aData));
-  CACHE_TRY(state->Execute());
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "INSERT INTO security_info (hash, data, refcount) "
+                     "VALUES (:hash, :data, 1);"_ns));
+
+  QM_TRY(state->BindUTF8StringAsBlobByName("hash"_ns, hash));
+  QM_TRY(state->BindUTF8StringAsBlobByName("data"_ns, aData));
+  QM_TRY(state->Execute());
 
   {
-    CACHE_TRY_INSPECT(const auto& state,
-                      quota::CreateAndExecuteSingleStepStatement(
-                          aConn, "SELECT last_insert_rowid()"_ns));
-
-    CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+    QM_TRY_INSPECT(const auto& state,
+                   quota::CreateAndExecuteSingleStepStatement(
+                       aConn, "SELECT last_insert_rowid()"_ns));
+
+    QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
   }
 }
 
 nsresult DeleteSecurityInfo(mozIStorageConnection& aConn, int32_t aId,
                             int32_t aCount) {
   // First, we need to determine the current refcount for this security blob.
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const int32_t& refcount, ([&aConn, aId]() -> Result<int32_t, nsresult> {
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& state,
             quota::CreateAndExecuteSingleStepStatement(
                 aConn, "SELECT refcount FROM security_info WHERE id=:id;"_ns,
                 [aId](auto& state) -> Result<Ok, nsresult> {
-                  CACHE_TRY(state.BindInt32ByName("id"_ns, aId));
+                  QM_TRY(state.BindInt32ByName("id"_ns, aId));
                   return Ok{};
                 }));
 
-        CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+        QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
       }()));
 
   MOZ_DIAGNOSTIC_ASSERT(refcount >= aCount);
 
   // Next, calculate the new refcount
   int32_t newCount = refcount - aCount;
 
   // If the last reference to this security blob was removed we can
   // just remove the entire row.
   if (newCount == 0) {
-    CACHE_TRY_INSPECT(
-        const auto& state,
-        MOZ_TO_RESULT_INVOKE_TYPED(
-            nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-            "DELETE FROM security_info WHERE id=:id;"_ns));
-
-    CACHE_TRY(state->BindInt32ByName("id"_ns, aId));
-    CACHE_TRY(state->Execute());
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(
+                       nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                       "DELETE FROM security_info WHERE id=:id;"_ns));
+
+    QM_TRY(state->BindInt32ByName("id"_ns, aId));
+    QM_TRY(state->Execute());
 
     return NS_OK;
   }
 
   // Otherwise update the refcount in the table to reflect the reduced
   // number of references to the security blob.
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           "UPDATE security_info SET refcount=:refcount WHERE id=:id;"_ns));
 
-  CACHE_TRY(state->BindInt32ByName("refcount"_ns, newCount));
-  CACHE_TRY(state->BindInt32ByName("id"_ns, aId));
-  CACHE_TRY(state->Execute());
+  QM_TRY(state->BindInt32ByName("refcount"_ns, newCount));
+  QM_TRY(state->BindInt32ByName("id"_ns, aId));
+  QM_TRY(state->Execute());
 
   return NS_OK;
 }
 
 nsresult DeleteSecurityInfoList(
     mozIStorageConnection& aConn,
     const nsTArray<IdCount>& aDeletedStorageIdList) {
   for (const auto& deletedStorageId : aDeletedStorageIdList) {
-    CACHE_TRY(DeleteSecurityInfo(aConn, deletedStorageId.mId,
-                                 deletedStorageId.mCount));
+    QM_TRY(DeleteSecurityInfo(aConn, deletedStorageId.mId,
+                              deletedStorageId.mCount));
   }
 
   return NS_OK;
 }
 
 nsresult InsertEntry(mozIStorageConnection& aConn, CacheId aCacheId,
                      const CacheRequest& aRequest, const nsID* aRequestBodyId,
                      const CacheResponse& aResponse,
                      const nsID* aResponseBodyId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
-      const auto& crypto,
-      ToResultGet<nsCOMPtr<nsICryptoHash>>(
-          MOZ_SELECT_OVERLOAD(do_CreateInstance), NS_CRYPTO_HASH_CONTRACTID));
+  QM_TRY_INSPECT(const auto& crypto, ToResultGet<nsCOMPtr<nsICryptoHash>>(
+                                         MOZ_SELECT_OVERLOAD(do_CreateInstance),
+                                         NS_CRYPTO_HASH_CONTRACTID));
 
   int32_t securityId = -1;
   if (!aResponse.channelInfo().securityInfo().IsEmpty()) {
-    CACHE_TRY_UNWRAP(
-        securityId, InsertSecurityInfo(aConn, *crypto,
-                                       aResponse.channelInfo().securityInfo()));
+    QM_TRY_UNWRAP(securityId,
+                  InsertSecurityInfo(aConn, *crypto,
+                                     aResponse.channelInfo().securityInfo()));
   }
 
   {
-    CACHE_TRY_INSPECT(const auto& state,
-                      MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
-                                                 aConn, CreateStatement,
-                                                 "INSERT INTO entries ("
-                                                 "request_method, "
-                                                 "request_url_no_query, "
-                                                 "request_url_no_query_hash, "
-                                                 "request_url_query, "
-                                                 "request_url_query_hash, "
-                                                 "request_url_fragment, "
-                                                 "request_referrer, "
-                                                 "request_referrer_policy, "
-                                                 "request_headers_guard, "
-                                                 "request_mode, "
-                                                 "request_credentials, "
-                                                 "request_contentpolicytype, "
-                                                 "request_cache, "
-                                                 "request_redirect, "
-                                                 "request_integrity, "
-                                                 "request_body_id, "
-                                                 "response_type, "
-                                                 "response_status, "
-                                                 "response_status_text, "
-                                                 "response_headers_guard, "
-                                                 "response_body_id, "
-                                                 "response_security_info_id, "
-                                                 "response_principal_info, "
-                                                 "response_padding_size, "
-                                                 "cache_id "
-                                                 ") VALUES ("
-                                                 ":request_method, "
-                                                 ":request_url_no_query, "
-                                                 ":request_url_no_query_hash, "
-                                                 ":request_url_query, "
-                                                 ":request_url_query_hash, "
-                                                 ":request_url_fragment, "
-                                                 ":request_referrer, "
-                                                 ":request_referrer_policy, "
-                                                 ":request_headers_guard, "
-                                                 ":request_mode, "
-                                                 ":request_credentials, "
-                                                 ":request_contentpolicytype, "
-                                                 ":request_cache, "
-                                                 ":request_redirect, "
-                                                 ":request_integrity, "
-                                                 ":request_body_id, "
-                                                 ":response_type, "
-                                                 ":response_status, "
-                                                 ":response_status_text, "
-                                                 ":response_headers_guard, "
-                                                 ":response_body_id, "
-                                                 ":response_security_info_id, "
-                                                 ":response_principal_info, "
-                                                 ":response_padding_size, "
-                                                 ":cache_id "
-                                                 ");"_ns));
-
-    CACHE_TRY(
-        state->BindUTF8StringByName("request_method"_ns, aRequest.method()));
-
-    CACHE_TRY(state->BindUTF8StringByName("request_url_no_query"_ns,
-                                          aRequest.urlWithoutQuery()));
-
-    CACHE_TRY_INSPECT(const auto& urlWithoutQueryHash,
-                      HashCString(*crypto, aRequest.urlWithoutQuery()));
-
-    CACHE_TRY(state->BindUTF8StringAsBlobByName("request_url_no_query_hash"_ns,
-                                                urlWithoutQueryHash));
-
-    CACHE_TRY(state->BindUTF8StringByName("request_url_query"_ns,
-                                          aRequest.urlQuery()));
-
-    CACHE_TRY_INSPECT(const auto& urlQueryHash,
-                      HashCString(*crypto, aRequest.urlQuery()));
-
-    CACHE_TRY(state->BindUTF8StringAsBlobByName("request_url_query_hash"_ns,
-                                                urlQueryHash));
-
-    CACHE_TRY(state->BindUTF8StringByName("request_url_fragment"_ns,
-                                          aRequest.urlFragment()));
-
-    CACHE_TRY(
-        state->BindStringByName("request_referrer"_ns, aRequest.referrer()));
-
-    CACHE_TRY(state->BindInt32ByName(
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement,
+                                              "INSERT INTO entries ("
+                                              "request_method, "
+                                              "request_url_no_query, "
+                                              "request_url_no_query_hash, "
+                                              "request_url_query, "
+                                              "request_url_query_hash, "
+                                              "request_url_fragment, "
+                                              "request_referrer, "
+                                              "request_referrer_policy, "
+                                              "request_headers_guard, "
+                                              "request_mode, "
+                                              "request_credentials, "
+                                              "request_contentpolicytype, "
+                                              "request_cache, "
+                                              "request_redirect, "
+                                              "request_integrity, "
+                                              "request_body_id, "
+                                              "response_type, "
+                                              "response_status, "
+                                              "response_status_text, "
+                                              "response_headers_guard, "
+                                              "response_body_id, "
+                                              "response_security_info_id, "
+                                              "response_principal_info, "
+                                              "response_padding_size, "
+                                              "cache_id "
+                                              ") VALUES ("
+                                              ":request_method, "
+                                              ":request_url_no_query, "
+                                              ":request_url_no_query_hash, "
+                                              ":request_url_query, "
+                                              ":request_url_query_hash, "
+                                              ":request_url_fragment, "
+                                              ":request_referrer, "
+                                              ":request_referrer_policy, "
+                                              ":request_headers_guard, "
+                                              ":request_mode, "
+                                              ":request_credentials, "
+                                              ":request_contentpolicytype, "
+                                              ":request_cache, "
+                                              ":request_redirect, "
+                                              ":request_integrity, "
+                                              ":request_body_id, "
+                                              ":response_type, "
+                                              ":response_status, "
+                                              ":response_status_text, "
+                                              ":response_headers_guard, "
+                                              ":response_body_id, "
+                                              ":response_security_info_id, "
+                                              ":response_principal_info, "
+                                              ":response_padding_size, "
+                                              ":cache_id "
+                                              ");"_ns));
+
+    QM_TRY(state->BindUTF8StringByName("request_method"_ns, aRequest.method()));
+
+    QM_TRY(state->BindUTF8StringByName("request_url_no_query"_ns,
+                                       aRequest.urlWithoutQuery()));
+
+    QM_TRY_INSPECT(const auto& urlWithoutQueryHash,
+                   HashCString(*crypto, aRequest.urlWithoutQuery()));
+
+    QM_TRY(state->BindUTF8StringAsBlobByName("request_url_no_query_hash"_ns,
+                                             urlWithoutQueryHash));
+
+    QM_TRY(state->BindUTF8StringByName("request_url_query"_ns,
+                                       aRequest.urlQuery()));
+
+    QM_TRY_INSPECT(const auto& urlQueryHash,
+                   HashCString(*crypto, aRequest.urlQuery()));
+
+    QM_TRY(state->BindUTF8StringAsBlobByName("request_url_query_hash"_ns,
+                                             urlQueryHash));
+
+    QM_TRY(state->BindUTF8StringByName("request_url_fragment"_ns,
+                                       aRequest.urlFragment()));
+
+    QM_TRY(state->BindStringByName("request_referrer"_ns, aRequest.referrer()));
+
+    QM_TRY(state->BindInt32ByName(
         "request_referrer_policy"_ns,
         static_cast<int32_t>(aRequest.referrerPolicy())));
 
-    CACHE_TRY(
+    QM_TRY(
         state->BindInt32ByName("request_headers_guard"_ns,
                                static_cast<int32_t>(aRequest.headersGuard())));
 
-    CACHE_TRY(state->BindInt32ByName("request_mode"_ns,
-                                     static_cast<int32_t>(aRequest.mode())));
-
-    CACHE_TRY(
+    QM_TRY(state->BindInt32ByName("request_mode"_ns,
+                                  static_cast<int32_t>(aRequest.mode())));
+
+    QM_TRY(
         state->BindInt32ByName("request_credentials"_ns,
                                static_cast<int32_t>(aRequest.credentials())));
 
-    CACHE_TRY(state->BindInt32ByName(
+    QM_TRY(state->BindInt32ByName(
         "request_contentpolicytype"_ns,
         static_cast<int32_t>(aRequest.contentPolicyType())));
 
-    CACHE_TRY(state->BindInt32ByName(
+    QM_TRY(state->BindInt32ByName(
         "request_cache"_ns, static_cast<int32_t>(aRequest.requestCache())));
 
-    CACHE_TRY(state->BindInt32ByName(
+    QM_TRY(state->BindInt32ByName(
         "request_redirect"_ns,
         static_cast<int32_t>(aRequest.requestRedirect())));
 
-    CACHE_TRY(
+    QM_TRY(
         state->BindStringByName("request_integrity"_ns, aRequest.integrity()));
 
-    CACHE_TRY(BindId(*state, "request_body_id"_ns, aRequestBodyId));
-
-    CACHE_TRY(state->BindInt32ByName("response_type"_ns,
-                                     static_cast<int32_t>(aResponse.type())));
-
-    CACHE_TRY(state->BindInt32ByName("response_status"_ns, aResponse.status()));
-
-    CACHE_TRY(state->BindUTF8StringByName("response_status_text"_ns,
-                                          aResponse.statusText()));
-
-    CACHE_TRY(
+    QM_TRY(BindId(*state, "request_body_id"_ns, aRequestBodyId));
+
+    QM_TRY(state->BindInt32ByName("response_type"_ns,
+                                  static_cast<int32_t>(aResponse.type())));
+
+    QM_TRY(state->BindInt32ByName("response_status"_ns, aResponse.status()));
+
+    QM_TRY(state->BindUTF8StringByName("response_status_text"_ns,
+                                       aResponse.statusText()));
+
+    QM_TRY(
         state->BindInt32ByName("response_headers_guard"_ns,
                                static_cast<int32_t>(aResponse.headersGuard())));
 
-    CACHE_TRY(BindId(*state, "response_body_id"_ns, aResponseBodyId));
+    QM_TRY(BindId(*state, "response_body_id"_ns, aResponseBodyId));
 
     if (aResponse.channelInfo().securityInfo().IsEmpty()) {
-      CACHE_TRY(state->BindNullByName("response_security_info_id"_ns));
+      QM_TRY(state->BindNullByName("response_security_info_id"_ns));
     } else {
-      CACHE_TRY(
+      QM_TRY(
           state->BindInt32ByName("response_security_info_id"_ns, securityId));
     }
 
     nsAutoCString serializedInfo;
     // We only allow content serviceworkers right now.
     if (aResponse.principalInfo().isSome()) {
       const mozilla::ipc::PrincipalInfo& principalInfo =
           aResponse.principalInfo().ref();
@@ -1643,186 +1634,183 @@ nsresult InsertEntry(mozIStorageConnecti
 
       serializedInfo.Append(cInfo.spec());
 
       nsAutoCString suffix;
       cInfo.attrs().CreateSuffix(suffix);
       serializedInfo.Append(suffix);
     }
 
-    CACHE_TRY(state->BindUTF8StringByName("response_principal_info"_ns,
-                                          serializedInfo));
+    QM_TRY(state->BindUTF8StringByName("response_principal_info"_ns,
+                                       serializedInfo));
 
     if (aResponse.paddingSize() == InternalResponse::UNKNOWN_PADDING_SIZE) {
       MOZ_DIAGNOSTIC_ASSERT(aResponse.type() != ResponseType::Opaque);
-      CACHE_TRY(state->BindNullByName("response_padding_size"_ns));
+      QM_TRY(state->BindNullByName("response_padding_size"_ns));
     } else {
       MOZ_DIAGNOSTIC_ASSERT(aResponse.paddingSize() >= 0);
       MOZ_DIAGNOSTIC_ASSERT(aResponse.type() == ResponseType::Opaque);
 
-      CACHE_TRY(state->BindInt64ByName("response_padding_size"_ns,
-                                       aResponse.paddingSize()));
+      QM_TRY(state->BindInt64ByName("response_padding_size"_ns,
+                                    aResponse.paddingSize()));
     }
 
-    CACHE_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
-
-    CACHE_TRY(state->Execute());
+    QM_TRY(state->BindInt64ByName("cache_id"_ns, aCacheId));
+
+    QM_TRY(state->Execute());
   }
 
-  CACHE_TRY_INSPECT(
-      const int32_t& entryId, ([&aConn]() -> Result<int32_t, nsresult> {
-        CACHE_TRY_INSPECT(const auto& state,
-                          quota::CreateAndExecuteSingleStepStatement(
-                              aConn, "SELECT last_insert_rowid()"_ns));
-
-        CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
-      }()));
+  QM_TRY_INSPECT(const int32_t& entryId,
+                 ([&aConn]() -> Result<int32_t, nsresult> {
+                   QM_TRY_INSPECT(const auto& state,
+                                  quota::CreateAndExecuteSingleStepStatement(
+                                      aConn, "SELECT last_insert_rowid()"_ns));
+
+                   QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+                 }()));
 
   {
-    CACHE_TRY_INSPECT(
-        const auto& state,
-        MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>, aConn,
-                                   CreateStatement,
-                                   "INSERT INTO request_headers ("
-                                   "name, "
-                                   "value, "
-                                   "entry_id "
-                                   ") VALUES (:name, :value, :entry_id)"_ns));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(
+                       nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                       "INSERT INTO request_headers ("
+                       "name, "
+                       "value, "
+                       "entry_id "
+                       ") VALUES (:name, :value, :entry_id)"_ns));
 
     for (const auto& requestHeader : aRequest.headers()) {
-      CACHE_TRY(state->BindUTF8StringByName("name"_ns, requestHeader.name()));
-
-      CACHE_TRY(state->BindUTF8StringByName("value"_ns, requestHeader.value()));
-
-      CACHE_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
-
-      CACHE_TRY(state->Execute());
+      QM_TRY(state->BindUTF8StringByName("name"_ns, requestHeader.name()));
+
+      QM_TRY(state->BindUTF8StringByName("value"_ns, requestHeader.value()));
+
+      QM_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
+
+      QM_TRY(state->Execute());
     }
   }
 
   {
-    CACHE_TRY_INSPECT(
-        const auto& state,
-        MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>, aConn,
-                                   CreateStatement,
-                                   "INSERT INTO response_headers ("
-                                   "name, "
-                                   "value, "
-                                   "entry_id "
-                                   ") VALUES (:name, :value, :entry_id)"_ns));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(
+                       nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                       "INSERT INTO response_headers ("
+                       "name, "
+                       "value, "
+                       "entry_id "
+                       ") VALUES (:name, :value, :entry_id)"_ns));
 
     for (const auto& responseHeader : aResponse.headers()) {
-      CACHE_TRY(state->BindUTF8StringByName("name"_ns, responseHeader.name()));
-      CACHE_TRY(
-          state->BindUTF8StringByName("value"_ns, responseHeader.value()));
-      CACHE_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
-      CACHE_TRY(state->Execute());
+      QM_TRY(state->BindUTF8StringByName("name"_ns, responseHeader.name()));
+      QM_TRY(state->BindUTF8StringByName("value"_ns, responseHeader.value()));
+      QM_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
+      QM_TRY(state->Execute());
     }
   }
 
   {
-    CACHE_TRY_INSPECT(const auto& state, MOZ_TO_RESULT_INVOKE_TYPED(
-                                             nsCOMPtr<mozIStorageStatement>,
-                                             aConn, CreateStatement,
-                                             "INSERT INTO response_url_list ("
-                                             "url, "
-                                             "entry_id "
-                                             ") VALUES (:url, :entry_id)"_ns));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement,
+                                              "INSERT INTO response_url_list ("
+                                              "url, "
+                                              "entry_id "
+                                              ") VALUES (:url, :entry_id)"_ns));
 
     for (const auto& responseUrl : aResponse.urlList()) {
-      CACHE_TRY(state->BindUTF8StringByName("url"_ns, responseUrl));
-      CACHE_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
-      CACHE_TRY(state->Execute());
+      QM_TRY(state->BindUTF8StringByName("url"_ns, responseUrl));
+      QM_TRY(state->BindInt32ByName("entry_id"_ns, entryId));
+      QM_TRY(state->Execute());
     }
   }
 
   return NS_OK;
 }
 
 /**
  * Gets a HeadersEntry from a storage statement by retrieving the first column
  * as the name and the second column as the value.
  */
 Result<HeadersEntry, nsresult> GetHeadersEntryFromStatement(
     mozIStorageStatement& aStmt) {
   HeadersEntry header;
 
-  CACHE_TRY_UNWRAP(header.name(), MOZ_TO_RESULT_INVOKE_TYPED(nsCString, aStmt,
-                                                             GetUTF8String, 0));
-  CACHE_TRY_UNWRAP(header.value(), MOZ_TO_RESULT_INVOKE_TYPED(
-                                       nsCString, aStmt, GetUTF8String, 1));
+  QM_TRY_UNWRAP(header.name(),
+                MOZ_TO_RESULT_INVOKE_TYPED(nsCString, aStmt, GetUTF8String, 0));
+  QM_TRY_UNWRAP(header.value(),
+                MOZ_TO_RESULT_INVOKE_TYPED(nsCString, aStmt, GetUTF8String, 1));
 
   return header;
 }
 
 Result<SavedResponse, nsresult> ReadResponse(mozIStorageConnection& aConn,
                                              EntryId aEntryId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   SavedResponse savedResponse;
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    quota::CreateAndExecuteSingleStepStatement(
-                        aConn,
-                        "SELECT "
-                        "entries.response_type, "
-                        "entries.response_status, "
-                        "entries.response_status_text, "
-                        "entries.response_headers_guard, "
-                        "entries.response_body_id, "
-                        "entries.response_principal_info, "
-                        "entries.response_padding_size, "
-                        "security_info.data "
-                        "FROM entries "
-                        "LEFT OUTER JOIN security_info "
-                        "ON entries.response_security_info_id=security_info.id "
-                        "WHERE entries.id=:id;"_ns,
-                        [aEntryId](auto& state) -> Result<Ok, nsresult> {
-                          CACHE_TRY(state.BindInt32ByName("id"_ns, aEntryId));
-
-                          return Ok{};
-                        }));
-
-  CACHE_TRY_INSPECT(const int32_t& type,
-                    MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+  QM_TRY_INSPECT(const auto& state,
+                 quota::CreateAndExecuteSingleStepStatement(
+                     aConn,
+                     "SELECT "
+                     "entries.response_type, "
+                     "entries.response_status, "
+                     "entries.response_status_text, "
+                     "entries.response_headers_guard, "
+                     "entries.response_body_id, "
+                     "entries.response_principal_info, "
+                     "entries.response_padding_size, "
+                     "security_info.data "
+                     "FROM entries "
+                     "LEFT OUTER JOIN security_info "
+                     "ON entries.response_security_info_id=security_info.id "
+                     "WHERE entries.id=:id;"_ns,
+                     [aEntryId](auto& state) -> Result<Ok, nsresult> {
+                       QM_TRY(state.BindInt32ByName("id"_ns, aEntryId));
+
+                       return Ok{};
+                     }));
+
+  QM_TRY_INSPECT(const int32_t& type,
+                 MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
   savedResponse.mValue.type() = static_cast<ResponseType>(type);
 
-  CACHE_TRY_INSPECT(const int32_t& status,
-                    MOZ_TO_RESULT_INVOKE(*state, GetInt32, 1));
+  QM_TRY_INSPECT(const int32_t& status,
+                 MOZ_TO_RESULT_INVOKE(*state, GetInt32, 1));
   savedResponse.mValue.status() = static_cast<uint32_t>(status);
 
-  CACHE_TRY(state->GetUTF8String(2, savedResponse.mValue.statusText()));
-
-  CACHE_TRY_INSPECT(const int32_t& guard,
-                    MOZ_TO_RESULT_INVOKE(*state, GetInt32, 3));
+  QM_TRY(state->GetUTF8String(2, savedResponse.mValue.statusText()));
+
+  QM_TRY_INSPECT(const int32_t& guard,
+                 MOZ_TO_RESULT_INVOKE(*state, GetInt32, 3));
   savedResponse.mValue.headersGuard() = static_cast<HeadersGuardEnum>(guard);
 
-  CACHE_TRY_INSPECT(const bool& nullBody,
-                    MOZ_TO_RESULT_INVOKE(*state, GetIsNull, 4));
+  QM_TRY_INSPECT(const bool& nullBody,
+                 MOZ_TO_RESULT_INVOKE(*state, GetIsNull, 4));
   savedResponse.mHasBodyId = !nullBody;
 
   if (savedResponse.mHasBodyId) {
-    CACHE_TRY_UNWRAP(savedResponse.mBodyId, ExtractId(*state, 4));
+    QM_TRY_UNWRAP(savedResponse.mBodyId, ExtractId(*state, 4));
   }
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& serializedInfo,
       MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, *state, GetUTF8String, 5));
 
   savedResponse.mValue.principalInfo() = Nothing();
   if (!serializedInfo.IsEmpty()) {
     nsAutoCString specNoSuffix;
     OriginAttributes attrs;
     if (!attrs.PopulateFromOrigin(serializedInfo, specNoSuffix)) {
       NS_WARNING("Something went wrong parsing a serialized principal!");
       return Err(NS_ERROR_FAILURE);
     }
 
     RefPtr<net::MozURL> url;
-    CACHE_TRY(net::MozURL::Init(getter_AddRefs(url), specNoSuffix));
+    QM_TRY(net::MozURL::Init(getter_AddRefs(url), specNoSuffix));
 
 #ifdef DEBUG
     nsDependentCSubstring scheme = url->Scheme();
 
     MOZ_ASSERT(
         scheme == "http" || scheme == "https" || scheme == "file" ||
         // A cached response entry may have a moz-extension principal if:
         //
@@ -1841,177 +1829,176 @@ Result<SavedResponse, nsresult> ReadResp
         //   process to fail.
         scheme == "moz-extension");
 #endif
 
     nsCString origin;
     url->Origin(origin);
 
     nsCString baseDomain;
-    CACHE_TRY(url->BaseDomain(baseDomain));
+    QM_TRY(url->BaseDomain(baseDomain));
 
     savedResponse.mValue.principalInfo() =
         Some(mozilla::ipc::ContentPrincipalInfo(attrs, origin, specNoSuffix,
                                                 Nothing(), baseDomain));
   }
 
-  CACHE_TRY_INSPECT(const bool& nullPadding,
-                    MOZ_TO_RESULT_INVOKE(*state, GetIsNull, 6));
+  QM_TRY_INSPECT(const bool& nullPadding,
+                 MOZ_TO_RESULT_INVOKE(*state, GetIsNull, 6));
 
   if (nullPadding) {
     MOZ_DIAGNOSTIC_ASSERT(savedResponse.mValue.type() != ResponseType::Opaque);
     savedResponse.mValue.paddingSize() = InternalResponse::UNKNOWN_PADDING_SIZE;
   } else {
     MOZ_DIAGNOSTIC_ASSERT(savedResponse.mValue.type() == ResponseType::Opaque);
-    CACHE_TRY_INSPECT(const int64_t& paddingSize,
-                      MOZ_TO_RESULT_INVOKE(*state, GetInt64, 6));
+    QM_TRY_INSPECT(const int64_t& paddingSize,
+                   MOZ_TO_RESULT_INVOKE(*state, GetInt64, 6));
 
     MOZ_DIAGNOSTIC_ASSERT(paddingSize >= 0);
     savedResponse.mValue.paddingSize() = paddingSize;
   }
 
-  CACHE_TRY(state->GetBlobAsUTF8String(
+  QM_TRY(state->GetBlobAsUTF8String(
       7, savedResponse.mValue.channelInfo().securityInfo()));
 
   {
-    CACHE_TRY_INSPECT(const auto& state, MOZ_TO_RESULT_INVOKE_TYPED(
-                                             nsCOMPtr<mozIStorageStatement>,
-                                             aConn, CreateStatement,
-                                             "SELECT "
-                                             "name, "
-                                             "value "
-                                             "FROM response_headers "
-                                             "WHERE entry_id=:entry_id;"_ns));
-
-    CACHE_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
-
-    CACHE_TRY_UNWRAP(savedResponse.mValue.headers(),
-                     quota::CollectElementsWhileHasResult(
-                         *state, GetHeadersEntryFromStatement));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement,
+                                              "SELECT "
+                                              "name, "
+                                              "value "
+                                              "FROM response_headers "
+                                              "WHERE entry_id=:entry_id;"_ns));
+
+    QM_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
+
+    QM_TRY_UNWRAP(savedResponse.mValue.headers(),
+                  quota::CollectElementsWhileHasResult(
+                      *state, GetHeadersEntryFromStatement));
   }
 
   {
-    CACHE_TRY_INSPECT(const auto& state, MOZ_TO_RESULT_INVOKE_TYPED(
-                                             nsCOMPtr<mozIStorageStatement>,
-                                             aConn, CreateStatement,
-                                             "SELECT "
-                                             "url "
-                                             "FROM response_url_list "
-                                             "WHERE entry_id=:entry_id;"_ns));
-
-    CACHE_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
-
-    CACHE_TRY_UNWRAP(savedResponse.mValue.urlList(),
-                     quota::CollectElementsWhileHasResult(
-                         *state, [](auto& stmt) -> Result<nsCString, nsresult> {
-                           CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
-                               nsCString, stmt, GetUTF8String, 0));
-                         }));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement,
+                                              "SELECT "
+                                              "url "
+                                              "FROM response_url_list "
+                                              "WHERE entry_id=:entry_id;"_ns));
+
+    QM_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
+
+    QM_TRY_UNWRAP(savedResponse.mValue.urlList(),
+                  quota::CollectElementsWhileHasResult(
+                      *state, [](auto& stmt) -> Result<nsCString, nsresult> {
+                        QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE_TYPED(
+                            nsCString, stmt, GetUTF8String, 0));
+                      }));
   }
 
   return savedResponse;
 }
 
 Result<SavedRequest, nsresult> ReadRequest(mozIStorageConnection& aConn,
                                            EntryId aEntryId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   SavedRequest savedRequest;
 
-  CACHE_TRY_INSPECT(const auto& state,
-                    quota::CreateAndExecuteSingleStepStatement<
-                        quota::SingleStepResult::ReturnNullIfNoResult>(
-                        aConn,
-                        "SELECT "
-                        "request_method, "
-                        "request_url_no_query, "
-                        "request_url_query, "
-                        "request_url_fragment, "
-                        "request_referrer, "
-                        "request_referrer_policy, "
-                        "request_headers_guard, "
-                        "request_mode, "
-                        "request_credentials, "
-                        "request_contentpolicytype, "
-                        "request_cache, "
-                        "request_redirect, "
-                        "request_integrity, "
-                        "request_body_id "
-                        "FROM entries "
-                        "WHERE id=:id;"_ns,
-                        [aEntryId](auto& state) -> Result<Ok, nsresult> {
-                          CACHE_TRY(state.BindInt32ByName("id"_ns, aEntryId));
-
-                          return Ok{};
-                        }));
-
-  CACHE_TRY(OkIf(state), Err(NS_ERROR_UNEXPECTED));
-
-  CACHE_TRY(state->GetUTF8String(0, savedRequest.mValue.method()));
-  CACHE_TRY(state->GetUTF8String(1, savedRequest.mValue.urlWithoutQuery()));
-  CACHE_TRY(state->GetUTF8String(2, savedRequest.mValue.urlQuery()));
-  CACHE_TRY(state->GetUTF8String(3, savedRequest.mValue.urlFragment()));
-  CACHE_TRY(state->GetString(4, savedRequest.mValue.referrer()));
-
-  CACHE_TRY_INSPECT(const int32_t& referrerPolicy,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 5));
+  QM_TRY_INSPECT(const auto& state,
+                 quota::CreateAndExecuteSingleStepStatement<
+                     quota::SingleStepResult::ReturnNullIfNoResult>(
+                     aConn,
+                     "SELECT "
+                     "request_method, "
+                     "request_url_no_query, "
+                     "request_url_query, "
+                     "request_url_fragment, "
+                     "request_referrer, "
+                     "request_referrer_policy, "
+                     "request_headers_guard, "
+                     "request_mode, "
+                     "request_credentials, "
+                     "request_contentpolicytype, "
+                     "request_cache, "
+                     "request_redirect, "
+                     "request_integrity, "
+                     "request_body_id "
+                     "FROM entries "
+                     "WHERE id=:id;"_ns,
+                     [aEntryId](auto& state) -> Result<Ok, nsresult> {
+                       QM_TRY(state.BindInt32ByName("id"_ns, aEntryId));
+
+                       return Ok{};
+                     }));
+
+  QM_TRY(OkIf(state), Err(NS_ERROR_UNEXPECTED));
+
+  QM_TRY(state->GetUTF8String(0, savedRequest.mValue.method()));
+  QM_TRY(state->GetUTF8String(1, savedRequest.mValue.urlWithoutQuery()));
+  QM_TRY(state->GetUTF8String(2, savedRequest.mValue.urlQuery()));
+  QM_TRY(state->GetUTF8String(3, savedRequest.mValue.urlFragment()));
+  QM_TRY(state->GetString(4, savedRequest.mValue.referrer()));
+
+  QM_TRY_INSPECT(const int32_t& referrerPolicy,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 5));
   savedRequest.mValue.referrerPolicy() =
       static_cast<ReferrerPolicy>(referrerPolicy);
 
-  CACHE_TRY_INSPECT(const int32_t& guard,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 6));
+  QM_TRY_INSPECT(const int32_t& guard,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 6));
   savedRequest.mValue.headersGuard() = static_cast<HeadersGuardEnum>(guard);
 
-  CACHE_TRY_INSPECT(const int32_t& mode,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 7));
+  QM_TRY_INSPECT(const int32_t& mode, MOZ_TO_RESULT_INVOKE(state, GetInt32, 7));
   savedRequest.mValue.mode() = static_cast<RequestMode>(mode);
 
-  CACHE_TRY_INSPECT(const int32_t& credentials,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 8));
+  QM_TRY_INSPECT(const int32_t& credentials,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 8));
   savedRequest.mValue.credentials() =
       static_cast<RequestCredentials>(credentials);
 
-  CACHE_TRY_INSPECT(const int32_t& requestContentPolicyType,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 9));
+  QM_TRY_INSPECT(const int32_t& requestContentPolicyType,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 9));
   savedRequest.mValue.contentPolicyType() =
       static_cast<nsContentPolicyType>(requestContentPolicyType);
 
-  CACHE_TRY_INSPECT(const int32_t& requestCache,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 10));
+  QM_TRY_INSPECT(const int32_t& requestCache,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 10));
   savedRequest.mValue.requestCache() = static_cast<RequestCache>(requestCache);
 
-  CACHE_TRY_INSPECT(const int32_t& requestRedirect,
-                    MOZ_TO_RESULT_INVOKE(state, GetInt32, 11));
+  QM_TRY_INSPECT(const int32_t& requestRedirect,
+                 MOZ_TO_RESULT_INVOKE(state, GetInt32, 11));
   savedRequest.mValue.requestRedirect() =
       static_cast<RequestRedirect>(requestRedirect);
 
-  CACHE_TRY(state->GetString(12, savedRequest.mValue.integrity()));
-
-  CACHE_TRY_INSPECT(const bool& nullBody,
-                    MOZ_TO_RESULT_INVOKE(state, GetIsNull, 13));
+  QM_TRY(state->GetString(12, savedRequest.mValue.integrity()));
+
+  QM_TRY_INSPECT(const bool& nullBody,
+                 MOZ_TO_RESULT_INVOKE(state, GetIsNull, 13));
   savedRequest.mHasBodyId = !nullBody;
   if (savedRequest.mHasBodyId) {
-    CACHE_TRY_UNWRAP(savedRequest.mBodyId, ExtractId(*state, 13));
+    QM_TRY_UNWRAP(savedRequest.mBodyId, ExtractId(*state, 13));
   }
 
   {
-    CACHE_TRY_INSPECT(const auto& state, MOZ_TO_RESULT_INVOKE_TYPED(
-                                             nsCOMPtr<mozIStorageStatement>,
-                                             aConn, CreateStatement,
-                                             "SELECT "
-                                             "name, "
-                                             "value "
-                                             "FROM request_headers "
-                                             "WHERE entry_id=:entry_id;"_ns));
-
-    CACHE_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
-
-    CACHE_TRY_UNWRAP(savedRequest.mValue.headers(),
-                     quota::CollectElementsWhileHasResult(
-                         *state, GetHeadersEntryFromStatement));
+    QM_TRY_INSPECT(const auto& state,
+                   MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
+                                              aConn, CreateStatement,
+                                              "SELECT "
+                                              "name, "
+                                              "value "
+                                              "FROM request_headers "
+                                              "WHERE entry_id=:entry_id;"_ns));
+
+    QM_TRY(state->BindInt32ByName("entry_id"_ns, aEntryId));
+
+    QM_TRY_UNWRAP(savedRequest.mValue.headers(),
+                  quota::CollectElementsWhileHasResult(
+                      *state, GetHeadersEntryFromStatement));
   }
 
   return savedRequest;
 }
 
 void AppendListParamsToQuery(nsACString& aQuery,
                              const nsTArray<EntryId>& aEntryIdList,
                              uint32_t aPos, int32_t aLen) {
@@ -2029,46 +2016,46 @@ void AppendListParamsToQuery(nsACString&
 }
 
 nsresult BindListParamsToQuery(mozIStorageStatement& aState,
                                const nsTArray<EntryId>& aEntryIdList,
                                uint32_t aPos, int32_t aLen) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT((aPos + aLen) <= aEntryIdList.Length());
   for (int32_t i = aPos; i < aLen; ++i) {
-    CACHE_TRY(aState.BindInt32ByIndex(i, aEntryIdList[i]));
+    QM_TRY(aState.BindInt32ByIndex(i, aEntryIdList[i]));
   }
   return NS_OK;
 }
 
 nsresult BindId(mozIStorageStatement& aState, const nsACString& aName,
                 const nsID* aId) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   if (!aId) {
-    CACHE_TRY(aState.BindNullByName(aName));
+    QM_TRY(aState.BindNullByName(aName));
     return NS_OK;
   }
 
   char idBuf[NSID_LENGTH];
   aId->ToProvidedString(idBuf);
-  CACHE_TRY(aState.BindUTF8StringByName(aName, nsDependentCString(idBuf)));
+  QM_TRY(aState.BindUTF8StringByName(aName, nsDependentCString(idBuf)));
 
   return NS_OK;
 }
 
 Result<nsID, nsresult> ExtractId(mozIStorageStatement& aState, uint32_t aPos) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& idString,
       MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, aState, GetUTF8String, aPos));
 
   nsID id;
-  CACHE_TRY(OkIf(id.Parse(idString.get())), Err(NS_ERROR_UNEXPECTED));
+  QM_TRY(OkIf(id.Parse(idString.get())), Err(NS_ERROR_UNEXPECTED));
 
   return id;
 }
 
 Result<NotNull<nsCOMPtr<mozIStorageStatement>>, nsresult>
 CreateAndBindKeyStatement(mozIStorageConnection& aConn,
                           const char* const aQueryFormat,
                           const nsAString& aKey) {
@@ -2076,54 +2063,53 @@ CreateAndBindKeyStatement(mozIStorageCon
 
   // The key is stored as a blob to avoid encoding issues.  An empty string
   // is mapped to NULL for blobs.  Normally we would just write the query
   // as "key IS :key" to do the proper NULL checking, but that prevents
   // sqlite from using the key index.  Therefore use "IS NULL" explicitly
   // if the key is empty, otherwise use "=:key" so that sqlite uses the
   // index.
 
-  CACHE_TRY_UNWRAP(
+  QM_TRY_UNWRAP(
       auto state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           nsPrintfCString(aQueryFormat,
                           aKey.IsEmpty() ? "key IS NULL" : "key=:key")));
 
   if (!aKey.IsEmpty()) {
-    CACHE_TRY(state->BindStringAsBlobByName("key"_ns, aKey));
+    QM_TRY(state->BindStringAsBlobByName("key"_ns, aKey));
   }
 
   return WrapNotNull(std::move(state));
 }
 
 Result<nsAutoCString, nsresult> HashCString(nsICryptoHash& aCrypto,
                                             const nsACString& aIn) {
-  CACHE_TRY(aCrypto.Init(nsICryptoHash::SHA1));
-
-  CACHE_TRY(aCrypto.Update(reinterpret_cast<const uint8_t*>(aIn.BeginReading()),
-                           aIn.Length()));
+  QM_TRY(aCrypto.Init(nsICryptoHash::SHA1));
+
+  QM_TRY(aCrypto.Update(reinterpret_cast<const uint8_t*>(aIn.BeginReading()),
+                        aIn.Length()));
 
   nsAutoCString fullHash;
-  CACHE_TRY(aCrypto.Finish(false /* based64 result */, fullHash));
+  QM_TRY(aCrypto.Finish(false /* based64 result */, fullHash));
 
   return Result<nsAutoCString, nsresult>{std::in_place,
                                          Substring(fullHash, 0, 8)};
 }
 
 }  // namespace
 
 nsresult IncrementalVacuum(mozIStorageConnection& aConn) {
   // Determine how much free space is in the database.
-  CACHE_TRY_INSPECT(const auto& state,
-                    quota::CreateAndExecuteSingleStepStatement(
-                        aConn, "PRAGMA freelist_count;"_ns));
-
-  CACHE_TRY_INSPECT(const int32_t& freePages,
-                    MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+  QM_TRY_INSPECT(const auto& state, quota::CreateAndExecuteSingleStepStatement(
+                                        aConn, "PRAGMA freelist_count;"_ns));
+
+  QM_TRY_INSPECT(const int32_t& freePages,
+                 MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
 
   // We have a relatively small page size, so we want to be careful to avoid
   // fragmentation.  We already use a growth incremental which will cause
   // sqlite to allocate and release multiple pages at the same time.  We can
   // further reduce fragmentation by making our allocated chunks a bit
   // "sticky".  This is done by creating some hysteresis where we allocate
   // pages/chunks as soon as we need them, but we only release pages/chunks
   // when we have a large amount of free space.  This helps with the case
@@ -2135,61 +2121,61 @@ nsresult IncrementalVacuum(mozIStorageCo
   if (freePages <= kMaxFreePages) {
     return NS_OK;
   }
 
   // Release the excess pages back to the sqlite VFS.  This may also release
   // chunks of multiple pages back to the OS.
   const int32_t pagesToRelease = freePages - kMaxFreePages;
 
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       nsPrintfCString("PRAGMA incremental_vacuum(%d);", pagesToRelease)));
 
   // Verify that our incremental vacuum actually did something
 #ifdef DEBUG
   {
-    CACHE_TRY_INSPECT(const auto& state,
-                      quota::CreateAndExecuteSingleStepStatement(
-                          aConn, "PRAGMA freelist_count;"_ns));
-
-    CACHE_TRY_INSPECT(const int32_t& freePages,
-                      MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
+    QM_TRY_INSPECT(const auto& state,
+                   quota::CreateAndExecuteSingleStepStatement(
+                       aConn, "PRAGMA freelist_count;"_ns));
+
+    QM_TRY_INSPECT(const int32_t& freePages,
+                   MOZ_TO_RESULT_INVOKE(*state, GetInt32, 0));
 
     MOZ_ASSERT(freePages <= kMaxFreePages);
   }
 #endif
 
   return NS_OK;
 }
 
 namespace {
 
 // Wrapper around mozIStorageConnection::GetSchemaVersion() that compensates
 // for hacky downgrade schema version tricks.  See the block comments for
 // kHackyDowngradeSchemaVersion and kHackyPaddingSizePresentVersion.
 Result<int32_t, nsresult> GetEffectiveSchemaVersion(
     mozIStorageConnection& aConn) {
-  CACHE_TRY_INSPECT(const int32_t& schemaVersion,
-                    MOZ_TO_RESULT_INVOKE(aConn, GetSchemaVersion));
+  QM_TRY_INSPECT(const int32_t& schemaVersion,
+                 MOZ_TO_RESULT_INVOKE(aConn, GetSchemaVersion));
 
   if (schemaVersion == kHackyDowngradeSchemaVersion) {
     // This is the special case.  Check for the existence of the
     // "response_padding_size" colum in table "entries".
     //
     // (pragma_table_info is a table-valued function format variant of
     // "PRAGMA table_info" supported since SQLite 3.16.0.  Firefox 53 shipped
     // was the first release with this functionality, shipping 3.16.2.)
     //
     // If there are any result rows, then the column is present.
-    CACHE_TRY_INSPECT(const bool& hasColumn,
-                      quota::CreateAndExecuteSingleStepStatement<
-                          quota::SingleStepResult::ReturnNullIfNoResult>(
-                          aConn,
-                          "SELECT name FROM pragma_table_info('entries') WHERE "
-                          "name = 'response_padding_size'"_ns));
+    QM_TRY_INSPECT(const bool& hasColumn,
+                   quota::CreateAndExecuteSingleStepStatement<
+                       quota::SingleStepResult::ReturnNullIfNoResult>(
+                       aConn,
+                       "SELECT name FROM pragma_table_info('entries') WHERE "
+                       "name = 'response_padding_size'"_ns));
 
     if (hasColumn) {
       return kHackyPaddingSizePresentVersion;
     }
   }
 
   return schemaVersion;
 }
@@ -2207,19 +2193,19 @@ struct Expect {
   const nsCString mName;
   const nsCString mType;
   const nsCString mSql;
   const bool mIgnoreSql;
 };
 #endif
 
 nsresult Validate(mozIStorageConnection& aConn) {
-  CACHE_TRY_INSPECT(const int32_t& schemaVersion,
-                    GetEffectiveSchemaVersion(aConn));
-  CACHE_TRY(OkIf(schemaVersion == kLatestSchemaVersion), NS_ERROR_FAILURE);
+  QM_TRY_INSPECT(const int32_t& schemaVersion,
+                 GetEffectiveSchemaVersion(aConn));
+  QM_TRY(OkIf(schemaVersion == kLatestSchemaVersion), NS_ERROR_FAILURE);
 
 #ifdef DEBUG
   // This is the schema we expect the database at the latest version to
   // contain.  Update this list if you add a new table or index.
   const Expect expects[] = {
       Expect("caches", "table", kTableCaches),
       Expect("sqlite_sequence", "table"),  // auto-gen by sqlite
       Expect("security_info", "table", kTableSecurityInfo),
@@ -2230,30 +2216,30 @@ nsresult Validate(mozIStorageConnection&
       Expect("response_headers", "table", kTableResponseHeaders),
       Expect("response_headers_name_index", "index", kIndexResponseHeadersName),
       Expect("response_url_list", "table", kTableResponseUrlList),
       Expect("storage", "table", kTableStorage),
       Expect("sqlite_autoindex_storage_1", "index"),  // auto-gen by sqlite
   };
 
   // Read the schema from the sqlite_master table and compare.
-  CACHE_TRY_INSPECT(const auto& state,
-                    MOZ_TO_RESULT_INVOKE_TYPED(
-                        nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
-                        "SELECT name, type, sql FROM sqlite_master;"_ns));
-
-  CACHE_TRY(quota::CollectWhileHasResult(
+  QM_TRY_INSPECT(const auto& state,
+                 MOZ_TO_RESULT_INVOKE_TYPED(
+                     nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
+                     "SELECT name, type, sql FROM sqlite_master;"_ns));
+
+  QM_TRY(quota::CollectWhileHasResult(
       *state, [&expects](auto& stmt) -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& name,
             MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, stmt, GetUTF8String, 0));
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& type,
             MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, stmt, GetUTF8String, 1));
-        CACHE_TRY_INSPECT(
+        QM_TRY_INSPECT(
             const auto& sql,
             MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, stmt, GetUTF8String, 2));
 
         bool foundMatch = false;
         for (const auto& expect : expects) {
           if (name == expect.mName) {
             if (type != expect.mType) {
               NS_WARNING(
@@ -2323,61 +2309,61 @@ constexpr Migration sMigrationList[] = {
     Migration{19, MigrateFrom19To20}, Migration{20, MigrateFrom20To21},
     Migration{21, MigrateFrom21To22}, Migration{22, MigrateFrom22To23},
     Migration{23, MigrateFrom23To24}, Migration{24, MigrateFrom24To25},
     Migration{25, MigrateFrom25To26}, Migration{26, MigrateFrom26To27},
     Migration{27, MigrateFrom27To28},
 };
 
 nsresult RewriteEntriesSchema(mozIStorageConnection& aConn) {
-  CACHE_TRY(aConn.ExecuteSimpleSQL("PRAGMA writable_schema = ON"_ns));
-
-  CACHE_TRY_INSPECT(
+  QM_TRY(aConn.ExecuteSimpleSQL("PRAGMA writable_schema = ON"_ns));
+
+  QM_TRY_INSPECT(
       const auto& state,
       MOZ_TO_RESULT_INVOKE_TYPED(
           nsCOMPtr<mozIStorageStatement>, aConn, CreateStatement,
           "UPDATE sqlite_master SET sql=:sql WHERE name='entries'"_ns));
 
-  CACHE_TRY(
+  QM_TRY(
       state->BindUTF8StringByName("sql"_ns, nsDependentCString(kTableEntries)));
-  CACHE_TRY(state->Execute());
-
-  CACHE_TRY(aConn.ExecuteSimpleSQL("PRAGMA writable_schema = OFF"_ns));
+  QM_TRY(state->Execute());
+
+  QM_TRY(aConn.ExecuteSimpleSQL("PRAGMA writable_schema = OFF"_ns));
 
   return NS_OK;
 }
 
 nsresult Migrate(mozIStorageConnection& aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY_UNWRAP(int32_t currentVersion, GetEffectiveSchemaVersion(aConn));
+  QM_TRY_UNWRAP(int32_t currentVersion, GetEffectiveSchemaVersion(aConn));
 
   bool rewriteSchema = false;
 
   while (currentVersion < kLatestSchemaVersion) {
     // Wiping old databases is handled in DBAction because it requires
     // making a whole new mozIStorageConnection.  Make sure we don't
     // accidentally get here for one of those old databases.
     MOZ_DIAGNOSTIC_ASSERT(currentVersion >= kFirstShippedSchemaVersion);
 
     for (const auto& migration : sMigrationList) {
       if (migration.mFromVersion == currentVersion) {
         bool shouldRewrite = false;
-        CACHE_TRY(migration.mFunc(aConn, shouldRewrite));
+        QM_TRY(migration.mFunc(aConn, shouldRewrite));
         if (shouldRewrite) {
           rewriteSchema = true;
         }
         break;
       }
     }
 
 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
     int32_t lastVersion = currentVersion;
 #endif
-    CACHE_TRY_UNWRAP(currentVersion, GetEffectiveSchemaVersion(aConn));
+    QM_TRY_UNWRAP(currentVersion, GetEffectiveSchemaVersion(aConn));
 
     MOZ_DIAGNOSTIC_ASSERT(currentVersion > lastVersion);
   }
 
   // Don't release assert this since people do sometimes share profiles
   // across schema versions.  Our check in Validate() will catch it.
   MOZ_ASSERT(currentVersion == kLatestSchemaVersion);
 
@@ -2395,21 +2381,21 @@ nsresult Migrate(mozIStorageConnection& 
 nsresult MigrateFrom15To16(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Add the request_redirect column with a default value of "follow".  Note,
   // we only use a default value here because its required by ALTER TABLE and
   // we need to apply the default "follow" to existing records in the table.
   // We don't actually want to keep the default in the schema for future
   // INSERTs.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "ALTER TABLE entries "
       "ADD COLUMN request_redirect INTEGER NOT NULL DEFAULT 0"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(16));
+  QM_TRY(aConn.SetSchemaVersion(16));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom16To17(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
@@ -2417,17 +2403,17 @@ nsresult MigrateFrom16To17(mozIStorageCo
   // This migration path removes the response_redirected and
   // response_redirected_url columns from the entries table.  sqlite doesn't
   // support removing a column from a table using ALTER TABLE, so we need to
   // create a new table without those columns, fill it up with the existing
   // data, and then drop the original table and rename the new one to the old
   // one.
 
   // Create a new_entries table with the new fields as of version 17.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "CREATE TABLE new_entries ("
       "id INTEGER NOT NULL PRIMARY KEY, "
       "request_method TEXT NOT NULL, "
       "request_url_no_query TEXT NOT NULL, "
       "request_url_no_query_hash BLOB NOT NULL, "
       "request_url_query TEXT NOT NULL, "
       "request_url_query_hash BLOB NOT NULL, "
       "request_referrer TEXT NOT NULL, "
@@ -2445,17 +2431,17 @@ nsresult MigrateFrom16To17(mozIStorageCo
       "response_body_id TEXT NULL, "
       "response_security_info_id INTEGER NULL REFERENCES security_info(id), "
       "response_principal_info TEXT NOT NULL, "
       "cache_id INTEGER NOT NULL REFERENCES caches(id) ON DELETE CASCADE, "
       "request_redirect INTEGER NOT NULL"
       ")"_ns));
 
   // Copy all of the data to the newly created table.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("INSERT INTO new_entries ("
                              "id, "
                              "request_method, "
                              "request_url_no_query, "
                              "request_url_no_query_hash, "
                              "request_url_query, "
                              "request_url_query_hash, "
                              "request_referrer, "
@@ -2497,56 +2483,56 @@ nsresult MigrateFrom16To17(mozIStorageCo
                              "response_headers_guard, "
                              "response_body_id, "
                              "response_security_info_id, "
                              "response_principal_info, "
                              "cache_id "
                              "FROM entries;"_ns));
 
   // Remove the old table.
-  CACHE_TRY(aConn.ExecuteSimpleSQL("DROP TABLE entries;"_ns));
+  QM_TRY(aConn.ExecuteSimpleSQL("DROP TABLE entries;"_ns));
 
   // Rename new_entries to entries.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("ALTER TABLE new_entries RENAME to entries;"_ns));
 
   // Now, recreate our indices.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(nsDependentCString(kIndexEntriesRequest)));
+  QM_TRY(aConn.ExecuteSimpleSQL(nsDependentCString(kIndexEntriesRequest)));
 
   // Revalidate the foreign key constraints, and ensure that there are no
   // violations.
-  CACHE_TRY_INSPECT(const bool& hasResult,
-                    quota::CreateAndExecuteSingleStepStatement<
-                        quota::SingleStepResult::ReturnNullIfNoResult>(
-                        aConn, "PRAGMA foreign_key_check;"_ns));
-
-  CACHE_TRY(OkIf(!hasResult), NS_ERROR_FAILURE);
-
-  CACHE_TRY(aConn.SetSchemaVersion(17));
+  QM_TRY_INSPECT(const bool& hasResult,
+                 quota::CreateAndExecuteSingleStepStatement<
+                     quota::SingleStepResult::ReturnNullIfNoResult>(
+                     aConn, "PRAGMA foreign_key_check;"_ns));
+
+  QM_TRY(OkIf(!hasResult), NS_ERROR_FAILURE);
+
+  QM_TRY(aConn.SetSchemaVersion(17));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom17To18(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // This migration is needed in order to remove "only-if-cached" RequestCache
   // values from the database.  This enum value was removed from the spec in
   // https://github.com/whatwg/fetch/issues/39 but we unfortunately happily
   // accepted this value in the Request constructor.
   //
   // There is no good value to upgrade this to, so we just stick to "default".
 
   static_assert(int(RequestCache::Default) == 0,
                 "This is where the 0 below comes from!");
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("UPDATE entries SET request_cache = 0 "
                              "WHERE request_cache = 5;"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(18));
+  QM_TRY(aConn.SetSchemaVersion(18));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom18To19(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // This migration is needed in order to update the RequestMode values for
@@ -2556,38 +2542,38 @@ nsresult MigrateFrom18To19(mozIStorageCo
   static_assert(int(nsIContentPolicy::TYPE_DOCUMENT) == 6 &&
                     int(nsIContentPolicy::TYPE_SUBDOCUMENT) == 7 &&
                     int(nsIContentPolicy::TYPE_INTERNAL_FRAME) == 28 &&
                     int(nsIContentPolicy::TYPE_INTERNAL_IFRAME) == 29 &&
                     int(RequestMode::Navigate) == 3,
                 "This is where the numbers below come from!");
   // 8 is former TYPE_REFRESH.
 
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "UPDATE entries SET request_mode = 3 "
       "WHERE request_contentpolicytype IN (6, 7, 28, 29, 8);"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(19));
+  QM_TRY(aConn.SetSchemaVersion(19));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom19To20(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Add the request_referrer_policy column with a default value of
   // "no-referrer-when-downgrade".  Note, we only use a default value here
   // because its required by ALTER TABLE and we need to apply the default
   // "no-referrer-when-downgrade" to existing records in the table. We don't
   // actually want to keep the default in the schema for future INSERTs.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "ALTER TABLE entries "
       "ADD COLUMN request_referrer_policy INTEGER NOT NULL DEFAULT 2"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(20));
+  QM_TRY(aConn.SetSchemaVersion(20));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom20To21(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
@@ -2595,17 +2581,17 @@ nsresult MigrateFrom20To21(mozIStorageCo
   // This migration creates response_url_list table to store response_url and
   // removes the response_url column from the entries table.
   // sqlite doesn't support removing a column from a table using ALTER TABLE,
   // so we need to create a new table without those columns, fill it up with the
   // existing data, and then drop the original table and rename the new one to
   // the old one.
 
   // Create a new_entries table with the new fields as of version 21.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "CREATE TABLE new_entries ("
       "id INTEGER NOT NULL PRIMARY KEY, "
       "request_method TEXT NOT NULL, "
       "request_url_no_query TEXT NOT NULL, "
       "request_url_no_query_hash BLOB NOT NULL, "
       "request_url_query TEXT NOT NULL, "
       "request_url_query_hash BLOB NOT NULL, "
       "request_referrer TEXT NOT NULL, "
@@ -2623,24 +2609,24 @@ nsresult MigrateFrom20To21(mozIStorageCo
       "response_security_info_id INTEGER NULL REFERENCES security_info(id), "
       "response_principal_info TEXT NOT NULL, "
       "cache_id INTEGER NOT NULL REFERENCES caches(id) ON DELETE CASCADE, "
       "request_redirect INTEGER NOT NULL, "
       "request_referrer_policy INTEGER NOT NULL"
       ")"_ns));
 
   // Create a response_url_list table with the new fields as of version 21.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "CREATE TABLE response_url_list ("
       "url TEXT NOT NULL, "
       "entry_id INTEGER NOT NULL REFERENCES entries(id) ON DELETE CASCADE"
       ")"_ns));
 
   // Copy all of the data to the newly created entries table.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("INSERT INTO new_entries ("
                              "id, "
                              "request_method, "
                              "request_url_no_query, "
                              "request_url_no_query_hash, "
                              "request_url_query, "
                              "request_url_query_hash, "
                              "request_referrer, "
@@ -2682,142 +2668,142 @@ nsresult MigrateFrom20To21(mozIStorageCo
                              "response_headers_guard, "
                              "response_body_id, "
                              "response_security_info_id, "
                              "response_principal_info, "
                              "cache_id "
                              "FROM entries;"_ns));
 
   // Copy reponse_url to the newly created response_url_list table.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("INSERT INTO response_url_list ("
                              "url, "
                              "entry_id "
                              ") SELECT "
                              "response_url, "
                              "id "
                              "FROM entries;"_ns));
 
   // Remove the old table.
-  CACHE_TRY(aConn.ExecuteSimpleSQL("DROP TABLE entries;"_ns));
+  QM_TRY(aConn.ExecuteSimpleSQL("DROP TABLE entries;"_ns));
 
   // Rename new_entries to entries.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("ALTER TABLE new_entries RENAME to entries;"_ns));
 
   // Now, recreate our indices.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexEntriesRequest)));
+  QM_TRY(aConn.ExecuteSimpleSQL(nsLiteralCString(kIndexEntriesRequest)));
 
   // Revalidate the foreign key constraints, and ensure that there are no
   // violations.
-  CACHE_TRY_INSPECT(const bool& hasResult,
-                    quota::CreateAndExecuteSingleStepStatement<
-                        quota::SingleStepResult::ReturnNullIfNoResult>(
-                        aConn, "PRAGMA foreign_key_check;"_ns));
-
-  CACHE_TRY(OkIf(!hasResult), NS_ERROR_FAILURE);
-
-  CACHE_TRY(aConn.SetSchemaVersion(21));
+  QM_TRY_INSPECT(const bool& hasResult,
+                 quota::CreateAndExecuteSingleStepStatement<
+                     quota::SingleStepResult::ReturnNullIfNoResult>(
+                     aConn, "PRAGMA foreign_key_check;"_ns));
+
+  QM_TRY(OkIf(!hasResult), NS_ERROR_FAILURE);
+
+  QM_TRY(aConn.SetSchemaVersion(21));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom21To22(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Add the request_integrity column.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "ALTER TABLE entries "
       "ADD COLUMN request_integrity TEXT NOT NULL DEFAULT '';"_ns));
 
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("UPDATE entries SET request_integrity = '';"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(22));
+  QM_TRY(aConn.SetSchemaVersion(22));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom22To23(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // The only change between 22 and 23 was a different snappy compression
   // format, but it's backwards-compatible.
-  CACHE_TRY(aConn.SetSchemaVersion(23));
+  QM_TRY(aConn.SetSchemaVersion(23));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom23To24(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Add the request_url_fragment column.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "ALTER TABLE entries "
       "ADD COLUMN request_url_fragment TEXT NOT NULL DEFAULT ''"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(24));
+  QM_TRY(aConn.SetSchemaVersion(24));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom24To25(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // The only change between 24 and 25 was a new nsIContentPolicy type.
-  CACHE_TRY(aConn.SetSchemaVersion(25));
+  QM_TRY(aConn.SetSchemaVersion(25));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom25To26(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // Add the response_padding_size column.
   // Note: only opaque repsonse should be non-null interger.
-  CACHE_TRY(aConn.ExecuteSimpleSQL(
+  QM_TRY(aConn.ExecuteSimpleSQL(
       "ALTER TABLE entries "
       "ADD COLUMN response_padding_size INTEGER NULL "_ns));
 
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("UPDATE entries SET response_padding_size = 0 "
                              "WHERE response_type = 4"_ns  // opaque response
                              ));
 
-  CACHE_TRY(aConn.SetSchemaVersion(26));
+  QM_TRY(aConn.SetSchemaVersion(26));
 
   aRewriteSchema = true;
 
   return NS_OK;
 }
 
 nsresult MigrateFrom26To27(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  CACHE_TRY(aConn.SetSchemaVersion(kHackyDowngradeSchemaVersion));
+  QM_TRY(aConn.SetSchemaVersion(kHackyDowngradeSchemaVersion));
 
   return NS_OK;
 }
 
 nsresult MigrateFrom27To28(mozIStorageConnection& aConn, bool& aRewriteSchema) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   // In Bug 1264178, we added a column request_integrity into table entries.
   // However, at that time, the default value for the existing rows is NULL
   // which against the statement in kTableEntries. Thus, we need to have another
   // upgrade to update these values to an empty string.
-  CACHE_TRY(
+  QM_TRY(
       aConn.ExecuteSimpleSQL("UPDATE entries SET request_integrity = '' "
                              "WHERE request_integrity is NULL;"_ns));
 
-  CACHE_TRY(aConn.SetSchemaVersion(28));
+  QM_TRY(aConn.SetSchemaVersion(28));
 
   return NS_OK;
 }
 
 }  // anonymous namespace
 }  // namespace mozilla::dom::cache::db
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -75,150 +75,149 @@ Result<SuccessType, nsresult> MapNotFoun
 Result<Ok, nsresult> MapAlreadyExistsToDefault(const nsresult aRv) {
   return (aRv == NS_ERROR_FILE_ALREADY_EXISTS)
              ? Result<Ok, nsresult>{std::in_place}
              : Err(aRv);
 }
 
 Result<NotNull<nsCOMPtr<nsIFile>>, nsresult> BodyGetCacheDir(nsIFile& aBaseDir,
                                                              const nsID& aId) {
-  CACHE_TRY_UNWRAP(auto cacheDir,
-                   CloneFileAndAppend(aBaseDir, kMorgueDirectory));
+  QM_TRY_UNWRAP(auto cacheDir, CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
   // Some file systems have poor performance when there are too many files
   // in a single directory.  Mitigate this issue by spreading the body
   // files out into sub-directories.  We use the last byte of the ID for
   // the name of the sub-directory.
-  CACHE_TRY(cacheDir->Append(IntToString(aId.m3[7])));
+  QM_TRY(cacheDir->Append(IntToString(aId.m3[7])));
 
   // Callers call this function without checking if the directory already
   // exists (idempotent usage). QM_OR_ELSE_WARN is not used here since we want
   // to ignore NS_ERROR_FILE_ALREADY_EXISTS completely.
   QM_TRY(ToResult(cacheDir->Create(nsIFile::DIRECTORY_TYPE, 0755))
              .orElse(ErrToDefaultOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS>));
 
   return WrapNotNullUnchecked(std::move(cacheDir));
 }
 
 }  // namespace
 
 nsresult BodyCreateDir(nsIFile& aBaseDir) {
-  CACHE_TRY_INSPECT(const auto& bodyDir,
-                    CloneFileAndAppend(aBaseDir, kMorgueDirectory));
+  QM_TRY_INSPECT(const auto& bodyDir,
+                 CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
   // Callers call this function without checking if the directory already
   // exists (idempotent usage). QM_OR_ELSE_WARN is not used here since we want
   // to ignore NS_ERROR_FILE_ALREADY_EXISTS completely.
   QM_TRY(ToResult(bodyDir->Create(nsIFile::DIRECTORY_TYPE, 0755))
              .orElse(ErrToDefaultOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS>));
 
   return NS_OK;
 }
 
 nsresult BodyDeleteDir(const QuotaInfo& aQuotaInfo, nsIFile& aBaseDir) {
-  CACHE_TRY_INSPECT(const auto& bodyDir,
-                    CloneFileAndAppend(aBaseDir, kMorgueDirectory));
+  QM_TRY_INSPECT(const auto& bodyDir,
+                 CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
-  CACHE_TRY(RemoveNsIFileRecursively(aQuotaInfo, *bodyDir));
+  QM_TRY(RemoveNsIFileRecursively(aQuotaInfo, *bodyDir));
 
   return NS_OK;
 }
 
 Result<std::pair<nsID, nsCOMPtr<nsISupports>>, nsresult> BodyStartWriteStream(
     const QuotaInfo& aQuotaInfo, nsIFile& aBaseDir, nsIInputStream& aSource,
     void* aClosure, nsAsyncCopyCallbackFun aCallback) {
   MOZ_DIAGNOSTIC_ASSERT(aClosure);
   MOZ_DIAGNOSTIC_ASSERT(aCallback);
 
-  CACHE_TRY_INSPECT(const auto& idGen, ToResultGet<nsCOMPtr<nsIUUIDGenerator>>(
-                                           MOZ_SELECT_OVERLOAD(do_GetService),
-                                           "@mozilla.org/uuid-generator;1"));
+  QM_TRY_INSPECT(const auto& idGen, ToResultGet<nsCOMPtr<nsIUUIDGenerator>>(
+                                        MOZ_SELECT_OVERLOAD(do_GetService),
+                                        "@mozilla.org/uuid-generator;1"));
 
   nsID id;
-  CACHE_TRY(idGen->GenerateUUIDInPlace(&id));
+  QM_TRY(idGen->GenerateUUIDInPlace(&id));
 
-  CACHE_TRY_INSPECT(const auto& finalFile,
-                    BodyIdToFile(aBaseDir, id, BODY_FILE_FINAL));
+  QM_TRY_INSPECT(const auto& finalFile,
+                 BodyIdToFile(aBaseDir, id, BODY_FILE_FINAL));
 
   {
-    CACHE_TRY_INSPECT(const bool& exists,
-                      MOZ_TO_RESULT_INVOKE(*finalFile, Exists));
+    QM_TRY_INSPECT(const bool& exists,
+                   MOZ_TO_RESULT_INVOKE(*finalFile, Exists));
 
-    CACHE_TRY(OkIf(!exists), Err(NS_ERROR_FILE_ALREADY_EXISTS));
+    QM_TRY(OkIf(!exists), Err(NS_ERROR_FILE_ALREADY_EXISTS));
   }
 
-  CACHE_TRY_INSPECT(const auto& tmpFile,
-                    BodyIdToFile(aBaseDir, id, BODY_FILE_TMP));
+  QM_TRY_INSPECT(const auto& tmpFile,
+                 BodyIdToFile(aBaseDir, id, BODY_FILE_TMP));
 
-  CACHE_TRY_INSPECT(const auto& fileStream,
-                    CreateFileOutputStream(PERSISTENCE_TYPE_DEFAULT, aQuotaInfo,
-                                           Client::DOMCACHE, tmpFile.get()));
+  QM_TRY_INSPECT(const auto& fileStream,
+                 CreateFileOutputStream(PERSISTENCE_TYPE_DEFAULT, aQuotaInfo,
+                                        Client::DOMCACHE, tmpFile.get()));
 
   const auto compressed =
       MakeRefPtr<SnappyCompressOutputStream>(fileStream.get());
 
   const nsCOMPtr<nsIEventTarget> target =
       do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
 
   nsCOMPtr<nsISupports> copyContext;
-  CACHE_TRY(NS_AsyncCopy(&aSource, compressed, target,
-                         NS_ASYNCCOPY_VIA_WRITESEGMENTS,
-                         compressed->BlockSize(), aCallback, aClosure, true,
-                         true,  // close streams
-                         getter_AddRefs(copyContext)));
+  QM_TRY(NS_AsyncCopy(&aSource, compressed, target,
+                      NS_ASYNCCOPY_VIA_WRITESEGMENTS, compressed->BlockSize(),
+                      aCallback, aClosure, true,
+                      true,  // close streams
+                      getter_AddRefs(copyContext)));
 
   return std::make_pair(id, std::move(copyContext));
 }
 
 void BodyCancelWrite(nsISupports& aCopyContext) {
   QM_WARNONLY_TRY(NS_CancelAsyncCopy(&aCopyContext, NS_ERROR_ABORT));
 
   // TODO The partially written file must be cleaned up after the async copy
   // makes its callback.
 }
 
 nsresult BodyFinalizeWrite(nsIFile& aBaseDir, const nsID& aId) {
-  CACHE_TRY_INSPECT(const auto& tmpFile,
-                    BodyIdToFile(aBaseDir, aId, BODY_FILE_TMP));
+  QM_TRY_INSPECT(const auto& tmpFile,
+                 BodyIdToFile(aBaseDir, aId, BODY_FILE_TMP));
 
-  CACHE_TRY_INSPECT(const auto& finalFile,
-                    BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL));
+  QM_TRY_INSPECT(const auto& finalFile,
+                 BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL));
 
   nsAutoString finalFileName;
-  CACHE_TRY(finalFile->GetLeafName(finalFileName));
+  QM_TRY(finalFile->GetLeafName(finalFileName));
 
   // It's fine to not notify the QuotaManager that the path has been changed,
   // because its path will be updated and its size will be recalculated when
   // opening file next time.
-  CACHE_TRY(tmpFile->RenameTo(nullptr, finalFileName));
+  QM_TRY(tmpFile->RenameTo(nullptr, finalFileName));
 
   return NS_OK;
 }
 
 Result<NotNull<nsCOMPtr<nsIInputStream>>, nsresult> BodyOpen(
     const QuotaInfo& aQuotaInfo, nsIFile& aBaseDir, const nsID& aId) {
-  CACHE_TRY_INSPECT(const auto& finalFile,
-                    BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL));
+  QM_TRY_INSPECT(const auto& finalFile,
+                 BodyIdToFile(aBaseDir, aId, BODY_FILE_FINAL));
 
-  CACHE_TRY_RETURN(CreateFileInputStream(PERSISTENCE_TYPE_DEFAULT, aQuotaInfo,
-                                         Client::DOMCACHE, finalFile.get())
-                       .map([](NotNull<RefPtr<FileInputStream>>&& stream) {
-                         return WrapNotNullUnchecked(
-                             nsCOMPtr<nsIInputStream>{stream.get()});
-                       }));
+  QM_TRY_RETURN(CreateFileInputStream(PERSISTENCE_TYPE_DEFAULT, aQuotaInfo,
+                                      Client::DOMCACHE, finalFile.get())
+                    .map([](NotNull<RefPtr<FileInputStream>>&& stream) {
+                      return WrapNotNullUnchecked(
+                          nsCOMPtr<nsIInputStream>{stream.get()});
+                    }));
 }
 
 nsresult BodyMaybeUpdatePaddingSize(const QuotaInfo& aQuotaInfo,
                                     nsIFile& aBaseDir, const nsID& aId,
                                     const uint32_t aPaddingInfo,
                                     int64_t* aPaddingSizeInOut) {
   MOZ_DIAGNOSTIC_ASSERT(aPaddingSizeInOut);
 
-  CACHE_TRY_INSPECT(const auto& bodyFile,
-                    BodyIdToFile(aBaseDir, aId, BODY_FILE_TMP));
+  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, aQuotaInfo, Client::DOMCACHE, bodyFile.get(),
       -1, &fileSize);
@@ -240,64 +239,64 @@ nsresult BodyMaybeUpdatePaddingSize(cons
   }
 
   return NS_OK;
 }
 
 nsresult BodyDeleteFiles(const QuotaInfo& aQuotaInfo, nsIFile& aBaseDir,
                          const nsTArray<nsID>& aIdList) {
   for (const auto id : aIdList) {
-    CACHE_TRY_INSPECT(const auto& bodyDir, BodyGetCacheDir(aBaseDir, id));
+    QM_TRY_INSPECT(const auto& bodyDir, BodyGetCacheDir(aBaseDir, id));
 
     const auto removeFileForId =
         [&aQuotaInfo, &id](
             nsIFile& bodyFile,
             const nsACString& leafName) -> Result<bool, nsresult> {
       nsID fileId;
-      CACHE_TRY(OkIf(fileId.Parse(leafName.BeginReading())), true,
-                ([&aQuotaInfo, &bodyFile](const auto) {
-                  DebugOnly<nsresult> result = RemoveNsIFile(
-                      aQuotaInfo, bodyFile, /* aTrackQuota */ false);
-                  MOZ_ASSERT(NS_SUCCEEDED(result));
-                }));
+      QM_TRY(OkIf(fileId.Parse(leafName.BeginReading())), true,
+             ([&aQuotaInfo, &bodyFile](const auto) {
+               DebugOnly<nsresult> result =
+                   RemoveNsIFile(aQuotaInfo, bodyFile, /* aTrackQuota */ false);
+               MOZ_ASSERT(NS_SUCCEEDED(result));
+             }));
 
       if (id.Equals(fileId)) {
         DebugOnly<nsresult> result = RemoveNsIFile(aQuotaInfo, bodyFile);
         MOZ_ASSERT(NS_SUCCEEDED(result));
         return true;
       }
 
       return false;
     };
-    CACHE_TRY(BodyTraverseFiles(aQuotaInfo, *bodyDir, removeFileForId,
-                                /* aCanRemoveFiles */ false,
-                                /* aTrackQuota */ true));
+    QM_TRY(BodyTraverseFiles(aQuotaInfo, *bodyDir, removeFileForId,
+                             /* aCanRemoveFiles */ false,
+                             /* aTrackQuota */ true));
   }
 
   return NS_OK;
 }
 
 namespace {
 
 Result<NotNull<nsCOMPtr<nsIFile>>, nsresult> BodyIdToFile(
     nsIFile& aBaseDir, const nsID& aId, const BodyFileType aType) {
-  CACHE_TRY_UNWRAP(auto bodyFile, BodyGetCacheDir(aBaseDir, aId));
+  QM_TRY_UNWRAP(auto bodyFile, BodyGetCacheDir(aBaseDir, aId));
 
   char idString[NSID_LENGTH];
   aId.ToProvidedString(idString);
 
   NS_ConvertASCIItoUTF16 fileName(idString);
 
   if (aType == BODY_FILE_FINAL) {
     fileName.AppendLiteral(".final");
   } else {
     fileName.AppendLiteral(".tmp");
   }
 
-  CACHE_TRY(bodyFile->Append(fileName));
+  QM_TRY(bodyFile->Append(fileName));
 
   return bodyFile;
 }
 
 int64_t RoundUp(const int64_t aX, const int64_t aY) {
   MOZ_DIAGNOSTIC_ASSERT(aX >= 0);
   MOZ_DIAGNOSTIC_ASSERT(aY > 0);
 
@@ -315,95 +314,93 @@ int64_t BodyGeneratePadding(const int64_
   return RoundUp(randomSize, kRoundUpNumber) - aBodyFileSize;
 }
 
 nsresult DirectoryPaddingWrite(nsIFile& aBaseDir,
                                DirPaddingFile aPaddingFileType,
                                int64_t aPaddingSize) {
   MOZ_DIAGNOSTIC_ASSERT(aPaddingSize >= 0);
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, aPaddingFileType == DirPaddingFile::TMP_FILE
                                        ? nsLiteralString(PADDING_TMP_FILE_NAME)
                                        : nsLiteralString(PADDING_FILE_NAME)));
 
-  CACHE_TRY_INSPECT(const auto& outputStream,
-                    NS_NewLocalFileOutputStream(file));
+  QM_TRY_INSPECT(const auto& outputStream, NS_NewLocalFileOutputStream(file));
 
   nsCOMPtr<nsIObjectOutputStream> objectStream =
       NS_NewObjectOutputStream(outputStream);
 
-  CACHE_TRY(objectStream->Write64(aPaddingSize));
+  QM_TRY(objectStream->Write64(aPaddingSize));
 
   return NS_OK;
 }
 
 }  // namespace
 
 nsresult BodyDeleteOrphanedFiles(const QuotaInfo& aQuotaInfo, 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
 
-  CACHE_TRY_INSPECT(const auto& dir,
-                    CloneFileAndAppend(aBaseDir, kMorgueDirectory));
+  QM_TRY_INSPECT(const auto& dir,
+                 CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
   // Iterate over all the intermediate morgue subdirs
-  CACHE_TRY(quota::CollectEachFile(
+  QM_TRY(quota::CollectEachFile(
       *dir,
       [&aQuotaInfo, &aKnownBodyIdList](
           const nsCOMPtr<nsIFile>& subdir) -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*subdir));
+        QM_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*subdir));
 
         switch (dirEntryKind) {
           case nsIFileKind::ExistsAsDirectory: {
             const auto removeOrphanedFiles =
                 [&aQuotaInfo, &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([&aQuotaInfo, &bodyFile] {
                 DebugOnly<nsresult> result =
                     RemoveNsIFile(aQuotaInfo, bodyFile);
                 MOZ_ASSERT(NS_SUCCEEDED(result));
               });
 
               nsID id;
-              CACHE_TRY(OkIf(id.Parse(leafName.BeginReading())), true);
+              QM_TRY(OkIf(id.Parse(leafName.BeginReading())), true);
 
               if (!aKnownBodyIdList.Contains(id)) {
                 return true;
               }
 
               cleanup.release();
 
               return false;
             };
 
             // QM_OR_ELSE_WARN is not used here since we want ignore
             // NS_ERROR_FILE_FS_CORRUPTED completely (even a warning is not
             // desired).
-            CACHE_TRY(
-                ToResult(BodyTraverseFiles(aQuotaInfo, *subdir,
-                                           removeOrphanedFiles,
-                                           /* aCanRemoveFiles */ true,
-                                           /* aTrackQuota */ true))
-                    .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
-                      // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
-                      // directory did not exist at all.
-                      if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
-                        return Ok{};
-                      }
+            QM_TRY(ToResult(BodyTraverseFiles(aQuotaInfo, *subdir,
+                                              removeOrphanedFiles,
+                                              /* aCanRemoveFiles */ true,
+                                              /* aTrackQuota */ true))
+                       .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
+                         // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
+                         // directory did not exist at all.
+                         if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
+                           return Ok{};
+                         }
 
-                      return Err(rv);
-                    }));
+                         return Err(rv);
+                       }));
             break;
           }
 
           case nsIFileKind::ExistsAsFile: {
             // If a file got in here somehow, try to remove it and move on
             DebugOnly<nsresult> result =
                 RemoveNsIFile(aQuotaInfo, *subdir, /* aTrackQuota */ false);
             MOZ_ASSERT(NS_SUCCEEDED(result));
@@ -420,83 +417,82 @@ nsresult BodyDeleteOrphanedFiles(const Q
 
   return NS_OK;
 }
 
 namespace {
 
 Result<nsCOMPtr<nsIFile>, nsresult> GetMarkerFileHandle(
     const QuotaInfo& aQuotaInfo) {
-  CACHE_TRY_UNWRAP(auto marker,
-                   CloneFileAndAppend(*aQuotaInfo.mDir, u"cache"_ns));
+  QM_TRY_UNWRAP(auto marker, CloneFileAndAppend(*aQuotaInfo.mDir, u"cache"_ns));
 
-  CACHE_TRY(marker->Append(u"context_open.marker"_ns));
+  QM_TRY(marker->Append(u"context_open.marker"_ns));
 
   return marker;
 }
 
 }  // namespace
 
 nsresult CreateMarkerFile(const QuotaInfo& aQuotaInfo) {
-  CACHE_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo));
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo));
 
   QM_TRY(
       QM_OR_ELSE_WARN(ToResult(marker->Create(nsIFile::NORMAL_FILE_TYPE, 0644)),
                       MapAlreadyExistsToDefault));
 
   // Note, we don't need to fsync here.  We only care about actually
   // 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 QuotaInfo& aQuotaInfo) {
-  CACHE_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo));
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo));
 
   DebugOnly<nsresult> result =
       RemoveNsIFile(aQuotaInfo, *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 QuotaInfo& aQuotaInfo) {
-  CACHE_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo), false);
+  QM_TRY_INSPECT(const auto& marker, GetMarkerFileHandle(aQuotaInfo), false);
 
-  CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(marker, Exists), false);
+  QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(marker, Exists), false);
 }
 
 nsresult RemoveNsIFileRecursively(const QuotaInfo& aQuotaInfo, nsIFile& aFile,
                                   const bool aTrackQuota) {
-  CACHE_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(aFile));
+  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.
-      CACHE_TRY(quota::CollectEachFile(
+      QM_TRY(quota::CollectEachFile(
           aFile,
           [&aQuotaInfo, &aTrackQuota](
               const nsCOMPtr<nsIFile>& file) -> Result<Ok, nsresult> {
-            CACHE_TRY(RemoveNsIFileRecursively(aQuotaInfo, *file, aTrackQuota));
+            QM_TRY(RemoveNsIFileRecursively(aQuotaInfo, *file, aTrackQuota));
 
             return Ok{};
           }));
 
       // In the end, remove the folder
-      CACHE_TRY(aFile.Remove(/* recursive */ false));
+      QM_TRY(aFile.Remove(/* recursive */ false));
 
       break;
 
     case nsIFileKind::ExistsAsFile:
       return RemoveNsIFile(aQuotaInfo, aFile, aTrackQuota);
 
     case nsIFileKind::DoesNotExist:
       // Ignore files that got removed externally while iterating.
@@ -505,17 +501,17 @@ nsresult RemoveNsIFileRecursively(const 
 
   return NS_OK;
 }
 
 nsresult RemoveNsIFile(const QuotaInfo& aQuotaInfo, nsIFile& aFile,
                        const bool aTrackQuota) {
   int64_t fileSize = 0;
   if (aTrackQuota) {
-    CACHE_TRY_INSPECT(
+    QM_TRY_INSPECT(
         const auto& maybeFileSize,
         QM_OR_ELSE_WARN(
             MOZ_TO_RESULT_INVOKE(aFile, GetFileSize).map(Some<int64_t>),
             MapNotFoundToDefault<Maybe<int64_t>>));
 
     if (!maybeFileSize) {
       return NS_OK;
     }
@@ -542,85 +538,85 @@ void DecreaseUsageForQuotaInfo(const Quo
   MOZ_DIAGNOSTIC_ASSERT(quotaManager);
 
   quotaManager->DecreaseUsageForClient(
       quota::ClientMetadata{aQuotaInfo, Client::DOMCACHE}, aUpdatingSize);
 }
 
 bool DirectoryPaddingFileExists(nsIFile& aBaseDir,
                                 DirPaddingFile aPaddingFileType) {
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, aPaddingFileType == DirPaddingFile::TMP_FILE
                                        ? nsLiteralString(PADDING_TMP_FILE_NAME)
                                        : nsLiteralString(PADDING_FILE_NAME)),
       false);
 
-  CACHE_TRY_RETURN(MOZ_TO_RESULT_INVOKE(file, Exists), false);
+  QM_TRY_RETURN(MOZ_TO_RESULT_INVOKE(file, Exists), false);
 }
 
 Result<int64_t, nsresult> DirectoryPaddingGet(nsIFile& aBaseDir) {
   MOZ_DIAGNOSTIC_ASSERT(
       !DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::TMP_FILE));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, nsLiteralString(PADDING_FILE_NAME)));
 
-  CACHE_TRY_UNWRAP(auto stream, NS_NewLocalFileInputStream(file));
+  QM_TRY_UNWRAP(auto stream, NS_NewLocalFileInputStream(file));
 
-  CACHE_TRY_INSPECT(const auto& bufferedStream,
-                    NS_NewBufferedInputStream(stream.forget(), 512));
+  QM_TRY_INSPECT(const auto& bufferedStream,
+                 NS_NewBufferedInputStream(stream.forget(), 512));
 
   const nsCOMPtr<nsIObjectInputStream> objectStream =
       NS_NewObjectInputStream(bufferedStream);
 
-  CACHE_TRY_RETURN(
+  QM_TRY_RETURN(
       MOZ_TO_RESULT_INVOKE(objectStream, Read64).map([](const uint64_t val) {
         return int64_t(val);
       }));
 }
 
 nsresult DirectoryPaddingInit(nsIFile& aBaseDir) {
-  CACHE_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::FILE, 0));
+  QM_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::FILE, 0));
 
   return NS_OK;
 }
 
 nsresult UpdateDirectoryPaddingFile(nsIFile& aBaseDir,
                                     mozIStorageConnection& aConn,
                                     const int64_t aIncreaseSize,
                                     const int64_t aDecreaseSize,
                                     const bool aTemporaryFileExist) {
   MOZ_DIAGNOSTIC_ASSERT(aIncreaseSize >= 0);
   MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
 
   const auto directoryPaddingGetResult =
       aTemporaryFileExist ? Maybe<int64_t>{} : [&aBaseDir] {
-        CACHE_TRY_RETURN(
+        QM_TRY_RETURN(
             QM_OR_ELSE_WARN(DirectoryPaddingGet(aBaseDir).map(Some<int64_t>),
                             MapNotFoundToDefault<Maybe<int64_t>>),
             Maybe<int64_t>{});
       }();
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const int64_t& currentPaddingSize,
       ([directoryPaddingGetResult, &aBaseDir, &aConn, aIncreaseSize,
         aDecreaseSize]() -> Result<int64_t, nsresult> {
         if (!directoryPaddingGetResult) {
           // Fail to read padding size from the dir padding file, so try to
           // restore.
 
           // Not delete the temporary padding file here, because we're going
           // to overwrite it below anyway.
-          CACHE_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
+          QM_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
 
           // We don't need to add the aIncreaseSize or aDecreaseSize here,
           // because it's already encompassed within the database.
-          CACHE_TRY_RETURN(db::FindOverallPaddingSize(aConn));
+          QM_TRY_RETURN(db::FindOverallPaddingSize(aConn));
         }
 
         int64_t currentPaddingSize = directoryPaddingGetResult.value();
         bool shouldRevise = false;
 
         if (aIncreaseSize > 0) {
           if (INT64_MAX - currentPaddingSize < aDecreaseSize) {
             shouldRevise = true;
@@ -637,82 +633,80 @@ nsresult UpdateDirectoryPaddingFile(nsIF
           }
         }
 
         if (shouldRevise) {
           // If somehow runing into this condition, the tracking padding size is
           // incorrect.
           // Delete padding file to indicate the padding size is incorrect for
           // avoiding error happening in the following lines.
-          CACHE_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
+          QM_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
 
-          CACHE_TRY_UNWRAP(currentPaddingSize,
-                           db::FindOverallPaddingSize(aConn));
+          QM_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(aConn));
 
           // XXXtt: we should have an easy way to update (increase or
           // recalulate) padding size in the QM. For now, only correct the
           // padding size in padding file and make QM be able to get the correct
           // size in the next QM initialization. We still want to catch this in
           // the debug build.
           MOZ_ASSERT(false, "The padding size is unsync with QM");
         }
 
 #ifdef DEBUG
         const int64_t lastPaddingSize = currentPaddingSize;
-        CACHE_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(aConn));
+        QM_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(aConn));
 
         MOZ_DIAGNOSTIC_ASSERT(currentPaddingSize == lastPaddingSize);
 #endif  // DEBUG
 
         return currentPaddingSize;
       }()));
 
   MOZ_DIAGNOSTIC_ASSERT(currentPaddingSize >= 0);
 
-  CACHE_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::TMP_FILE,
-                                  currentPaddingSize));
+  QM_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::TMP_FILE,
+                               currentPaddingSize));
 
   return NS_OK;
 }
 
 nsresult DirectoryPaddingFinalizeWrite(nsIFile& aBaseDir) {
   MOZ_DIAGNOSTIC_ASSERT(
       DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::TMP_FILE));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, nsLiteralString(PADDING_TMP_FILE_NAME)));
 
-  CACHE_TRY(file->RenameTo(nullptr, nsLiteralString(PADDING_FILE_NAME)));
+  QM_TRY(file->RenameTo(nullptr, nsLiteralString(PADDING_FILE_NAME)));
 
   return NS_OK;
 }
 
 Result<int64_t, nsresult> DirectoryPaddingRestore(nsIFile& aBaseDir,
                                                   mozIStorageConnection& aConn,
                                                   const bool aMustRestore) {
   // The content of padding file is untrusted, so remove it here.
-  CACHE_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
+  QM_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE));
 
-  CACHE_TRY_INSPECT(const int64_t& paddingSize,
-                    db::FindOverallPaddingSize(aConn));
+  QM_TRY_INSPECT(const int64_t& paddingSize, db::FindOverallPaddingSize(aConn));
   MOZ_DIAGNOSTIC_ASSERT(paddingSize >= 0);
 
-  CACHE_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::FILE, paddingSize),
-            (aMustRestore ? Err(tryTempError)
-                          : Result<int64_t, nsresult>{paddingSize}));
+  QM_TRY(DirectoryPaddingWrite(aBaseDir, DirPaddingFile::FILE, paddingSize),
+         (aMustRestore ? Err(tryTempError)
+                       : Result<int64_t, nsresult>{paddingSize}));
 
-  CACHE_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::TMP_FILE));
+  QM_TRY(DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::TMP_FILE));
 
   return paddingSize;
 }
 
 nsresult DirectoryPaddingDeleteFile(nsIFile& aBaseDir,
                                     DirPaddingFile aPaddingFileType) {
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& file,
       CloneFileAndAppend(aBaseDir, aPaddingFileType == DirPaddingFile::TMP_FILE
                                        ? nsLiteralString(PADDING_TMP_FILE_NAME)
                                        : nsLiteralString(PADDING_FILE_NAME)));
 
   QM_TRY(QM_OR_ELSE_WARN(ToResult(file->Remove(/* recursive */ false)),
                          MapNotFoundToDefault<>));
 
--- a/dom/cache/FileUtilsImpl.h
+++ b/dom/cache/FileUtilsImpl.h
@@ -29,58 +29,57 @@ nsresult BodyTraverseFiles(const QuotaIn
     rv = parentFile->GetNativeLeafName(nativeLeafName);
     MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
 
     MOZ_DIAGNOSTIC_ASSERT(StringEndsWith(nativeLeafName, "morgue"_ns));
   }
 #endif
 
   FlippedOnce<true> isEmpty;
-  CACHE_TRY(quota::CollectEachFile(
+  QM_TRY(quota::CollectEachFile(
       aBodyDir,
       [&isEmpty, &aQuotaInfo, aTrackQuota, &aHandleFileFunc,
        aCanRemoveFiles](const nsCOMPtr<nsIFile>& file) -> Result<Ok, nsresult> {
-        CACHE_TRY_INSPECT(const auto& dirEntryKind,
-                          quota::GetDirEntryKind(*file));
+        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(
                 aQuotaInfo, *file, /* aTrackQuota */ false);
             MOZ_ASSERT(NS_SUCCEEDED(result));
             break;
           }
 
           case quota::nsIFileKind::ExistsAsFile: {
             nsAutoCString leafName;
-            CACHE_TRY(file->GetNativeLeafName(leafName));
+            QM_TRY(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(aQuotaInfo, *file, aTrackQuota);
                 MOZ_ASSERT(NS_SUCCEEDED(result));
                 return Ok{};
               }
             } else {
-              CACHE_TRY(OkIf(StringEndsWith(leafName, ".final"_ns)), Ok{},
-                        ([&aQuotaInfo, &file](const auto&) {
-                          // Otherwise, it must be a .final file.  If its not,
-                          // then try to remove it and move on
-                          DebugOnly<nsresult> result = RemoveNsIFile(
-                              aQuotaInfo, *file, /* aTrackQuota */ false);
-                          MOZ_ASSERT(NS_SUCCEEDED(result));
-                        }));
+              QM_TRY(OkIf(StringEndsWith(leafName, ".final"_ns)), Ok{},
+                     ([&aQuotaInfo, &file](const auto&) {
+                       // Otherwise, it must be a .final file.  If its not,
+                       // then try to remove it and move on
+                       DebugOnly<nsresult> result = RemoveNsIFile(
+                           aQuotaInfo, *file, /* aTrackQuota */ false);
+                       MOZ_ASSERT(NS_SUCCEEDED(result));
+                     }));
             }
 
-            CACHE_TRY_INSPECT(const bool& fileDeleted,
-                              aHandleFileFunc(*file, leafName));
+            QM_TRY_INSPECT(const bool& fileDeleted,
+                           aHandleFileFunc(*file, leafName));
             if (fileDeleted) {
               return Ok{};
             }
 
             isEmpty.EnsureFlipped();
             break;
           }
 
--- a/dom/cache/Manager.cpp
+++ b/dom/cache/Manager.cpp
@@ -55,17 +55,17 @@ nsresult MaybeUpdatePaddingFile(nsIFile*
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
   MOZ_DIAGNOSTIC_ASSERT(aConn);
   MOZ_DIAGNOSTIC_ASSERT(aIncreaseSize >= 0);
   MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
 
   RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
   MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
 
-  CACHE_TRY(cacheQuotaClient->MaybeUpdatePaddingFileInternal(
+  QM_TRY(cacheQuotaClient->MaybeUpdatePaddingFileInternal(
       *aBaseDir, *aConn, aIncreaseSize, aDecreaseSize, aCommitHook));
 
   return NS_OK;
 }
 
 // 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.
@@ -73,68 +73,67 @@ class SetupAction final : public SyncDBA
  public:
   SetupAction() : SyncDBAction(DBAction::Create) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    CACHE_TRY(BodyCreateDir(*aDBDir));
+    QM_TRY(BodyCreateDir(*aDBDir));
 
     // executes in its own transaction
-    CACHE_TRY(db::CreateOrMigrateSchema(*aConn));
+    QM_TRY(db::CreateOrMigrateSchema(*aConn));
 
     // If the Context marker file exists, then the last session was
     // not cleanly shutdown.  In these cases sqlite will ensure that
     // 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(aQuotaInfo)) {
       NS_WARNING("Cache not shutdown cleanly! Cleaning up stale data...");
       mozStorageTransaction trans(aConn, false,
                                   mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-      CACHE_TRY(trans.Start());
+      QM_TRY(trans.Start());
 
       // Clean up orphaned Cache objects
-      CACHE_TRY_INSPECT(const auto& orphanedCacheIdList,
-                        db::FindOrphanedCacheIds(*aConn));
+      QM_TRY_INSPECT(const auto& orphanedCacheIdList,
+                     db::FindOrphanedCacheIds(*aConn));
 
-      CACHE_TRY_INSPECT(
+      QM_TRY_INSPECT(
           const CheckedInt64& overallDeletedPaddingSize,
           Reduce(
               orphanedCacheIdList, CheckedInt64(0),
               [aConn, &aQuotaInfo, &aDBDir](
                   CheckedInt64 oldValue, const Maybe<const CacheId&>& element)
                   -> Result<CheckedInt64, nsresult> {
-                CACHE_TRY_INSPECT(const auto& deletionInfo,
-                                  db::DeleteCacheId(*aConn, *element));
+                QM_TRY_INSPECT(const auto& deletionInfo,
+                               db::DeleteCacheId(*aConn, *element));
 
-                CACHE_TRY(BodyDeleteFiles(aQuotaInfo, *aDBDir,
-                                          deletionInfo.mDeletedBodyIdList));
+                QM_TRY(BodyDeleteFiles(aQuotaInfo, *aDBDir,
+                                       deletionInfo.mDeletedBodyIdList));
 
                 if (deletionInfo.mDeletedPaddingSize > 0) {
                   DecreaseUsageForQuotaInfo(aQuotaInfo,
                                             deletionInfo.mDeletedPaddingSize);
                 }
 
                 return oldValue + deletionInfo.mDeletedPaddingSize;
               }));
 
       // Clean up orphaned body objects
-      CACHE_TRY_INSPECT(const auto& knownBodyIdList,
-                        db::GetKnownBodyIds(*aConn));
+      QM_TRY_INSPECT(const auto& knownBodyIdList, db::GetKnownBodyIds(*aConn));
 
-      CACHE_TRY(BodyDeleteOrphanedFiles(aQuotaInfo, *aDBDir, knownBodyIdList));
+      QM_TRY(BodyDeleteOrphanedFiles(aQuotaInfo, *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
@@ -143,17 +142,17 @@ class SetupAction final : public SyncDBA
       QM_WARNONLY_TRY(
           MaybeUpdatePaddingFile(aDBDir, aConn, /* aIncreaceSize */ 0,
                                  overallDeletedPaddingSize.value(),
                                  [&trans]() { return trans.Commit(); }));
     }
 
     if (DirectoryPaddingFileExists(*aDBDir, DirPaddingFile::TMP_FILE) ||
         !DirectoryPaddingFileExists(*aDBDir, DirPaddingFile::FILE)) {
-      CACHE_TRY(RestorePaddingFile(aDBDir, aConn));
+      QM_TRY(RestorePaddingFile(aDBDir, aConn));
     }
 
     return NS_OK;
   }
 };
 
 // ----------------------------------------------------------------------------
 
@@ -176,22 +175,22 @@ class DeleteOrphanedBodyAction final : p
 
     // 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);
     };
 
-    CACHE_TRY_INSPECT(const auto& dbDir,
-                      CloneFileAndAppend(*aQuotaInfo.mDir, u"cache"_ns),
-                      QM_VOID, resolve);
+    QM_TRY_INSPECT(const auto& dbDir,
+                   CloneFileAndAppend(*aQuotaInfo.mDir, u"cache"_ns), QM_VOID,
+                   resolve);
 
-    CACHE_TRY(BodyDeleteFiles(aQuotaInfo, *dbDir, mDeletedBodyIdList), QM_VOID,
-              resolve);
+    QM_TRY(BodyDeleteFiles(aQuotaInfo, *dbDir, mDeletedBodyIdList), QM_VOID,
+           resolve);
 
     aResolver->Resolve(NS_OK);
   }
 
  private:
   DeletedBodyIdList mDeletedBodyIdList;
 };
 
@@ -229,25 +228,25 @@ class Manager::Factory {
   friend class StaticAutoPtr<Manager::Factory>;
 
   static Result<SafeRefPtr<Manager>, nsresult> AcquireCreateIfNonExistent(
       const SafeRefPtr<ManagerId>& aManagerId) {
     mozilla::ipc::AssertIsOnBackgroundThread();
 
     // Ensure there is a factory instance.  This forces the Acquire() call
     // below to use the same factory.
-    CACHE_TRY(MaybeCreateInstance());
+    QM_TRY(MaybeCreateInstance());
 
     SafeRefPtr<Manager> ref = Acquire(*aManagerId);
     if (!ref) {
       // TODO: replace this with a thread pool (bug 1119864)
-      // XXX Can't use CACHE_TRY_INSPECT because that causes a clang-plugin
+      // XXX Can't use QM_TRY_INSPECT because that causes a clang-plugin
       // error of the NoNewThreadsChecker.
       nsCOMPtr<nsIThread> ioThread;
-      CACHE_TRY(ToResult(
+      QM_TRY(ToResult(
           NS_NewNamedThread("DOMCacheThread", getter_AddRefs(ioThread))));
 
       ref = MakeSafeRefPtr<Manager>(aManagerId.clonePtr(), ioThread,
                                     ConstructorGuard{});
 
       // There may be an old manager for this origin in the process of
       // cleaning up.  We need to tell the new manager about this so
       // that it won't actually start until the old manager is done.
@@ -409,17 +408,17 @@ class Manager::Factory {
 
     sFactory = nullptr;
   }
 
   static SafeRefPtr<Manager> Acquire(const ManagerId& aManagerId,
                                      State aState = Open) {
     mozilla::ipc::AssertIsOnBackgroundThread();
 
-    CACHE_TRY(MaybeCreateInstance(), nullptr);
+    QM_TRY(MaybeCreateInstance(), nullptr);
 
     // Iterate in reverse to find the most recent, matching Manager.  This
     // is important when looking for a Closing Manager.  If a new Manager
     // chains to an old Manager we want it to be the most recent one.
     const auto range = Reversed(sFactory->mManagerList.NonObservingRange());
     const auto foundIt = std::find_if(
         range.begin(), range.end(), [aState, &aManagerId](const auto& manager) {
           return aState == manager->GetState() &&
@@ -534,21 +533,21 @@ class Manager::DeleteOrphanedCacheAction
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     mQuotaInfo.emplace(aQuotaInfo);
 
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-    CACHE_TRY(trans.Start());
+    QM_TRY(trans.Start());
 
-    CACHE_TRY_UNWRAP(mDeletionInfo, db::DeleteCacheId(*aConn, mCacheId));
+    QM_TRY_UNWRAP(mDeletionInfo, db::DeleteCacheId(*aConn, mCacheId));
 
-    CACHE_TRY(MaybeUpdatePaddingFile(
+    QM_TRY(MaybeUpdatePaddingFile(
         aDBDir, aConn, /* aIncreaceSize */ 0, mDeletionInfo.mDeletedPaddingSize,
         [&trans]() mutable { return trans.Commit(); }));
 
     return NS_OK;
   }
 
   virtual void CompleteOnInitiatingThread(nsresult aRv) override {
     // If the transaction fails, we shouldn't delete the body files and decrease
@@ -589,35 +588,34 @@ class Manager::CacheMatchAction final : 
         mStreamList(std::move(aStreamList)),
         mFoundResponse(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    CACHE_TRY_INSPECT(
+    QM_TRY_INSPECT(
         const auto& maybeResponse,
         db::CacheMatch(*aConn, mCacheId, mArgs.request(), mArgs.params()));
 
     mFoundResponse = maybeResponse.isSome();
     if (mFoundResponse) {
       mResponse = std::move(maybeResponse.ref());
     }
 
     if (!mFoundResponse || !mResponse.mHasBodyId ||
         IsHeadRequest(mArgs.request(), mArgs.params())) {
       mResponse.mHasBodyId = false;
       return NS_OK;
     }
 
     nsCOMPtr<nsIInputStream> stream;
     if (mArgs.openMode() == OpenMode::Eager) {
-      CACHE_TRY_UNWRAP(stream,
-                       BodyOpen(aQuotaInfo, *aDBDir, mResponse.mBodyId));
+      QM_TRY_UNWRAP(stream, BodyOpen(aQuotaInfo, *aDBDir, mResponse.mBodyId));
     }
 
     mStreamList->Add(mResponse.mBodyId, std::move(stream));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
@@ -655,30 +653,30 @@ class Manager::CacheMatchAllAction final
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    CACHE_TRY_UNWRAP(mSavedResponses,
-                     db::CacheMatchAll(*aConn, mCacheId, mArgs.maybeRequest(),
-                                       mArgs.params()));
+    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) {
-        CACHE_TRY_UNWRAP(
+        QM_TRY_UNWRAP(
             stream, BodyOpen(aQuotaInfo, *aDBDir, mSavedResponses[i].mBodyId));
       }
 
       mStreamList->Add(mSavedResponses[i].mBodyId, std::move(stream));
     }
 
     return NS_OK;
   }
@@ -762,23 +760,23 @@ class Manager::CachePutAllAction final :
     mDBDir = aDBDir;
     mConn = aConn;
     mQuotaInfo.emplace(aQuotaInfo);
 
     // 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, &aQuotaInfo]() -> nsresult {
-      CACHE_TRY(CollectEachInRange(
+      QM_TRY(CollectEachInRange(
           mList, [this, &aQuotaInfo](auto& entry) -> nsresult {
-            CACHE_TRY(StartStreamCopy(aQuotaInfo, entry, RequestStream,
-                                      &mExpectedAsyncCopyCompletions));
+            QM_TRY(StartStreamCopy(aQuotaInfo, entry, RequestStream,
+                                   &mExpectedAsyncCopyCompletions));
 
-            CACHE_TRY(StartStreamCopy(aQuotaInfo, entry, ResponseStream,
-                                      &mExpectedAsyncCopyCompletions));
+            QM_TRY(StartStreamCopy(aQuotaInfo, entry, ResponseStream,
+                                   &mExpectedAsyncCopyCompletions));
 
             return NS_OK;
           }));
 
       return NS_OK;
     }();
 
     // Always call OnAsyncCopyComplete() manually here.  This covers the
@@ -843,40 +841,40 @@ class Manager::CachePutAllAction final :
     if (NS_FAILED(mAsyncResult)) {
       DoResolve(mAsyncResult);
       return;
     }
 
     mozStorageTransaction trans(mConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-    CACHE_TRY(trans.Start(), QM_VOID);
+    QM_TRY(trans.Start(), QM_VOID);
 
     const nsresult rv = [this, &trans]() -> nsresult {
-      CACHE_TRY(CollectEachInRange(mList, [this](Entry& e) -> nsresult {
+      QM_TRY(CollectEachInRange(mList, [this](Entry& e) -> nsresult {
         if (e.mRequestStream) {
-          CACHE_TRY(BodyFinalizeWrite(*mDBDir, e.mRequestBodyId));
+          QM_TRY(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.
-            CACHE_TRY(BodyMaybeUpdatePaddingSize(
+            QM_TRY(BodyMaybeUpdatePaddingSize(
                 mQuotaInfo.ref(), *mDBDir, e.mResponseBodyId,
                 e.mResponse.paddingInfo(), &e.mResponse.paddingSize()));
 
             MOZ_DIAGNOSTIC_ASSERT(INT64_MAX - e.mResponse.paddingSize() >=
                                   mUpdatedPaddingSize);
             mUpdatedPaddingSize += e.mResponse.paddingSize();
           }
 
-          CACHE_TRY(BodyFinalizeWrite(*mDBDir, e.mResponseBodyId));
+          QM_TRY(BodyFinalizeWrite(*mDBDir, e.mResponseBodyId));
         }
 
-        CACHE_TRY_UNWRAP(
+        QM_TRY_UNWRAP(
             auto deletionInfo,
             db::CachePut(*mConn, mCacheId, e.mRequest,
                          e.mRequestStream ? &e.mRequestBodyId : nullptr,
                          e.mResponse,
                          e.mResponseStream ? &e.mResponseBodyId : nullptr));
 
         const int64_t deletedPaddingSize = deletionInfo.mDeletedPaddingSize;
         mDeletedBodyIdList = std::move(deletionInfo.mDeletedBodyIdList);
@@ -884,17 +882,17 @@ class Manager::CachePutAllAction final :
         MOZ_DIAGNOSTIC_ASSERT(INT64_MAX - mDeletedPaddingSize >=
                               deletedPaddingSize);
         mDeletedPaddingSize += deletedPaddingSize;
 
         return NS_OK;
       }));
 
       // Update padding file when it's necessary
-      CACHE_TRY(MaybeUpdatePaddingFile(
+      QM_TRY(MaybeUpdatePaddingFile(
           mDBDir, mConn, mUpdatedPaddingSize, mDeletedPaddingSize,
           [&trans]() mutable { return trans.Commit(); }));
 
       return NS_OK;
     }();
 
     DoResolve(rv);
   }
@@ -966,19 +964,19 @@ class Manager::CachePutAllAction final :
 
     const auto& source = aStreamId == RequestStream ? aEntry.mRequestStream
                                                     : aEntry.mResponseStream;
 
     if (!source) {
       return NS_OK;
     }
 
-    CACHE_TRY_INSPECT((const auto& [bodyId, copyContext]),
-                      BodyStartWriteStream(aQuotaInfo, *mDBDir, *source, this,
-                                           AsyncCopyCompleteFunc));
+    QM_TRY_INSPECT((const auto& [bodyId, copyContext]),
+                   BodyStartWriteStream(aQuotaInfo, *mDBDir, *source, this,
+                                        AsyncCopyCompleteFunc));
 
     if (aStreamId == RequestStream) {
       aEntry.mRequestBodyId = bodyId;
     } else {
       aEntry.mResponseBodyId = bodyId;
     }
 
     mBodyIdWrittenList.AppendElement(bodyId);
@@ -1103,28 +1101,28 @@ class Manager::CacheDeleteAction final :
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     mQuotaInfo.emplace(aQuotaInfo);
 
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-    CACHE_TRY(trans.Start());
+    QM_TRY(trans.Start());
 
-    CACHE_TRY_UNWRAP(
+    QM_TRY_UNWRAP(
         auto maybeDeletionInfo,
         db::CacheDelete(*aConn, mCacheId, mArgs.request(), mArgs.params()));
 
     mSuccess = maybeDeletionInfo.isSome();
     if (mSuccess) {
       mDeletionInfo = std::move(maybeDeletionInfo.ref());
     }
 
-    CACHE_TRY(
+    QM_TRY(
         MaybeUpdatePaddingFile(aDBDir, aConn, /* aIncreaceSize */ 0,
                                mDeletionInfo.mDeletedPaddingSize,
                                [&trans]() mutable { return trans.Commit(); }),
         QM_PROPAGATE, [this](const nsresult) { mSuccess = false; });
 
     return NS_OK;
   }
 
@@ -1170,31 +1168,31 @@ class Manager::CacheKeysAction final : p
         mArgs(aArgs),
         mStreamList(std::move(aStreamList)) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    CACHE_TRY_UNWRAP(
+    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) {
-        CACHE_TRY_UNWRAP(
-            stream, BodyOpen(aQuotaInfo, *aDBDir, mSavedRequests[i].mBodyId));
+        QM_TRY_UNWRAP(stream,
+                      BodyOpen(aQuotaInfo, *aDBDir, mSavedRequests[i].mBodyId));
       }
 
       mStreamList->Add(mSavedRequests[i].mBodyId, std::move(stream));
     }
 
     return NS_OK;
   }
 
@@ -1248,18 +1246,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) {
-      CACHE_TRY_UNWRAP(stream,
-                       BodyOpen(aQuotaInfo, *aDBDir, mSavedResponse.mBodyId));
+      QM_TRY_UNWRAP(stream,
+                    BodyOpen(aQuotaInfo, *aDBDir, mSavedResponse.mBodyId));
     }
 
     mStreamList->Add(mSavedResponse.mBodyId, std::move(stream));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
@@ -1290,18 +1288,18 @@ class Manager::StorageHasAction final : 
       : BaseAction(std::move(aManager), aListenerId),
         mNamespace(aNamespace),
         mArgs(aArgs),
         mCacheFound(false) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
-    CACHE_TRY_INSPECT(const auto& maybeCacheId,
-                      db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
+    QM_TRY_INSPECT(const auto& maybeCacheId,
+                   db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
 
     mCacheFound = maybeCacheId.isSome();
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     aListener->OnOpComplete(std::move(aRv), StorageHasResult(mCacheFound));
@@ -1326,33 +1324,33 @@ class Manager::StorageOpenAction final :
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     // Cache does not exist, create it instead
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-    CACHE_TRY(trans.Start());
+    QM_TRY(trans.Start());
 
     // Look for existing cache
-    CACHE_TRY_INSPECT(const auto& maybeCacheId,
-                      db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
+    QM_TRY_INSPECT(const auto& maybeCacheId,
+                   db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
 
     if (maybeCacheId.isSome()) {
       mCacheId = maybeCacheId.ref();
       MOZ_DIAGNOSTIC_ASSERT(mCacheId != INVALID_CACHE_ID);
       return NS_OK;
     }
 
-    CACHE_TRY_UNWRAP(mCacheId, db::CreateCacheId(*aConn));
+    QM_TRY_UNWRAP(mCacheId, db::CreateCacheId(*aConn));
 
-    CACHE_TRY(db::StoragePutCache(*aConn, mNamespace, mArgs.key(), mCacheId));
+    QM_TRY(db::StoragePutCache(*aConn, mNamespace, mArgs.key(), mCacheId));
 
-    CACHE_TRY(trans.Commit());
+    QM_TRY(trans.Commit());
 
     MOZ_DIAGNOSTIC_ASSERT(mCacheId != INVALID_CACHE_ID);
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     MOZ_DIAGNOSTIC_ASSERT(aRv.Failed() || mCacheId != INVALID_CACHE_ID);
     aListener->OnOpComplete(std::move(aRv),
@@ -1379,32 +1377,32 @@ class Manager::StorageDeleteAction final
         mCacheId(INVALID_CACHE_ID) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     mozStorageTransaction trans(aConn, false,
                                 mozIStorageConnection::TRANSACTION_IMMEDIATE);
 
-    CACHE_TRY(trans.Start());
+    QM_TRY(trans.Start());
 
-    CACHE_TRY_INSPECT(const auto& maybeCacheId,
-                      db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
+    QM_TRY_INSPECT(const auto& maybeCacheId,
+                   db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
 
     if (maybeCacheId.isNothing()) {
       mCacheDeleted = false;
       return NS_OK;
     }
     mCacheId = maybeCacheId.ref();
 
     // Don't delete the removing padding size here, we'll delete it on
     // DeleteOrphanedCacheAction.
-    CACHE_TRY(db::StorageForgetCache(*aConn, mNamespace, mArgs.key()));
+    QM_TRY(db::StorageForgetCache(*aConn, mNamespace, mArgs.key()));
 
-    CACHE_TRY(trans.Commit());
+    QM_TRY(trans.Commit());
 
     mCacheDeleted = true;
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     if (mCacheDeleted) {
       // If content is referencing this cache, mark it orphaned to be
@@ -1440,17 +1438,17 @@ class Manager::StorageKeysAction final :
  public:
   StorageKeysAction(SafeRefPtr<Manager> aManager, ListenerId aListenerId,
                     Namespace aNamespace)
       : BaseAction(std::move(aManager), aListenerId), mNamespace(aNamespace) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
-    CACHE_TRY_UNWRAP(mKeys, db::StorageGetKeys(*aConn, mNamespace));
+    QM_TRY_UNWRAP(mKeys, db::StorageGetKeys(*aConn, mNamespace));
 
     return NS_OK;
   }
 
   virtual void Complete(Listener* aListener, ErrorResult&& aRv) override {
     if (aRv.Failed()) {
       mKeys.Clear();
     }
@@ -1472,17 +1470,17 @@ class Manager::OpenStreamAction final : 
         mResolver(std::move(aResolver)),
         mBodyId(aBodyId) {}
 
   virtual nsresult RunSyncWithDBOnTarget(
       const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
       mozIStorageConnection* aConn) override {
     MOZ_DIAGNOSTIC_ASSERT(aDBDir);
 
-    CACHE_TRY_UNWRAP(mBodyStream, BodyOpen(aQuotaInfo, *aDBDir, mBodyId));
+    QM_TRY_UNWRAP(mBodyStream, BodyOpen(aQuotaInfo, *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/ManagerId.cpp
+++ b/dom/cache/ManagerId.cpp
@@ -21,18 +21,18 @@ using mozilla::dom::quota::QuotaManager;
 // static
 Result<SafeRefPtr<ManagerId>, nsresult> ManagerId::Create(
     nsIPrincipal* aPrincipal) {
   MOZ_ASSERT(NS_IsMainThread());
 
   // QuotaManager::GetOriginFromPrincipal() has special logic for system
   // and about: principals.  We need to use the same modified origin in
   // order to interpret calls from QM correctly.
-  CACHE_TRY_INSPECT(const auto& quotaOrigin,
-                    QuotaManager::GetOriginFromPrincipal(aPrincipal));
+  QM_TRY_INSPECT(const auto& quotaOrigin,
+                 QuotaManager::GetOriginFromPrincipal(aPrincipal));
 
   return MakeSafeRefPtr<ManagerId>(aPrincipal, quotaOrigin, ConstructorGuard{});
 }
 
 already_AddRefed<nsIPrincipal> ManagerId::Principal() const {
   MOZ_ASSERT(NS_IsMainThread());
   nsCOMPtr<nsIPrincipal> ref = mPrincipal;
   return ref.forget();
--- a/dom/cache/PrincipalVerifier.cpp
+++ b/dom/cache/PrincipalVerifier.cpp
@@ -96,17 +96,17 @@ PrincipalVerifier::Run() {
 
 void PrincipalVerifier::VerifyOnMainThread() {
   MOZ_ASSERT(NS_IsMainThread());
 
   // No matter what happens, we need to release the actor before leaving
   // this method.
   RefPtr<ContentParent> actor = std::move(mActor);
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& principal, PrincipalInfoToPrincipal(mPrincipalInfo), QM_VOID,
       [this](const nsresult result) { DispatchToInitiatingThread(result); });
 
   // We disallow null principal on the client side, but double-check here.
   if (NS_WARN_IF(principal->GetIsNullPrincipal())) {
     DispatchToInitiatingThread(NS_ERROR_FAILURE);
     return;
   }
--- a/dom/cache/QuotaClient.cpp
+++ b/dom/cache/QuotaClient.cpp
@@ -36,36 +36,36 @@ using mozilla::dom::quota::UsageInfo;
 using mozilla::ipc::AssertIsOnBackgroundThread;
 
 namespace {
 
 template <typename StepFunc>
 Result<UsageInfo, nsresult> ReduceUsageInfo(nsIFile& aDir,
                                             const Atomic<bool>& aCanceled,
                                             const StepFunc& aStepFunc) {
-  CACHE_TRY_RETURN(quota::ReduceEachFileAtomicCancelable(
+  QM_TRY_RETURN(quota::ReduceEachFileAtomicCancelable(
       aDir, aCanceled, UsageInfo{},
       [&aStepFunc](UsageInfo usageInfo, const nsCOMPtr<nsIFile>& bodyDir)
           -> Result<UsageInfo, nsresult> {
-        CACHE_TRY(OkIf(!QuotaManager::IsShuttingDown()), Err(NS_ERROR_ABORT));
+        QM_TRY(OkIf(!QuotaManager::IsShuttingDown()), Err(NS_ERROR_ABORT));
 
-        CACHE_TRY_INSPECT(const auto& stepUsageInfo, aStepFunc(bodyDir));
+        QM_TRY_INSPECT(const auto& stepUsageInfo, aStepFunc(bodyDir));
 
         return usageInfo + stepUsageInfo;
       }));
 }
 
 Result<UsageInfo, nsresult> GetBodyUsage(nsIFile& aMorgueDir,
                                          const Atomic<bool>& aCanceled) {
   AssertIsOnIOThread();
 
-  CACHE_TRY_RETURN(ReduceUsageInfo(
+  QM_TRY_RETURN(ReduceUsageInfo(
       aMorgueDir, aCanceled,
       [](const nsCOMPtr<nsIFile>& bodyDir) -> Result<UsageInfo, nsresult> {
-        CACHE_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*bodyDir));
+        QM_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*bodyDir));
 
         if (dirEntryKind != nsIFileKind::ExistsAsDirectory) {
           if (dirEntryKind == nsIFileKind::ExistsAsFile) {
             const DebugOnly<nsresult> result =
                 RemoveNsIFile(QuotaInfo{}, *bodyDir, /* aTrackQuota */ false);
             // Try to remove the unexpected files, and keep moving on even if it
             // fails because it might be created by virus or the operation
             // system
@@ -76,18 +76,18 @@ Result<UsageInfo, nsresult> GetBodyUsage
         }
 
         UsageInfo usageInfo;
         const auto getUsage =
             [&usageInfo](nsIFile& bodyFile,
                          const nsACString& leafName) -> Result<bool, nsresult> {
           Unused << leafName;
 
-          CACHE_TRY_INSPECT(const int64_t& fileSize,
-                            MOZ_TO_RESULT_INVOKE(bodyFile, GetFileSize));
+          QM_TRY_INSPECT(const int64_t& fileSize,
+                         MOZ_TO_RESULT_INVOKE(bodyFile, GetFileSize));
           MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
           // FIXME: Separate file usage and database usage in OriginInfo so that
           // the workaround for treating body file size as database usage can be
           // removed.
           //
           // This is needed because we want to remove the mutex lock for padding
           // files. The lock is needed because the padding file is accessed on
           // the QM IO thread while getting origin usage and is accessed on the
@@ -101,28 +101,28 @@ Result<UsageInfo, nsresult> GetBodyUsage
           usageInfo += DatabaseUsageType(Some(fileSize));
 
           return false;
         };
 
         // QM_OR_ELSE_WARN is not used here since we want ignore
         // NS_ERROR_FILE_FS_CORRUPTED completely (even a warning is not
         // desired).
-        CACHE_TRY(ToResult(BodyTraverseFiles(QuotaInfo{}, *bodyDir, getUsage,
-                                             /* aCanRemoveFiles */ true,
-                                             /* aTrackQuota */ false))
-                      .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
-                        // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
-                        // directory did not exist at all.
-                        if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
-                          return Ok{};
-                        }
+        QM_TRY(ToResult(BodyTraverseFiles(QuotaInfo{}, *bodyDir, getUsage,
+                                          /* aCanRemoveFiles */ true,
+                                          /* aTrackQuota */ false))
+                   .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
+                     // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
+                     // directory did not exist at all.
+                     if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
+                       return Ok{};
+                     }
 
-                        return Err(rv);
-                      }));
+                     return Err(rv);
+                   }));
         return usageInfo;
       }));
 }
 
 Result<int64_t, nsresult> GetPaddingSizeFromDB(
     nsIFile& aDir, nsIFile& aDBFile, const OriginMetadata& aOriginMetadata) {
   QuotaInfo quotaInfo;
   static_cast<OriginMetadata&>(quotaInfo) = aOriginMetadata;
@@ -131,32 +131,31 @@ Result<int64_t, nsresult> GetPaddingSize
   // 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(quotaInfo.mDirectoryLockId == -1);
 
 #ifdef DEBUG
   {
-    CACHE_TRY_INSPECT(const bool& exists,
-                      MOZ_TO_RESULT_INVOKE(aDBFile, Exists));
+    QM_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(aDBFile, Exists));
     MOZ_ASSERT(exists);
   }
 #endif
 
-  CACHE_TRY_INSPECT(const auto& conn, OpenDBConnection(quotaInfo, aDBFile));
+  QM_TRY_INSPECT(const auto& conn, OpenDBConnection(quotaInfo, 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).
-  CACHE_TRY(db::CreateOrMigrateSchema(*conn));
+  QM_TRY(db::CreateOrMigrateSchema(*conn));
 
-  CACHE_TRY_RETURN(DirectoryPaddingRestore(aDir, *conn,
-                                           /* aMustRestore */ false));
+  QM_TRY_RETURN(DirectoryPaddingRestore(aDir, *conn,
+                                        /* aMustRestore */ false));
 }
 
 }  // namespace
 
 const nsLiteralString kCachesSQLiteFilename = u"caches.sqlite"_ns;
 const nsLiteralString kMorgueDirectoryFilename = u"morgue"_ns;
 
 CacheQuotaClient::CacheQuotaClient() {
@@ -176,108 +175,107 @@ CacheQuotaClient::Type CacheQuotaClient:
 Result<UsageInfo, nsresult> CacheQuotaClient::InitOrigin(
     PersistenceType aPersistenceType, const OriginMetadata& aOriginMetadata,
     const AtomicBool& aCanceled) {
   AssertIsOnIOThread();
 
   QuotaManager* const qm = QuotaManager::Get();
   MOZ_DIAGNOSTIC_ASSERT(qm);
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& dir,
       qm->GetDirectoryForOrigin(aPersistenceType, aOriginMetadata.mOrigin));
 
-  CACHE_TRY(
-      dir->Append(NS_LITERAL_STRING_FROM_CSTRING(DOMCACHE_DIRECTORY_NAME)));
+  QM_TRY(dir->Append(NS_LITERAL_STRING_FROM_CSTRING(DOMCACHE_DIRECTORY_NAME)));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& cachesSQLiteFile,
       ([dir]() -> Result<nsCOMPtr<nsIFile>, nsresult> {
-        CACHE_TRY_INSPECT(const auto& cachesSQLite,
-                          CloneFileAndAppend(*dir, kCachesSQLiteFilename));
+        QM_TRY_INSPECT(const auto& cachesSQLite,
+                       CloneFileAndAppend(*dir, kCachesSQLiteFilename));
 
         // IsDirectory is used to check if caches.sqlite exists or not. Another
         // benefit of this is that we can test the failed cases by creating a
         // directory named "caches.sqlite".
-        CACHE_TRY_INSPECT(const auto& dirEntryKind,
-                          GetDirEntryKind(*cachesSQLite));
+        QM_TRY_INSPECT(const auto& dirEntryKind,
+                       GetDirEntryKind(*cachesSQLite));
         if (dirEntryKind == nsIFileKind::DoesNotExist) {
           // We only ensure padding files and morgue directory get removed like
           // WipeDatabase in DBAction.cpp. The -wal journal file will be
           // automatically deleted by sqlite when the new database is created.
           // XXX Ideally, we would delete the -wal journal file as well (here
           // and also in WipeDatabase).
           // XXX We should have something like WipeDatabaseNoQuota for this.
           // XXX Long term, we might even think about removing entire origin
           // directory because missing caches.sqlite while other files exist can
           // be interpreted as database corruption.
-          CACHE_TRY(mozilla::dom::cache::DirectoryPaddingDeleteFile(
+          QM_TRY(mozilla::dom::cache::DirectoryPaddingDeleteFile(
               *dir, DirPaddingFile::TMP_FILE));
 
-          CACHE_TRY(mozilla::dom::cache::DirectoryPaddingDeleteFile(
+          QM_TRY(mozilla::dom::cache::DirectoryPaddingDeleteFile(
               *dir, DirPaddingFile::FILE));
 
-          CACHE_TRY_INSPECT(const auto& morgueDir,
-                            CloneFileAndAppend(*dir, kMorgueDirectoryFilename));
+          QM_TRY_INSPECT(const auto& morgueDir,
+                         CloneFileAndAppend(*dir, kMorgueDirectoryFilename));
 
           QuotaInfo dummy;
-          CACHE_TRY(mozilla::dom::cache::RemoveNsIFileRecursively(
+          QM_TRY(mozilla::dom::cache::RemoveNsIFileRecursively(
               dummy, *morgueDir,
               /* aTrackQuota */ false));
 
           return nsCOMPtr<nsIFile>{nullptr};
         }
 
-        CACHE_TRY(OkIf(dirEntryKind == nsIFileKind::ExistsAsFile),
-                  Err(NS_ERROR_FAILURE));
+        QM_TRY(OkIf(dirEntryKind == nsIFileKind::ExistsAsFile),
+               Err(NS_ERROR_FAILURE));
 
         return cachesSQLite;
       }()));
 
   // If the caches.sqlite doesn't exist, then padding files and morgue directory
   // should have been removed if they existed. We ignore the rest of known files
   // because we assume that they will be removed when a new database is created.
   // XXX Ensure the -wel file is removed if the caches.sqlite doesn't exist.
-  CACHE_TRY(OkIf(!!cachesSQLiteFile), UsageInfo{});
+  QM_TRY(OkIf(!!cachesSQLiteFile), UsageInfo{});
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& paddingSize,
       ([dir, cachesSQLiteFile,
         &aOriginMetadata]() -> Result<int64_t, nsresult> {
         if (!DirectoryPaddingFileExists(*dir, DirPaddingFile::TMP_FILE)) {
           QM_WARNONLY_TRY_UNWRAP(const auto maybePaddingSize,
                                  DirectoryPaddingGet(*dir));
           if (maybePaddingSize) {
             return maybePaddingSize.ref();
           }
         }
 
         // If the temporary file still exists or failing to get the padding size
         // from the padding file, then we need to get the padding size from the
         // database and restore the padding file.
-        CACHE_TRY_RETURN(
+        QM_TRY_RETURN(
             GetPaddingSizeFromDB(*dir, *cachesSQLiteFile, aOriginMetadata));
       }()));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const auto& innerUsageInfo,
       ReduceUsageInfo(
           *dir, aCanceled,
           [&aCanceled](
               const nsCOMPtr<nsIFile>& file) -> Result<UsageInfo, nsresult> {
-            CACHE_TRY_INSPECT(
+            QM_TRY_INSPECT(
                 const auto& leafName,
                 MOZ_TO_RESULT_INVOKE_TYPED(nsAutoString, file, GetLeafName));
 
-            CACHE_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*file));
+            QM_TRY_INSPECT(const auto& dirEntryKind, GetDirEntryKind(*file));
 
             switch (dirEntryKind) {
               case nsIFileKind::ExistsAsDirectory:
                 if (leafName.EqualsLiteral("morgue")) {
-                  CACHE_TRY_RETURN(GetBodyUsage(*file, aCanceled));
+                  QM_TRY_RETURN(GetBodyUsage(*file, aCanceled));
                 } else {
                   NS_WARNING("Unknown Cache directory found!");
                 }
 
                 break;
 
               case nsIFileKind::ExistsAsFile:
                 // Ignore transient sqlite files and marker files
@@ -285,18 +283,18 @@ Result<UsageInfo, nsresult> CacheQuotaCl
                     leafName.EqualsLiteral("caches.sqlite-shm") ||
                     leafName.Find("caches.sqlite-mj"_ns, false, 0, 0) == 0 ||
                     leafName.EqualsLiteral("context_open.marker")) {
                   break;
                 }
 
                 if (leafName.Equals(kCachesSQLiteFilename) ||
                     leafName.EqualsLiteral("caches.sqlite-wal")) {
-                  CACHE_TRY_INSPECT(const int64_t& fileSize,
-                                    MOZ_TO_RESULT_INVOKE(file, GetFileSize));
+                  QM_TRY_INSPECT(const int64_t& fileSize,
+                                 MOZ_TO_RESULT_INVOKE(file, GetFileSize));
                   MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
 
                   return UsageInfo{DatabaseUsageType(Some(fileSize))};
                 }
 
                 // Ignore directory padding file
                 if (leafName.EqualsLiteral(PADDING_FILE_NAME) ||
                     leafName.EqualsLiteral(PADDING_TMP_FILE_NAME)) {
@@ -413,56 +411,55 @@ nsCString CacheQuotaClient::GetShutdownS
 void CacheQuotaClient::FinalizeShutdown() {
   // Nothing to do here.
 }
 
 nsresult CacheQuotaClient::UpgradeStorageFrom2_0To2_1(nsIFile* aDirectory) {
   AssertIsOnIOThread();
   MOZ_DIAGNOSTIC_ASSERT(aDirectory);
 
-  CACHE_TRY(DirectoryPaddingInit(*aDirectory));
+  QM_TRY(DirectoryPaddingInit(*aDirectory));
 
   return NS_OK;
 }
 
 nsresult CacheQuotaClient::RestorePaddingFileInternal(
     nsIFile* aBaseDir, mozIStorageConnection* aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
   MOZ_DIAGNOSTIC_ASSERT(aConn);
 
-  CACHE_TRY_INSPECT(const int64_t& dummyPaddingSize,
-                    DirectoryPaddingRestore(*aBaseDir, *aConn,
-                                            /* aMustRestore */ true));
+  QM_TRY_INSPECT(const int64_t& dummyPaddingSize,
+                 DirectoryPaddingRestore(*aBaseDir, *aConn,
+                                         /* aMustRestore */ true));
   Unused << dummyPaddingSize;
 
   return NS_OK;
 }
 
 nsresult CacheQuotaClient::WipePaddingFileInternal(const QuotaInfo& aQuotaInfo,
                                                    nsIFile* aBaseDir) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
 
   MOZ_ASSERT(DirectoryPaddingFileExists(*aBaseDir, DirPaddingFile::FILE));
 
-  CACHE_TRY_INSPECT(
+  QM_TRY_INSPECT(
       const int64_t& paddingSize, ([&aBaseDir]() -> Result<int64_t, nsresult> {
         const bool temporaryPaddingFileExist =
             DirectoryPaddingFileExists(*aBaseDir, DirPaddingFile::TMP_FILE);
 
         Maybe<int64_t> directoryPaddingGetResult;
         if (!temporaryPaddingFileExist) {
-          CACHE_TRY_UNWRAP(
-              directoryPaddingGetResult,
-              ([&aBaseDir]() -> Result<Maybe<int64_t>, nsresult> {
-                CACHE_TRY_RETURN(
-                    DirectoryPaddingGet(*aBaseDir).map(Some<int64_t>),
-                    Maybe<int64_t>{});
-              }()));
+          QM_TRY_UNWRAP(directoryPaddingGetResult,
+                        ([&aBaseDir]() -> Result<Maybe<int64_t>, nsresult> {
+                          QM_TRY_RETURN(
+                              DirectoryPaddingGet(*aBaseDir).map(Some<int64_t>),
+                              Maybe<int64_t>{});
+                        }()));
         }
 
         if (temporaryPaddingFileExist || !directoryPaddingGetResult) {
           // XXXtt: Maybe have a method in the QuotaManager to clean the usage
           // under the quota client and the origin. There is nothing we can do
           // to recover the file.
           NS_WARNING("Cannnot read padding size from file!");
           return 0;
@@ -470,22 +467,22 @@ nsresult CacheQuotaClient::WipePaddingFi
 
         return *directoryPaddingGetResult;
       }()));
 
   if (paddingSize > 0) {
     DecreaseUsageForQuotaInfo(aQuotaInfo, paddingSize);
   }
 
-  CACHE_TRY(DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::FILE));
+  QM_TRY(DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::FILE));
 
   // Remove temporary file if we have one.
-  CACHE_TRY(DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::TMP_FILE));
+  QM_TRY(DirectoryPaddingDeleteFile(*aBaseDir, DirPaddingFile::TMP_FILE));
 
-  CACHE_TRY(DirectoryPaddingInit(*aBaseDir));
+  QM_TRY(DirectoryPaddingInit(*aBaseDir));
 
   return NS_OK;
 }
 
 CacheQuotaClient::~CacheQuotaClient() {
   AssertIsOnBackgroundThread();
   MOZ_DIAGNOSTIC_ASSERT(sInstance == this);
 
@@ -507,27 +504,27 @@ already_AddRefed<quota::Client> CreateQu
 nsresult RestorePaddingFile(nsIFile* aBaseDir, mozIStorageConnection* aConn) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
   MOZ_DIAGNOSTIC_ASSERT(aConn);
 
   RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
   MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
 
-  CACHE_TRY(cacheQuotaClient->RestorePaddingFileInternal(aBaseDir, aConn));
+  QM_TRY(cacheQuotaClient->RestorePaddingFileInternal(aBaseDir, aConn));
 
   return NS_OK;
 }
 
 // static
 nsresult WipePaddingFile(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
 
   RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
   MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
 
-  CACHE_TRY(cacheQuotaClient->WipePaddingFileInternal(aQuotaInfo, aBaseDir));
+  QM_TRY(cacheQuotaClient->WipePaddingFileInternal(aQuotaInfo, aBaseDir));
 
   return NS_OK;
 }
 
 }  // namespace mozilla::dom::cache
--- a/dom/cache/QuotaClientImpl.h
+++ b/dom/cache/QuotaClientImpl.h
@@ -71,30 +71,30 @@ class CacheQuotaClient final : public qu
 
     // Temporary should be removed at the end of each action. If not, it means
     // the failure happened.
     const bool temporaryPaddingFileExist =
         DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::TMP_FILE);
 
     if (aIncreaseSize == aDecreaseSize && !temporaryPaddingFileExist) {
       // Early return here, since most cache actions won't modify padding size.
-      CACHE_TRY(aCommitHook());
+      QM_TRY(aCommitHook());
 
       return NS_OK;
     }
 
     // Don't delete the temporary padding file in case of an error to force the
     // next action recalculate the padding size.
-    CACHE_TRY(UpdateDirectoryPaddingFile(aBaseDir, aConn, aIncreaseSize,
-                                         aDecreaseSize,
-                                         temporaryPaddingFileExist));
+    QM_TRY(UpdateDirectoryPaddingFile(aBaseDir, aConn, aIncreaseSize,
+                                      aDecreaseSize,
+                                      temporaryPaddingFileExist));
 
     // Don't delete the temporary padding file in case of an error to force the
     // next action recalculate the padding size.
-    CACHE_TRY(aCommitHook());
+    QM_TRY(aCommitHook());
 
     QM_TRY(QM_OR_ELSE_WARN(
         ToResult(DirectoryPaddingFinalizeWrite(aBaseDir)),
         ([&aBaseDir](const nsresult) -> Result<Ok, nsresult> {
           // Force restore file next time.
           Unused << DirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE);
 
           // Ensure that we are able to force the padding file