Bug 1168606 - Use const where easily possible. r=ttung,asuth
☠☠ backed out by e7e97d7a6a43 ☠ ☠
authorSimon Giesecke <sgiesecke@mozilla.com>
Tue, 01 Oct 2019 09:14:04 +0000
changeset 495849 9e7a90dcc429194fbe08e63aeed311ce100114cc
parent 495848 e493a6b5f1255b037a877eba744043265486cc8b
child 495850 f844afbebc6a667f758002a04d0149c646aae42b
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttung, asuth
bugs1168606
milestone71.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 1168606 - Use const where easily possible. r=ttung,asuth Differential Revision: https://phabricator.services.mozilla.com/D43631
dom/indexedDB/ActorsChild.cpp
dom/indexedDB/ActorsChild.h
dom/indexedDB/ActorsParent.cpp
dom/indexedDB/IDBCursor.cpp
dom/indexedDB/IDBCursor.h
dom/indexedDB/IDBIndex.cpp
dom/indexedDB/IDBObjectStore.cpp
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -184,17 +184,17 @@ class MOZ_STACK_CLASS AutoSetCurrentTran
       mThreadLocal->SetCurrentTransaction(mPreviousTransaction);
     }
   }
 
   IDBTransaction* Transaction() const { return mTransaction; }
 };
 
 class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
-  IDBRequest* mRequest;
+  IDBRequest* const mRequest;
   AutoSetCurrentTransaction mAutoTransaction;
 
   union {
     IDBDatabase* mDatabase;
     IDBCursor* mCursor;
     IDBMutableFile* mMutableFile;
     StructuredCloneReadInfo* mStructuredClone;
     const nsTArray<StructuredCloneReadInfo>* mStructuredCloneArray;
@@ -367,28 +367,28 @@ class MOZ_STACK_CLASS ResultHelper final
                     nsresult>::Type
   GetResult(JSContext* aCx, T* aDOMObject,
             JS::MutableHandle<JS::Value> aResult) {
     if (!aDOMObject) {
       aResult.setNull();
       return NS_OK;
     }
 
-    bool ok = GetOrCreateDOMReflector(aCx, aDOMObject, aResult);
+    const bool ok = GetOrCreateDOMReflector(aCx, aDOMObject, aResult);
     if (NS_WARN_IF(!ok)) {
       IDB_REPORT_INTERNAL_ERR();
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     return NS_OK;
   }
 
   nsresult GetResult(JSContext* aCx, StructuredCloneReadInfo* aCloneInfo,
                      JS::MutableHandle<JS::Value> aResult) {
-    bool ok = IDBObjectStore::DeserializeValue(aCx, *aCloneInfo, aResult);
+    const bool ok = IDBObjectStore::DeserializeValue(aCx, *aCloneInfo, aResult);
 
     if (NS_WARN_IF(!ok)) {
       return NS_ERROR_DOM_DATA_CLONE_ERR;
     }
 
     return NS_OK;
   }
 
@@ -410,17 +410,17 @@ class MOZ_STACK_CLASS ResultHelper final
       }
 
       for (uint32_t index = 0; index < count; index++) {
         auto& cloneInfo =
             const_cast<StructuredCloneReadInfo&>(aCloneInfos->ElementAt(index));
 
         JS::Rooted<JS::Value> value(aCx);
 
-        nsresult rv = GetResult(aCx, &cloneInfo, &value);
+        const nsresult rv = GetResult(aCx, &cloneInfo, &value);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
         if (NS_WARN_IF(!JS_DefineElement(aCx, array, index, value,
                                          JSPROP_ENUMERATE))) {
           IDB_REPORT_INTERNAL_ERR();
           return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
@@ -429,17 +429,17 @@ class MOZ_STACK_CLASS ResultHelper final
     }
 
     aResult.setObject(*array);
     return NS_OK;
   }
 
   nsresult GetResult(JSContext* aCx, const Key* aKey,
                      JS::MutableHandle<JS::Value> aResult) {
-    nsresult rv = aKey->ToJSVal(aCx, aResult);
+    const nsresult rv = aKey->ToJSVal(aCx, aResult);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
 
   nsresult GetResult(JSContext* aCx, const nsTArray<Key>* aKeys,
                      JS::MutableHandle<JS::Value> aResult) {
@@ -458,17 +458,17 @@ class MOZ_STACK_CLASS ResultHelper final
       }
 
       for (uint32_t index = 0; index < count; index++) {
         const Key& key = aKeys->ElementAt(index);
         MOZ_ASSERT(!key.IsUnset());
 
         JS::Rooted<JS::Value> value(aCx);
 
-        nsresult rv = GetResult(aCx, &key, &value);
+        const nsresult rv = GetResult(aCx, &key, &value);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
         if (NS_WARN_IF(!JS_DefineElement(aCx, array, index, value,
                                          JSPROP_ENUMERATE))) {
           IDB_REPORT_INTERNAL_ERR();
           return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
@@ -494,17 +494,17 @@ class PermissionRequestMainProcessHelper
         mActor(aActor),
         mFactory(aFactory) {
     MOZ_ASSERT(aActor);
     MOZ_ASSERT(aFactory);
     aActor->AssertIsOnOwningThread();
   }
 
  protected:
-  ~PermissionRequestMainProcessHelper() {}
+  ~PermissionRequestMainProcessHelper() = default;
 
  private:
   virtual void OnPromptComplete(PermissionValue aPermissionValue) override;
 };
 
 void DeserializeStructuredCloneFiles(
     IDBDatabase* aDatabase,
     const nsTArray<SerializedStructuredCloneFile>& aSerializedFiles,
@@ -526,58 +526,58 @@ void DeserializeStructuredCloneFiles(
       const BlobOrMutableFile& blobOrMutableFile = serializedFile.file();
 
       switch (serializedFile.type()) {
         case StructuredCloneFile::eBlob: {
           MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::TIPCBlob);
 
           const IPCBlob& ipcBlob = blobOrMutableFile.get_IPCBlob();
 
-          RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
+          const RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
           MOZ_ASSERT(blobImpl);
 
           RefPtr<Blob> blob =
               Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
 
-          StructuredCloneFile* file = aFiles.AppendElement();
+          StructuredCloneFile* const file = aFiles.AppendElement();
           MOZ_ASSERT(file);
 
           file->mType = StructuredCloneFile::eBlob;
           file->mBlob.swap(blob);
 
           break;
         }
 
         case StructuredCloneFile::eMutableFile: {
           MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::Tnull_t ||
                      blobOrMutableFile.type() ==
                          BlobOrMutableFile::TPBackgroundMutableFileChild);
 
           switch (blobOrMutableFile.type()) {
             case BlobOrMutableFile::Tnull_t: {
-              StructuredCloneFile* file = aFiles.AppendElement();
+              StructuredCloneFile* const file = aFiles.AppendElement();
               MOZ_ASSERT(file);
 
               file->mType = StructuredCloneFile::eMutableFile;
 
               break;
             }
 
             case BlobOrMutableFile::TPBackgroundMutableFileChild: {
-              auto* actor = static_cast<BackgroundMutableFileChild*>(
+              auto* const actor = static_cast<BackgroundMutableFileChild*>(
                   blobOrMutableFile.get_PBackgroundMutableFileChild());
               MOZ_ASSERT(actor);
 
               actor->EnsureDOMObject();
 
-              auto* mutableFile =
+              auto* const mutableFile =
                   static_cast<IDBMutableFile*>(actor->GetDOMObject());
               MOZ_ASSERT(mutableFile);
 
-              StructuredCloneFile* file = aFiles.AppendElement();
+              StructuredCloneFile* const file = aFiles.AppendElement();
               MOZ_ASSERT(file);
 
               file->mType = StructuredCloneFile::eMutableFile;
               file->mMutableFile = mutableFile;
 
               actor->ReleaseDOMObject();
 
               break;
@@ -591,44 +591,45 @@ void DeserializeStructuredCloneFiles(
         }
 
         case StructuredCloneFile::eStructuredClone: {
           if (aForPreprocess) {
             MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::TIPCBlob);
 
             const IPCBlob& ipcBlob = blobOrMutableFile.get_IPCBlob();
 
-            RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
+            const RefPtr<BlobImpl> blobImpl =
+                IPCBlobUtils::Deserialize(ipcBlob);
             MOZ_ASSERT(blobImpl);
 
             RefPtr<Blob> blob =
                 Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
 
-            StructuredCloneFile* file = aFiles.AppendElement();
+            StructuredCloneFile* const file = aFiles.AppendElement();
             MOZ_ASSERT(file);
 
             file->mType = StructuredCloneFile::eStructuredClone;
             file->mBlob.swap(blob);
           } else {
             MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::Tnull_t);
 
-            StructuredCloneFile* file = aFiles.AppendElement();
+            StructuredCloneFile* const file = aFiles.AppendElement();
             MOZ_ASSERT(file);
 
             file->mType = StructuredCloneFile::eStructuredClone;
           }
 
           break;
         }
 
         case StructuredCloneFile::eWasmBytecode:
         case StructuredCloneFile::eWasmCompiled: {
           MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::Tnull_t);
 
-          StructuredCloneFile* file = aFiles.AppendElement();
+          StructuredCloneFile* const file = aFiles.AppendElement();
           MOZ_ASSERT(file);
 
           file->mType = serializedFile.type();
 
           // Don't set mBlob, support for storing WebAssembly.Modules has been
           // removed in bug 1469395. Support for de-serialization of
           // WebAssembly.Modules has been removed in bug 1561876. Full removal
           // is tracked in bug 1487479.
@@ -648,18 +649,18 @@ void DispatchErrorEvent(IDBRequest* aReq
                         Event* aEvent = nullptr) {
   MOZ_ASSERT(aRequest);
   aRequest->AssertIsOnOwningThread();
   MOZ_ASSERT(NS_FAILED(aErrorCode));
   MOZ_ASSERT(NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_DOM_INDEXEDDB);
 
   AUTO_PROFILER_LABEL("IndexedDB:DispatchErrorEvent", DOM);
 
-  RefPtr<IDBRequest> request = aRequest;
-  RefPtr<IDBTransaction> transaction = aTransaction;
+  const RefPtr<IDBRequest> request = aRequest;
+  const RefPtr<IDBTransaction> transaction = aTransaction;
 
   request->SetError(aErrorCode);
 
   RefPtr<Event> errorEvent;
   if (!aEvent) {
     // Make an error event and fire it at the target.
     errorEvent = CreateGenericEvent(request, nsDependentString(kErrorEventType),
                                     eDoesBubble, eCancelable);
@@ -681,51 +682,52 @@ void DispatchErrorEvent(IDBRequest* aReq
   } else {
     IDB_LOG_MARK_CHILD_REQUEST("Firing %s event with error 0x%x", "%s (0x%x)",
                                request->LoggingSerialNumber(),
                                IDB_LOG_STRINGIFY(aEvent, kErrorEventType),
                                aErrorCode);
   }
 
   IgnoredErrorResult rv;
-  bool doDefault = request->DispatchEvent(*aEvent, CallerType::System, rv);
+  const bool doDefault =
+      request->DispatchEvent(*aEvent, CallerType::System, rv);
   if (NS_WARN_IF(rv.Failed())) {
     return;
   }
 
   MOZ_ASSERT(!transaction || transaction->IsOpen() || transaction->IsAborted());
 
   // Do not abort the transaction here if this request is failed due to the
   // abortion of its transaction to ensure that the correct error cause of
   // the abort event be set in IDBTransaction::FireCompleteOrAbortEvents()
   // later.
   if (transaction && transaction->IsOpen() &&
       aErrorCode != NS_ERROR_DOM_INDEXEDDB_ABORT_ERR) {
-    WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
+    WidgetEvent* const internalEvent = aEvent->WidgetEventPtr();
     MOZ_ASSERT(internalEvent);
 
     if (internalEvent->mFlags.mExceptionWasRaised) {
       transaction->Abort(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
     } else if (doDefault) {
       transaction->Abort(request);
     }
   }
 }
 
 void DispatchSuccessEvent(ResultHelper* aResultHelper,
                           Event* aEvent = nullptr) {
   MOZ_ASSERT(aResultHelper);
 
   AUTO_PROFILER_LABEL("IndexedDB:DispatchSuccessEvent", DOM);
 
-  RefPtr<IDBRequest> request = aResultHelper->Request();
+  const RefPtr<IDBRequest> request = aResultHelper->Request();
   MOZ_ASSERT(request);
   request->AssertIsOnOwningThread();
 
-  RefPtr<IDBTransaction> transaction = aResultHelper->Transaction();
+  const RefPtr<IDBTransaction> transaction = aResultHelper->Transaction();
 
   if (transaction && transaction->IsAborted()) {
     DispatchErrorEvent(request, transaction->AbortCode(), transaction);
     return;
   }
 
   RefPtr<Event> successEvent;
   if (!aEvent) {
@@ -757,39 +759,39 @@ void DispatchSuccessEvent(ResultHelper* 
                 transaction->IsOpen() && !transaction->IsAborted());
 
   IgnoredErrorResult rv;
   request->DispatchEvent(*aEvent, rv);
   if (NS_WARN_IF(rv.Failed())) {
     return;
   }
 
-  WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
+  WidgetEvent* const internalEvent = aEvent->WidgetEventPtr();
   MOZ_ASSERT(internalEvent);
 
   if (transaction && transaction->IsOpen()) {
     if (internalEvent->mFlags.mExceptionWasRaised) {
       transaction->Abort(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
     } else {
       // To handle upgrade transaction.
       transaction->Run();
     }
   }
 }
 
 PRFileDesc* GetFileDescriptorFromStream(nsIInputStream* aStream) {
   MOZ_ASSERT(aStream);
 
-  nsCOMPtr<nsIFileMetadata> fileMetadata = do_QueryInterface(aStream);
+  const nsCOMPtr<nsIFileMetadata> fileMetadata = do_QueryInterface(aStream);
   if (NS_WARN_IF(!fileMetadata)) {
     return nullptr;
   }
 
   PRFileDesc* fileDesc;
-  nsresult rv = fileMetadata->GetFileDescriptor(&fileDesc);
+  const nsresult rv = fileMetadata->GetFileDescriptor(&fileDesc);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return nullptr;
   }
 
   MOZ_ASSERT(fileDesc);
 
   return fileDesc;
 }
@@ -860,27 +862,27 @@ class WorkerPermissionChallenge final : 
       return false;
     }
 
     return true;
   }
 
   NS_IMETHOD
   Run() override {
-    bool completed = RunInternal();
+    const bool completed = RunInternal();
     if (completed) {
       OperationCompleted();
     }
 
     return NS_OK;
   }
 
   void OperationCompleted() {
     if (NS_IsMainThread()) {
-      RefPtr<WorkerPermissionOperationCompleted> runnable =
+      const RefPtr<WorkerPermissionOperationCompleted> runnable =
           new WorkerPermissionOperationCompleted(mWorkerPrivate, this);
 
       MOZ_ALWAYS_TRUE(runnable->Dispatch());
       return;
     }
 
     MOZ_ASSERT(mActor);
     mActor->AssertIsOnOwningThread();
@@ -902,30 +904,30 @@ class WorkerPermissionChallenge final : 
     MOZ_ASSERT(NS_IsMainThread());
 
     // Walk up to our containing page
     WorkerPrivate* wp = mWorkerPrivate;
     while (wp->GetParent()) {
       wp = wp->GetParent();
     }
 
-    nsPIDOMWindowInner* window = wp->GetWindow();
+    nsPIDOMWindowInner* const window = wp->GetWindow();
     if (!window) {
       return true;
     }
 
     nsresult rv;
-    nsCOMPtr<nsIPrincipal> principal =
+    const nsCOMPtr<nsIPrincipal> principal =
         mozilla::ipc::PrincipalInfoToPrincipal(mPrincipalInfo, &rv);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return true;
     }
 
     if (XRE_IsParentProcess()) {
-      nsCOMPtr<Element> ownerElement =
+      const nsCOMPtr<Element> ownerElement =
           do_QueryInterface(window->GetChromeEventHandler());
       if (NS_WARN_IF(!ownerElement)) {
         return true;
       }
 
       RefPtr<WorkerPermissionRequest> helper =
           new WorkerPermissionRequest(ownerElement, principal, this);
 
@@ -951,20 +953,20 @@ class WorkerPermissionChallenge final : 
         ->Then(
             GetCurrentThreadSerialEventTarget(), __func__,
             [self](const uint32_t& aPermission) { self->OperationCompleted(); },
             [](const mozilla::ipc::ResponseRejectReason) {});
     return false;
   }
 
  private:
-  WorkerPrivate* mWorkerPrivate;
+  WorkerPrivate* const mWorkerPrivate;
   BackgroundFactoryRequestChild* mActor;
   RefPtr<IDBFactory> mFactory;
-  PrincipalInfo mPrincipalInfo;
+  const PrincipalInfo mPrincipalInfo;
 };
 
 void WorkerPermissionRequest::OnPromptComplete(
     PermissionValue aPermissionValue) {
   MOZ_ASSERT(NS_IsMainThread());
   mChallenge->OperationCompleted();
 }
 
@@ -1013,17 +1015,17 @@ class MOZ_STACK_CLASS AutoSetCurrentFile
     }
   }
 
   IDBFileHandle* FileHandle() const { return mFileHandle; }
 };
 
 class MOZ_STACK_CLASS FileHandleResultHelper final
     : public IDBFileRequest::ResultCallback {
-  IDBFileRequest* mFileRequest;
+  IDBFileRequest* const mFileRequest;
   AutoSetCurrentFileHandle mAutoFileHandle;
 
   union {
     File* mFile;
     const nsCString* mString;
     const FileRequestMetadata* mMetadata;
     const JS::Handle<JS::Value>* mJSValHandle;
   } mResult;
@@ -1114,17 +1116,17 @@ class MOZ_STACK_CLASS FileHandleResultHe
     }
 
     MOZ_CRASH("Should never get here!");
   }
 
  private:
   nsresult GetResult(JSContext* aCx, File* aFile,
                      JS::MutableHandle<JS::Value> aResult) {
-    bool ok = GetOrCreateDOMReflector(aCx, aFile, aResult);
+    const bool ok = GetOrCreateDOMReflector(aCx, aFile, aResult);
     if (NS_WARN_IF(!ok)) {
       return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
     }
 
     return NS_OK;
   }
 
   nsresult GetResult(JSContext* aCx, const nsCString* aString,
@@ -1198,69 +1200,69 @@ class MOZ_STACK_CLASS FileHandleResultHe
 
     aResult.setObject(*obj);
     return NS_OK;
   }
 };
 
 already_AddRefed<File> ConvertActorToFile(
     IDBFileHandle* aFileHandle, const FileRequestGetFileResponse& aResponse) {
-  auto* actor = static_cast<PendingIPCBlobChild*>(aResponse.fileChild());
+  auto* const actor = static_cast<PendingIPCBlobChild*>(aResponse.fileChild());
 
   IDBMutableFile* mutableFile = aFileHandle->GetMutableFile();
   MOZ_ASSERT(mutableFile);
 
   const FileRequestMetadata& metadata = aResponse.metadata();
 
   const Maybe<uint64_t>& size = metadata.size();
   MOZ_ASSERT(size.isSome());
 
   const Maybe<int64_t>& lastModified = metadata.lastModified();
   MOZ_ASSERT(lastModified.isSome());
 
-  RefPtr<BlobImpl> blobImpl = actor->SetPendingInfoAndDeleteActor(
+  const RefPtr<BlobImpl> blobImpl = actor->SetPendingInfoAndDeleteActor(
       mutableFile->Name(), mutableFile->Type(), size.value(),
       lastModified.value());
   MOZ_ASSERT(blobImpl);
 
-  RefPtr<BlobImpl> blobImplSnapshot =
+  const RefPtr<BlobImpl> blobImplSnapshot =
       new BlobImplSnapshot(blobImpl, static_cast<IDBFileHandle*>(aFileHandle));
 
   RefPtr<File> file =
       File::Create(mutableFile->GetOwnerGlobal(), blobImplSnapshot);
   return file.forget();
 }
 
 void DispatchFileHandleErrorEvent(IDBFileRequest* aFileRequest,
                                   nsresult aErrorCode,
                                   IDBFileHandle* aFileHandle) {
   MOZ_ASSERT(aFileRequest);
   aFileRequest->AssertIsOnOwningThread();
   MOZ_ASSERT(NS_FAILED(aErrorCode));
   MOZ_ASSERT(NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_DOM_FILEHANDLE);
   MOZ_ASSERT(aFileHandle);
 
-  RefPtr<IDBFileRequest> fileRequest = aFileRequest;
-  RefPtr<IDBFileHandle> fileHandle = aFileHandle;
+  const RefPtr<IDBFileRequest> fileRequest = aFileRequest;
+  const RefPtr<IDBFileHandle> fileHandle = aFileHandle;
 
   AutoSetCurrentFileHandle ascfh(aFileHandle);
 
   fileRequest->FireError(aErrorCode);
 
   MOZ_ASSERT(fileHandle->IsOpen() || fileHandle->IsAborted());
 }
 
 void DispatchFileHandleSuccessEvent(FileHandleResultHelper* aResultHelper) {
   MOZ_ASSERT(aResultHelper);
 
-  RefPtr<IDBFileRequest> fileRequest = aResultHelper->FileRequest();
+  const RefPtr<IDBFileRequest> fileRequest = aResultHelper->FileRequest();
   MOZ_ASSERT(fileRequest);
   fileRequest->AssertIsOnOwningThread();
 
-  RefPtr<IDBFileHandle> fileHandle = aResultHelper->FileHandle();
+  const RefPtr<IDBFileHandle> fileHandle = aResultHelper->FileHandle();
   MOZ_ASSERT(fileHandle);
 
   if (fileHandle->IsAborted()) {
     fileRequest->FireError(NS_ERROR_DOM_FILEHANDLE_ABORT_ERR);
     return;
   }
 
   MOZ_ASSERT(fileHandle->IsOpen());
@@ -1293,23 +1295,23 @@ class BackgroundRequestChild::Preprocess
 
     // Waiting to finish/finishing on the owning thread. Next step is Completed.
     Finishing,
 
     // All done.
     Completed
   };
 
-  nsCOMPtr<nsIEventTarget> mOwningEventTarget;
+  const nsCOMPtr<nsIEventTarget> mOwningEventTarget;
   RefPtr<TaskQueue> mTaskQueue;
   nsCOMPtr<nsIEventTarget> mTaskQueueEventTarget;
   nsCOMPtr<nsIInputStream> mStream;
   UniquePtr<JSStructuredCloneData> mCloneData;
   BackgroundRequestChild* mActor;
-  uint32_t mCloneDataIndex;
+  const uint32_t mCloneDataIndex;
   nsresult mResultCode;
   State mState;
 
  public:
   PreprocessHelper(uint32_t aCloneDataIndex, BackgroundRequestChild* aActor)
       : CancelableRunnable(
             "indexedDB::BackgroundRequestChild::PreprocessHelper"),
         mOwningEventTarget(aActor->GetActorEventTarget()),
@@ -1464,17 +1466,17 @@ bool BackgroundFactoryChild::DeallocPBac
   return true;
 }
 
 PBackgroundIDBDatabaseChild*
 BackgroundFactoryChild::AllocPBackgroundIDBDatabaseChild(
     const DatabaseSpec& aSpec, PBackgroundIDBFactoryRequestChild* aRequest) {
   AssertIsOnOwningThread();
 
-  auto request = static_cast<BackgroundFactoryRequestChild*>(aRequest);
+  auto* const request = static_cast<BackgroundFactoryRequestChild*>(aRequest);
   MOZ_ASSERT(request);
 
   return new BackgroundDatabaseChild(aSpec, request);
 }
 
 bool BackgroundFactoryChild::DeallocPBackgroundIDBDatabaseChild(
     PBackgroundIDBDatabaseChild* aActor) {
   MOZ_ASSERT(aActor);
--- a/dom/indexedDB/ActorsChild.h
+++ b/dom/indexedDB/ActorsChild.h
@@ -205,17 +205,17 @@ class BackgroundFactoryRequestChild fina
   typedef mozilla::dom::quota::PersistenceType PersistenceType;
 
   friend IDBFactory;
   friend class BackgroundFactoryChild;
   friend class BackgroundDatabaseChild;
   friend class PermissionRequestChild;
   friend class PermissionRequestParent;
 
-  RefPtr<IDBFactory> mFactory;
+  const RefPtr<IDBFactory> mFactory;
 
   // Normally when opening of a database is successful, we receive a database
   // actor in request response, so we can use it to call ReleaseDOMObject()
   // which clears temporary strong reference to IDBDatabase.
   // However, when there's an error, we don't receive a database actor and
   // IDBRequest::mTransaction is already cleared (must be). So the only way how
   // to call ReleaseDOMObject() is to have a back-reference to database actor.
   // This creates a weak ref cycle between
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -556,18 +556,18 @@ struct IndexDataValue final {
     return mIndexId < aOther.mIndexId;
   }
 };
 
 /*******************************************************************************
  * SQLite functions
  ******************************************************************************/
 
-int32_t MakeSchemaVersion(uint32_t aMajorSchemaVersion,
-                          uint32_t aMinorSchemaVersion) {
+constexpr int32_t MakeSchemaVersion(uint32_t aMajorSchemaVersion,
+                                    uint32_t aMinorSchemaVersion) {
   return int32_t((aMajorSchemaVersion << 4) + aMinorSchemaVersion);
 }
 
 // WARNING: the hash function used for the database name must not change.
 // That's why this function exists separately from mozilla::HashString(), even
 // though it is (at the time of writing) equivalent. See bug 780408 and bug
 // 940315 for details.
 uint32_t HashName(const nsAString& aName) {
@@ -666,17 +666,17 @@ uint32_t CompressedByteCountForIndexId(i
 
 void WriteCompressedNumber(uint64_t aNumber, uint8_t** aIterator) {
   MOZ_ASSERT(aIterator);
   MOZ_ASSERT(*aIterator);
 
   uint8_t*& buffer = *aIterator;
 
 #ifdef DEBUG
-  const uint8_t* bufferStart = buffer;
+  const uint8_t* const bufferStart = buffer;
   const uint64_t originalNumber = aNumber;
 #endif
 
   while (true) {
     uint64_t shiftedNumber = aNumber >> 7;
     if (shiftedNumber) {
       *buffer++ = uint8_t(0x80 | (aNumber & 0x7f));
       aNumber = shiftedNumber;
@@ -852,17 +852,17 @@ nsresult ReadCompressedIndexDataValuesFr
   AUTO_PROFILER_LABEL("ReadCompressedIndexDataValuesFromBlob", DOM);
 
   if (uintptr_t(aBlobData) > UINTPTR_MAX - aBlobDataLength) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_FILE_CORRUPTED;
   }
 
   const uint8_t* blobDataIter = aBlobData;
-  const uint8_t* blobDataEnd = aBlobData + aBlobDataLength;
+  const uint8_t* const blobDataEnd = aBlobData + aBlobDataLength;
 
   while (blobDataIter < blobDataEnd) {
     int64_t indexId;
     bool unique;
     ReadCompressedIndexId(&blobDataIter, blobDataEnd, &indexId, &unique);
 
     if (NS_WARN_IF(blobDataIter == blobDataEnd)) {
       IDB_REPORT_INTERNAL_ERR();
@@ -3574,17 +3574,17 @@ nsresult UpgradeIndexDataValuesFunction:
     nsTArray<IndexDataValue>& aIndexValues) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aBlobData);
   MOZ_ASSERT(aBlobDataLength);
   MOZ_ASSERT(aIndexValues.IsEmpty());
 
   const uint8_t* blobDataIter = aBlobData;
-  const uint8_t* blobDataEnd = aBlobData + aBlobDataLength;
+  const uint8_t* const blobDataEnd = aBlobData + aBlobDataLength;
 
   int64_t indexId;
   bool unique;
   bool nextIndexIdAlreadyRead = false;
 
   while (blobDataIter < blobDataEnd) {
     if (!nextIndexIdAlreadyRead) {
       ReadCompressedIndexId(&blobDataIter, blobDataEnd, &indexId, &unique);
@@ -4146,17 +4146,17 @@ nsresult OpenDatabaseAndHandleBusy(mozIS
           "seconds",
           path.get());
       NS_WARNING(message.get());
     }
 #endif
 
     // Another thread must be checkpointing the WAL. Wait up to 10 seconds for
     // that to complete.
-    TimeStamp start = TimeStamp::NowLoRes();
+    const TimeStamp start = TimeStamp::NowLoRes();
 
     while (true) {
       PR_Sleep(PR_MillisecondsToInterval(100));
 
       rv = StorageOpenTraits<FileOrURLType>::Open(aStorageService, aFileOrURL,
                                                   getter_AddRefs(connection));
       if (rv != NS_ERROR_STORAGE_BUSY ||
           TimeStamp::NowLoRes() - start > TimeDuration::FromSeconds(10)) {
@@ -4366,67 +4366,90 @@ nsresult CreateStorageConnection(nsIFile
         return rv;
       }
     } else {
       // This logic needs to change next time we change the schema!
       static_assert(kSQLiteSchemaVersion == int32_t((26 << 4) + 0),
                     "Upgrade function needed due to schema version increase.");
 
       while (schemaVersion != kSQLiteSchemaVersion) {
-        if (schemaVersion == 4) {
-          rv = UpgradeSchemaFrom4To5(connection);
-        } else if (schemaVersion == 5) {
-          rv = UpgradeSchemaFrom5To6(connection);
-        } else if (schemaVersion == 6) {
-          rv = UpgradeSchemaFrom6To7(connection);
-        } else if (schemaVersion == 7) {
-          rv = UpgradeSchemaFrom7To8(connection);
-        } else if (schemaVersion == 8) {
-          rv = UpgradeSchemaFrom8To9_0(connection);
-          vacuumNeeded = true;
-        } else if (schemaVersion == MakeSchemaVersion(9, 0)) {
-          rv = UpgradeSchemaFrom9_0To10_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(10, 0)) {
-          rv = UpgradeSchemaFrom10_0To11_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(11, 0)) {
-          rv = UpgradeSchemaFrom11_0To12_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(12, 0)) {
-          rv = UpgradeSchemaFrom12_0To13_0(connection, &vacuumNeeded);
-        } else if (schemaVersion == MakeSchemaVersion(13, 0)) {
-          rv = UpgradeSchemaFrom13_0To14_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(14, 0)) {
-          rv = UpgradeSchemaFrom14_0To15_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(15, 0)) {
-          rv = UpgradeSchemaFrom15_0To16_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(16, 0)) {
-          rv = UpgradeSchemaFrom16_0To17_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(17, 0)) {
-          rv = UpgradeSchemaFrom17_0To18_0(connection, aOrigin);
-          vacuumNeeded = true;
-        } else if (schemaVersion == MakeSchemaVersion(18, 0)) {
-          rv = UpgradeSchemaFrom18_0To19_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(19, 0)) {
-          rv = UpgradeSchemaFrom19_0To20_0(aFMDirectory, connection);
-        } else if (schemaVersion == MakeSchemaVersion(20, 0)) {
-          rv = UpgradeSchemaFrom20_0To21_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(21, 0)) {
-          rv = UpgradeSchemaFrom21_0To22_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(22, 0)) {
-          rv = UpgradeSchemaFrom22_0To23_0(connection, aOrigin);
-        } else if (schemaVersion == MakeSchemaVersion(23, 0)) {
-          rv = UpgradeSchemaFrom23_0To24_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(24, 0)) {
-          rv = UpgradeSchemaFrom24_0To25_0(connection);
-        } else if (schemaVersion == MakeSchemaVersion(25, 0)) {
-          rv = UpgradeSchemaFrom25_0To26_0(connection);
-        } else {
-          IDB_WARNING(
-              "Unable to open IndexedDB database, no upgrade path is "
-              "available!");
-          return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
+        switch (schemaVersion) {
+          case 4:
+            rv = UpgradeSchemaFrom4To5(connection);
+            break;
+          case 5:
+            rv = UpgradeSchemaFrom5To6(connection);
+            break;
+          case 6:
+            rv = UpgradeSchemaFrom6To7(connection);
+            break;
+          case 7:
+            rv = UpgradeSchemaFrom7To8(connection);
+            break;
+          case 8:
+            rv = UpgradeSchemaFrom8To9_0(connection);
+            vacuumNeeded = true;
+            break;
+          case MakeSchemaVersion(9, 0):
+            rv = UpgradeSchemaFrom9_0To10_0(connection);
+            break;
+          case MakeSchemaVersion(10, 0):
+            rv = UpgradeSchemaFrom10_0To11_0(connection);
+            break;
+          case MakeSchemaVersion(11, 0):
+            rv = UpgradeSchemaFrom11_0To12_0(connection);
+            break;
+          case MakeSchemaVersion(12, 0):
+            rv = UpgradeSchemaFrom12_0To13_0(connection, &vacuumNeeded);
+            break;
+          case MakeSchemaVersion(13, 0):
+            rv = UpgradeSchemaFrom13_0To14_0(connection);
+            break;
+          case MakeSchemaVersion(14, 0):
+            rv = UpgradeSchemaFrom14_0To15_0(connection);
+            break;
+          case MakeSchemaVersion(15, 0):
+            rv = UpgradeSchemaFrom15_0To16_0(connection);
+            break;
+          case MakeSchemaVersion(16, 0):
+            rv = UpgradeSchemaFrom16_0To17_0(connection);
+            break;
+          case MakeSchemaVersion(17, 0):
+            rv = UpgradeSchemaFrom17_0To18_0(connection, aOrigin);
+            vacuumNeeded = true;
+            break;
+          case MakeSchemaVersion(18, 0):
+            rv = UpgradeSchemaFrom18_0To19_0(connection);
+            break;
+          case MakeSchemaVersion(19, 0):
+            rv = UpgradeSchemaFrom19_0To20_0(aFMDirectory, connection);
+            break;
+          case MakeSchemaVersion(20, 0):
+            rv = UpgradeSchemaFrom20_0To21_0(connection);
+            break;
+          case MakeSchemaVersion(21, 0):
+            rv = UpgradeSchemaFrom21_0To22_0(connection);
+            break;
+          case MakeSchemaVersion(22, 0):
+            rv = UpgradeSchemaFrom22_0To23_0(connection, aOrigin);
+            break;
+          case MakeSchemaVersion(23, 0):
+            rv = UpgradeSchemaFrom23_0To24_0(connection);
+            break;
+          case MakeSchemaVersion(24, 0):
+            rv = UpgradeSchemaFrom24_0To25_0(connection);
+            break;
+          case MakeSchemaVersion(25, 0):
+            rv = UpgradeSchemaFrom25_0To26_0(connection);
+            break;
+          default:
+            IDB_WARNING(
+                "Unable to open IndexedDB database, no upgrade path is "
+                "available!");
+            return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
         }
 
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
         rv = connection->GetSchemaVersion(&schemaVersion);
         if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -9256,16 +9279,33 @@ const CommonOpenCursorParams& GetCommonO
     case OpenCursorParams::TIndexOpenCursorParams:
     case OpenCursorParams::TIndexOpenKeyCursorParams:
       return GetCommonIndexOpenCursorParams(aParams).commonParams();
     default:
       MOZ_CRASH("Should never get here!");
   }
 }
 
+// TODO: Using nsCString as a return type here seems to lead to a dependency on
+// some temporaries, which I did not expect. Is it a good idea that the default
+// operator+ behaviour constructs such strings? It is certainly useful as an
+// optimization, but this should be better done via an appropriately named
+// function rather than an operator.
+nsAutoCString MakeColumnPairSelectionList(
+    const nsLiteralCString& aPlainColumnName,
+    const nsLiteralCString& aLocaleAwareColumnName,
+    const nsLiteralCString& aSortColumnAlias, const bool aIsLocaleAware) {
+  return aPlainColumnName +
+         (aIsLocaleAware ? EmptyCString()
+                         : NS_LITERAL_CSTRING(" as ") + aSortColumnAlias) +
+         NS_LITERAL_CSTRING(", ") + aLocaleAwareColumnName +
+         (aIsLocaleAware ? NS_LITERAL_CSTRING(" as ") + aSortColumnAlias
+                         : EmptyCString());
+}
+
 constexpr bool IsIncreasingOrder(const IDBCursor::Direction aDirection) {
   MOZ_ASSERT(
       aDirection == IDBCursor::NEXT || aDirection == IDBCursor::NEXT_UNIQUE ||
       aDirection == IDBCursor::PREV || aDirection == IDBCursor::PREV_UNIQUE);
 
   return aDirection == IDBCursor::NEXT || aDirection == IDBCursor::NEXT_UNIQUE;
 }
 
@@ -9573,17 +9613,17 @@ nsresult DatabaseConnection::BeginWriteT
   rv = beginStmt->Execute();
   if (rv == NS_ERROR_STORAGE_BUSY) {
     NS_WARNING(
         "Received NS_ERROR_STORAGE_BUSY when attempting to start write "
         "transaction, retrying for up to 10 seconds");
 
     // Another thread must be using the database. Wait up to 10 seconds for
     // that to complete.
-    TimeStamp start = TimeStamp::NowLoRes();
+    const TimeStamp start = TimeStamp::NowLoRes();
 
     while (true) {
       PR_Sleep(PR_MillisecondsToInterval(100));
 
       rv = beginStmt->Execute();
       if (rv != NS_ERROR_STORAGE_BUSY ||
           TimeStamp::NowLoRes() - start > TimeDuration::FromSeconds(10)) {
         break;
@@ -10415,17 +10455,17 @@ void DatabaseConnection::UpdateRefcountF
       }
 
       rv = file->Remove(false);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       if (aFileManager->EnforcingQuota()) {
-        QuotaManager* quotaManager = QuotaManager::Get();
+        QuotaManager* const quotaManager = QuotaManager::Get();
         MOZ_ASSERT(quotaManager);
 
         quotaManager->DecreaseUsageForOrigin(
             aFileManager->Type(), aFileManager->Group(), aFileManager->Origin(),
             Client::IDB, fileSize);
       }
 
       file = FileManager::GetFileForId(mJournalDirectory, aId);
@@ -14079,37 +14119,38 @@ bool TransactionBase::StartRequest(PBack
     op->Cleanup();
     return false;
   }
 
   op->DispatchToConnectionPool();
   return true;
 }
 
-bool TransactionBase::DeallocRequest(PBackgroundIDBRequestParent* aActor) {
+bool TransactionBase::DeallocRequest(
+    PBackgroundIDBRequestParent* const aActor) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
 
   // Transfer ownership back from IPDL.
-  RefPtr<NormalTransactionOp> actor =
+  const RefPtr<NormalTransactionOp> actor =
       dont_AddRef(static_cast<NormalTransactionOp*>(aActor));
   return true;
 }
 
 PBackgroundIDBCursorParent* TransactionBase::AllocCursor(
     const OpenCursorParams& aParams, bool aTrustParams) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aParams.type() != OpenCursorParams::T__None);
 
 #ifdef DEBUG
   // Always verify parameters in DEBUG builds!
   aTrustParams = false;
 #endif
 
-  OpenCursorParams::Type type = aParams.type();
+  const OpenCursorParams::Type type = aParams.type();
   RefPtr<FullObjectStoreMetadata> objectStoreMetadata;
   RefPtr<FullIndexMetadata> indexMetadata;
   Cursor::Direction direction;
 
   // First extract the parameters common to all open cursor variants.
   const auto& commonParams = GetCommonOpenCursorParams(aParams);
   objectStoreMetadata =
       GetMetadataForObjectStoreId(commonParams.objectStoreId());
@@ -14143,37 +14184,37 @@ PBackgroundIDBCursorParent* TransactionB
 
   // Create Cursor and transfer ownership to IPDL.
   return MakeAndAddRef<Cursor>(this, type, std::move(objectStoreMetadata),
                                std::move(indexMetadata), direction,
                                Cursor::ConstructFromTransactionBase{})
       .take();
 }
 
-bool TransactionBase::StartCursor(PBackgroundIDBCursorParent* aActor,
+bool TransactionBase::StartCursor(PBackgroundIDBCursorParent* const aActor,
                                   const OpenCursorParams& aParams) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
   MOZ_ASSERT(aParams.type() != OpenCursorParams::T__None);
 
-  auto* op = static_cast<Cursor*>(aActor);
+  auto* const op = static_cast<Cursor*>(aActor);
 
   if (NS_WARN_IF(!op->Start(aParams))) {
     return false;
   }
 
   return true;
 }
 
-bool TransactionBase::DeallocCursor(PBackgroundIDBCursorParent* aActor) {
+bool TransactionBase::DeallocCursor(PBackgroundIDBCursorParent* const aActor) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
 
   // Transfer ownership back from IPDL.
-  RefPtr<Cursor> actor = dont_AddRef(static_cast<Cursor*>(aActor));
+  const RefPtr<Cursor> actor = dont_AddRef(static_cast<Cursor*>(aActor));
   return true;
 }
 
 /*******************************************************************************
  * NormalTransaction
  ******************************************************************************/
 
 NormalTransaction::NormalTransaction(
@@ -14184,17 +14225,17 @@ NormalTransaction::NormalTransaction(
   MOZ_ASSERT(!aObjectStores.IsEmpty());
 
   mObjectStores.SwapElements(aObjectStores);
 }
 
 bool NormalTransaction::IsSameProcessActor() {
   AssertIsOnBackgroundThread();
 
-  PBackgroundParent* actor = Manager()->Manager()->Manager();
+  PBackgroundParent* const actor = Manager()->Manager()->Manager();
   MOZ_ASSERT(actor);
 
   return !BackgroundParent::IsOtherProcessActor(actor);
 }
 
 void NormalTransaction::SendCompleteNotification(nsresult aResult) {
   AssertIsOnBackgroundThread();
 
@@ -14219,17 +14260,17 @@ void NormalTransaction::ActorDestroy(Act
     MaybeCommitOrAbort();
   }
 }
 
 mozilla::ipc::IPCResult NormalTransaction::RecvDeleteMe() {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(!IsActorDestroyed());
 
-  IProtocol* mgr = Manager();
+  IProtocol* const mgr = Manager();
   if (!PBackgroundIDBTransactionParent::Send__delete__(this)) {
     return IPC_FAIL_NO_REASON(mgr);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult NormalTransaction::RecvCommit() {
   AssertIsOnBackgroundThread();
@@ -14255,56 +14296,56 @@ NormalTransaction::AllocPBackgroundIDBRe
     const RequestParams& aParams) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aParams.type() != RequestParams::T__None);
 
   return AllocRequest(aParams, IsSameProcessActor());
 }
 
 mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBRequestConstructor(
-    PBackgroundIDBRequestParent* aActor, const RequestParams& aParams) {
+    PBackgroundIDBRequestParent* const aActor, const RequestParams& aParams) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
   MOZ_ASSERT(aParams.type() != RequestParams::T__None);
 
   if (!StartRequest(aActor)) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
 bool NormalTransaction::DeallocPBackgroundIDBRequestParent(
-    PBackgroundIDBRequestParent* aActor) {
+    PBackgroundIDBRequestParent* const aActor) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
 
   return DeallocRequest(aActor);
 }
 
 PBackgroundIDBCursorParent* NormalTransaction::AllocPBackgroundIDBCursorParent(
     const OpenCursorParams& aParams) {
   AssertIsOnBackgroundThread();
 
   return AllocCursor(aParams, IsSameProcessActor());
 }
 
 mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBCursorConstructor(
-    PBackgroundIDBCursorParent* aActor, const OpenCursorParams& aParams) {
+    PBackgroundIDBCursorParent* const aActor, const OpenCursorParams& aParams) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
   MOZ_ASSERT(aParams.type() != OpenCursorParams::T__None);
 
   if (!StartCursor(aActor, aParams)) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
 bool NormalTransaction::DeallocPBackgroundIDBCursorParent(
-    PBackgroundIDBCursorParent* aActor) {
+    PBackgroundIDBCursorParent* const aActor) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
 
   return DeallocCursor(aActor);
 }
 
 /*******************************************************************************
  * VersionChangeTransaction
@@ -14948,20 +14989,21 @@ bool VersionChangeTransaction::DeallocPB
 
   return DeallocCursor(aActor);
 }
 
 /*******************************************************************************
  * Cursor
  ******************************************************************************/
 
-Cursor::Cursor(RefPtr<TransactionBase> aTransaction, Type aType,
+Cursor::Cursor(RefPtr<TransactionBase> aTransaction, const Type aType,
                RefPtr<FullObjectStoreMetadata> aObjectStoreMetadata,
-               RefPtr<FullIndexMetadata> aIndexMetadata, Direction aDirection,
-               ConstructFromTransactionBase /*aConstructionTag*/)
+               RefPtr<FullIndexMetadata> aIndexMetadata,
+               const Direction aDirection,
+               const ConstructFromTransactionBase /*aConstructionTag*/)
     : mTransaction(std::move(aTransaction)),
       mDatabase(!IsKeyCursor(aType) ? mTransaction->GetDatabase() : nullptr),
       mFileManager(!IsKeyCursor(aType) ? mDatabase->GetFileManager() : nullptr),
       mBackgroundParent(
           !IsKeyCursor(aType) ? mTransaction->GetBackgroundParent() : nullptr),
       mObjectStoreMetadata(std::move(aObjectStoreMetadata)),
       mIndexMetadata(std::move(aIndexMetadata)),
       mObjectStoreId(mObjectStoreMetadata->mCommonMetadata.id()),
@@ -15000,28 +15042,28 @@ bool Cursor::VerifyRequestParams(const C
   MOZ_ASSERT(aParams.type() != CursorRequestParams::T__None);
   MOZ_ASSERT(mObjectStoreMetadata);
   MOZ_ASSERT_IF(mType == OpenCursorParams::TIndexOpenCursorParams ||
                     mType == OpenCursorParams::TIndexOpenKeyCursorParams,
                 mIndexMetadata);
 
 #ifdef DEBUG
   {
-    RefPtr<FullObjectStoreMetadata> objectStoreMetadata =
+    const RefPtr<FullObjectStoreMetadata> objectStoreMetadata =
         mTransaction->GetMetadataForObjectStoreId(mObjectStoreId);
     if (objectStoreMetadata) {
       MOZ_ASSERT(objectStoreMetadata == mObjectStoreMetadata);
     } else {
       MOZ_ASSERT(mObjectStoreMetadata->mDeleted);
     }
 
     if (objectStoreMetadata &&
         (mType == OpenCursorParams::TIndexOpenCursorParams ||
          mType == OpenCursorParams::TIndexOpenKeyCursorParams)) {
-      RefPtr<FullIndexMetadata> indexMetadata =
+      const RefPtr<FullIndexMetadata> indexMetadata =
           mTransaction->GetMetadataForIndexId(objectStoreMetadata, mIndexId);
       if (indexMetadata) {
         MOZ_ASSERT(indexMetadata == mIndexMetadata);
       } else {
         MOZ_ASSERT(mIndexMetadata->mDeleted);
       }
     }
   }
@@ -15116,17 +15158,17 @@ bool Cursor::Start(const OpenCursorParam
   if (NS_WARN_IF(mCurrentlyRunningOp)) {
     ASSERT_UNLESS_FUZZING();
     return false;
   }
 
   const Maybe<SerializedKeyRange>& optionalKeyRange =
       GetCommonOpenCursorParams(aParams).optionalKeyRange();
 
-  RefPtr<OpenOp> openOp = new OpenOp(this, optionalKeyRange);
+  const RefPtr<OpenOp> openOp = new OpenOp(this, optionalKeyRange);
 
   if (NS_WARN_IF(!openOp->Init(mTransaction))) {
     openOp->Cleanup();
     return false;
   }
 
   openOp->DispatchToConnectionPool();
   mCurrentlyRunningOp = openOp;
@@ -15198,17 +15240,17 @@ void Cursor::SendResponseInternal(
       MOZ_ASSERT(serializedInfo);
       MOZ_ASSERT(serializedInfo->files().IsEmpty());
 
       serializedInfo->files().SwapElements(serializedFiles);
     }
   }
 
   // Work around the deleted function by casting to the base class.
-  auto* base = static_cast<PBackgroundIDBCursorParent*>(this);
+  auto* const base = static_cast<PBackgroundIDBCursorParent*>(this);
   if (!base->SendResponse(aResponse)) {
     NS_WARNING("Failed to send response!");
   }
 
   mCurrentlyRunningOp = nullptr;
 }
 
 void Cursor::ActorDestroy(ActorDestroyReason aWhy) {
@@ -15276,17 +15318,17 @@ mozilla::ipc::IPCResult Cursor::RecvCont
     return IPC_FAIL_NO_REASON(this);
   }
 
   if (NS_WARN_IF(mTransaction->mCommitOrAbortReceived)) {
     ASSERT_UNLESS_FUZZING();
     return IPC_FAIL_NO_REASON(this);
   }
 
-  RefPtr<ContinueOp> continueOp = new ContinueOp(this, aParams);
+  const RefPtr<ContinueOp> continueOp = new ContinueOp(this, aParams);
   if (NS_WARN_IF(!continueOp->Init(mTransaction))) {
     continueOp->Cleanup();
     return IPC_FAIL_NO_REASON(this);
   }
 
   continueOp->DispatchToConnectionPool();
   mCurrentlyRunningOp = continueOp;
 
@@ -16428,17 +16470,18 @@ void QuotaClient::ShutdownTimedOut() {
       nsCString origin(factoryOp->Origin());
       SanitizeOrigin(origin);
 
       nsCString state;
       factoryOp->StringifyState(state);
 
       NS_NAMED_LITERAL_CSTRING(delimiter, "*");
 
-      nsCString id = persistenceType + delimiter + origin + delimiter + state;
+      const nsCString id =
+          persistenceType + delimiter + origin + delimiter + state;
 
       ids.PutEntry(id);
     }
 
     data.Append(" (");
 
     bool first = true;
     for (auto iter = ids.ConstIter(); !iter.Done(); iter.Next()) {
@@ -16471,17 +16514,17 @@ void QuotaClient::ShutdownTimedOut() {
 
   MOZ_CRASH("IndexedDB shutdown timed out");
 }
 
 void QuotaClient::DeleteTimerCallback(nsITimer* aTimer, void* aClosure) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aTimer);
 
-  auto* self = static_cast<QuotaClient*>(aClosure);
+  auto* const self = static_cast<QuotaClient*>(aClosure);
   MOZ_ASSERT(self);
   MOZ_ASSERT(self->mDeleteTimer);
   MOZ_ASSERT(SameCOMIdentity(self->mDeleteTimer, aTimer));
 
   for (auto iter = self->mPendingDeleteInfos.ConstIter(); !iter.Done();
        iter.Next()) {
     auto key = iter.Key();
     auto value = iter.Data();
@@ -16496,17 +16539,17 @@ void QuotaClient::DeleteTimerCallback(ns
   }
 
   self->mPendingDeleteInfos.Clear();
 }
 
 nsresult QuotaClient::GetDirectory(PersistenceType aPersistenceType,
                                    const nsACString& aOrigin,
                                    nsIFile** aDirectory) {
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   NS_ASSERTION(quotaManager, "This should never fail!");
 
   nsCOMPtr<nsIFile> directory;
   nsresult rv = quotaManager->GetDirectoryForOrigin(aPersistenceType, aOrigin,
                                                     getter_AddRefs(directory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -16592,19 +16635,20 @@ nsresult QuotaClient::GetDatabaseFilenam
     }
 
     nsDependentSubstring leafNameBase;
     if (!GetBaseFilename(leafName, sqliteSuffix, leafNameBase)) {
       nsString path;
       MOZ_ALWAYS_SUCCEEDS(file->GetPath(path));
       MOZ_ASSERT(!path.IsEmpty());
 
-      nsPrintfCString warning(R"(An unexpected file exists in the storage )"
-                              R"(area: "%s")",
-                              NS_ConvertUTF16toUTF8(path).get());
+      const nsPrintfCString warning(
+          R"(An unexpected file exists in the storage )"
+          R"(area: "%s")",
+          NS_ConvertUTF16toUTF8(path).get());
       NS_WARNING(warning.get());
       if (!aForUpgrade) {
         return NS_ERROR_UNEXPECTED;
       }
       continue;
     }
 
     aDatabaseFilenames.PutEntry(leafNameBase);
@@ -16747,17 +16791,17 @@ void DeleteFilesRunnable::RunImmediately
 
   Unused << this->Run();
 }
 
 nsresult DeleteFilesRunnable::Open() {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mState == State_Initial);
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   if (NS_WARN_IF(!quotaManager)) {
     return NS_ERROR_FAILURE;
   }
 
   mState = State_DirectoryOpenPending;
 
   quotaManager->OpenDirectory(mFileManager->Type(), mFileManager->Group(),
                               mFileManager->Origin(), quota::Client::IDB,
@@ -16780,17 +16824,17 @@ nsresult DeleteFilesRunnable::DeleteFile
     rv = file->GetFileSize(&fileSize);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
   }
 
   rv = file->Remove(false);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   if (mFileManager->EnforcingQuota()) {
-    QuotaManager* quotaManager = QuotaManager::Get();
+    QuotaManager* const quotaManager = QuotaManager::Get();
     NS_ASSERTION(quotaManager, "Shouldn't be null!");
 
     quotaManager->DecreaseUsageForOrigin(
         mFileManager->Type(), mFileManager->Group(), mFileManager->Origin(),
         Client::IDB, fileSize);
   }
 
   file = mFileManager->GetFileForId(mJournalDirectory, aFileId);
@@ -16879,17 +16923,17 @@ DeleteFilesRunnable::Run() {
 
 void DeleteFilesRunnable::DirectoryLockAcquired(DirectoryLock* aLock) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mState == State_DirectoryOpenPending);
   MOZ_ASSERT(!mDirectoryLock);
 
   mDirectoryLock = aLock;
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   // Must set this before dispatching otherwise we will race with the IO thread
   mState = State_DatabaseWorkOpen;
 
   nsresult rv = quotaManager->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     Finish();
@@ -16960,17 +17004,17 @@ nsresult Maintenance::CreateIndexedDatab
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == State::CreateIndexedDatabaseManager);
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
       IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
-  IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
+  IndexedDatabaseManager* const mgr = IndexedDatabaseManager::GetOrCreate();
   if (NS_WARN_IF(!mgr)) {
     return NS_ERROR_FAILURE;
   }
 
   mState = State::IndexedDatabaseManagerOpen;
   MOZ_ALWAYS_SUCCEEDS(
       mQuotaClient->BackgroundThread()->Dispatch(this, NS_DISPATCH_NORMAL));
 
@@ -17005,17 +17049,17 @@ nsresult Maintenance::DirectoryOpen() {
   MOZ_ASSERT(mState == State::DirectoryOpenPending);
   MOZ_ASSERT(mDirectoryLock);
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
       IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   mState = State::DirectoryWorkOpen;
 
   nsresult rv = quotaManager->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NS_ERROR_FAILURE;
   }
@@ -17034,25 +17078,26 @@ nsresult Maintenance::DirectoryWork() {
   // We have to find all database files that match any persistence type and any
   // origin. We ignore anything out of the ordinary for now.
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
       IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsresult rv = quotaManager->EnsureStorageIsInitialized();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  nsCOMPtr<nsIFile> storageDir = GetFileForPath(quotaManager->GetStoragePath());
+  const nsCOMPtr<nsIFile> storageDir =
+      GetFileForPath(quotaManager->GetStoragePath());
   if (NS_WARN_IF(!storageDir)) {
     return NS_ERROR_FAILURE;
   }
 
   bool exists;
   rv = storageDir->Exists(&exists);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -17348,20 +17393,19 @@ nsresult Maintenance::BeginDatabaseMaint
     return NS_ERROR_ABORT;
   }
 
   RefPtr<nsThreadPool> threadPool;
 
   for (DirectoryInfo& directoryInfo : mDirectoryInfos) {
     for (const nsString& databasePath : directoryInfo.mDatabasePaths) {
       if (Helper::IsSafeToRunMaintenance(databasePath)) {
-        RefPtr<DatabaseMaintenance> databaseMaintenance =
-            new DatabaseMaintenance(this, directoryInfo.mPersistenceType,
-                                    directoryInfo.mGroup, directoryInfo.mOrigin,
-                                    databasePath);
+        const auto databaseMaintenance = MakeRefPtr<DatabaseMaintenance>(
+            this, directoryInfo.mPersistenceType, directoryInfo.mGroup,
+            directoryInfo.mOrigin, databasePath);
 
         if (!threadPool) {
           threadPool = mQuotaClient->GetOrCreateThreadPool();
           MOZ_ASSERT(threadPool);
         }
 
         MOZ_ALWAYS_SUCCEEDS(
             threadPool->Dispatch(databaseMaintenance, NS_DISPATCH_NORMAL));
@@ -17393,17 +17437,17 @@ void Maintenance::Finish() {
 
     IDB_WARNING("Maintenance finished with error: %s", errorName.get());
   }
 
   mDirectoryLock = nullptr;
 
   // It can happen that we are only referenced by mCurrentMaintenance which is
   // cleared in NoteFinishedMaintenance()
-  RefPtr<Maintenance> kungFuDeathGrip = this;
+  const RefPtr<Maintenance> kungFuDeathGrip = this;
 
   mQuotaClient->NoteFinishedMaintenance(this);
 
   mState = State::Complete;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(Maintenance, Runnable)
 
@@ -17520,17 +17564,17 @@ void DatabaseMaintenance::PerformMainten
     }
   };
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
       mMaintenance->IsAborted()) {
     return;
   }
 
-  nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
+  const nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
   MOZ_ASSERT(databaseFile);
 
   nsCOMPtr<mozIStorageConnection> connection;
   nsresult rv = GetStorageConnection(databaseFile, mPersistenceType, mGroup,
                                      mOrigin, TelemetryIdForFile(databaseFile),
                                      getter_AddRefs(connection));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
@@ -17756,17 +17800,17 @@ nsresult DatabaseMaintenance::DetermineM
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   NS_ASSERTION(lastVacuumSize > 0,
                "Thy last vacuum size shall be greater than zero, less than "
                "zero shall thy last vacuum size not be. Zero is right out.");
 
-  PRTime startTime = mMaintenance->StartTime();
+  const PRTime startTime = mMaintenance->StartTime();
 
   // This shouldn't really be possible...
   if (NS_WARN_IF(startTime <= lastVacuumTime)) {
     *aMaintenanceAction = MaintenanceAction::Nothing;
     return NS_OK;
   }
 
   if (startTime - lastVacuumTime < kMinVacuumAge) {
@@ -18078,19 +18122,19 @@ DatabaseMaintenance::AutoProgressHandler
 NS_IMPL_ISUPPORTS(CompressDataBlobsFunction, mozIStorageFunction)
 NS_IMPL_ISUPPORTS(EncodeKeysFunction, mozIStorageFunction)
 NS_IMPL_ISUPPORTS(StripObsoleteOriginAttributesFunction, mozIStorageFunction);
 
 nsresult UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory,
                                       mozIStorageConnection* aConnection) {
   // This file manager doesn't need real origin info, etc. The only purpose is
   // to store file ids without adding more complexity or code duplication.
-  RefPtr<FileManager> fileManager =
-      new FileManager(PERSISTENCE_TYPE_INVALID, EmptyCString(), EmptyCString(),
-                      EmptyString(), false);
+  auto fileManager =
+      MakeRefPtr<FileManager>(PERSISTENCE_TYPE_INVALID, EmptyCString(),
+                              EmptyCString(), EmptyString(), false);
 
   nsresult rv = fileManager->Init(aFMDirectory, aConnection);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   mFileManager.swap(fileManager);
   return NS_OK;
@@ -18261,31 +18305,32 @@ nsresult DatabaseOperationBase::GetStruc
     StructuredCloneReadInfo* aInfo) {
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aFileManager);
   MOZ_ASSERT(aInfo);
 
   AUTO_PROFILER_LABEL(
       "DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob", DOM);
 
-  const char* compressed = reinterpret_cast<const char*>(aBlobData);
-  size_t compressedLength = size_t(aBlobDataLength);
+  const char* const compressed = reinterpret_cast<const char*>(aBlobData);
+  const size_t compressedLength = size_t(aBlobDataLength);
 
   size_t uncompressedLength;
   if (NS_WARN_IF(!snappy::GetUncompressedLength(compressed, compressedLength,
                                                 &uncompressedLength))) {
     return NS_ERROR_FILE_CORRUPTED;
   }
 
   AutoTArray<uint8_t, 512> uncompressed;
   if (NS_WARN_IF(!uncompressed.SetLength(uncompressedLength, fallible))) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  char* uncompressedBuffer = reinterpret_cast<char*>(uncompressed.Elements());
+  char* const uncompressedBuffer =
+      reinterpret_cast<char*>(uncompressed.Elements());
 
   if (NS_WARN_IF(!snappy::RawUncompress(compressed, compressedLength,
                                         uncompressedBuffer))) {
     return NS_ERROR_FILE_CORRUPTED;
   }
 
   if (!aInfo->mData.AppendBytes(uncompressedBuffer, uncompressed.Length())) {
     return NS_ERROR_OUT_OF_MEMORY;
@@ -18319,45 +18364,46 @@ nsresult DatabaseOperationBase::GetStruc
     rv = DeserializeStructuredCloneFiles(aFileManager, aFileIds, aInfo->mFiles);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // Higher and lower 32 bits described
   // in ObjectStoreAddOrPutRequestOp::DoDatabaseWork.
-  uint32_t index = uint32_t(aIntData & 0xFFFFFFFF);
+  const uint32_t index = uint32_t(aIntData & 0xFFFFFFFF);
 
   if (index >= aInfo->mFiles.Length()) {
     MOZ_ASSERT(false, "Bad index value!");
     return NS_ERROR_UNEXPECTED;
   }
 
   if (IndexedDatabaseManager::PreprocessingEnabled()) {
     aInfo->mHasPreprocessInfo = true;
     return NS_OK;
   }
 
   StructuredCloneFile& file = aInfo->mFiles[index];
   MOZ_ASSERT(file.mFileInfo);
   MOZ_ASSERT(file.mType == StructuredCloneFile::eStructuredClone);
 
-  nsCOMPtr<nsIFile> nativeFile = FileInfo::GetFileForFileInfo(file.mFileInfo);
+  const nsCOMPtr<nsIFile> nativeFile =
+      FileInfo::GetFileForFileInfo(file.mFileInfo);
   if (NS_WARN_IF(!nativeFile)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIInputStream> fileInputStream;
   rv = NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream), nativeFile);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  RefPtr<SnappyUncompressInputStream> snappyInputStream =
-      new SnappyUncompressInputStream(fileInputStream);
+  const auto snappyInputStream =
+      MakeRefPtr<SnappyUncompressInputStream>(fileInputStream);
 
   do {
     char buffer[kFileCopyBufferSize];
 
     uint32_t numRead;
     rv = snappyInputStream->Read(buffer, sizeof(buffer), &numRead);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       break;
@@ -18490,22 +18536,22 @@ nsresult DatabaseOperationBase::GetUniqu
   if (!objectStoreMetadata->mIndexes.Count()) {
     return NS_OK;
   }
 
   const uint32_t indexCount = objectStoreMetadata->mIndexes.Count();
   MOZ_ASSERT(indexCount > 0);
 
   aMaybeUniqueIndexTable.emplace();
-  UniqueIndexTable* uniqueIndexTable = aMaybeUniqueIndexTable.ptr();
+  UniqueIndexTable* const uniqueIndexTable = aMaybeUniqueIndexTable.ptr();
   MOZ_ASSERT(uniqueIndexTable);
 
   for (auto iter = objectStoreMetadata->mIndexes.Iter(); !iter.Done();
        iter.Next()) {
-    FullIndexMetadata* value = iter.UserData();
+    FullIndexMetadata* const value = iter.UserData();
     MOZ_ASSERT(!uniqueIndexTable->Get(value->mCommonMetadata.id()));
 
     if (NS_WARN_IF(!uniqueIndexTable->Put(value->mCommonMetadata.id(),
                                           value->mCommonMetadata.unique(),
                                           fallible))) {
       break;
     }
   }
@@ -19483,17 +19529,17 @@ nsresult FactoryOp::SendToIOThread() {
   MOZ_ASSERT(mState == State::DatabaseOpenPending);
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
       !OperationMayProceed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   // Must set this before dispatching otherwise we will race with the IO thread.
   mState = State::DatabaseWorkOpen;
 
   nsresult rv = quotaManager->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     IDB_REPORT_INTERNAL_ERR();
@@ -19798,17 +19844,17 @@ nsresult FactoryOp::OpenDirectory() {
   MOZ_ASSERT(!mDirectoryLock);
   MOZ_ASSERT(!QuotaClient::IsShuttingDownOnBackgroundThread());
   MOZ_ASSERT(QuotaManager::Get());
 
   // Need to get database file path in advance.
   const nsString& databaseName = mCommonParams.metadata().name();
   PersistenceType persistenceType = mCommonParams.metadata().persistenceType();
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsCOMPtr<nsIFile> dbFile;
   nsresult rv = quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin,
                                                     getter_AddRefs(dbFile));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -20074,17 +20120,17 @@ nsresult OpenDatabaseOp::DoDatabaseWork(
       !OperationMayProceed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   const nsString& databaseName = mCommonParams.metadata().name();
   PersistenceType persistenceType = mCommonParams.metadata().persistenceType();
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsCOMPtr<nsIFile> dbDirectory;
 
   nsresult rv = quotaManager->EnsureOriginIsInitialized(
       persistenceType, mSuffix, mGroup, mOrigin, getter_AddRefs(dbDirectory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -21411,17 +21457,17 @@ nsresult DeleteDatabaseOp::DoDatabaseWor
       !OperationMayProceed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   const nsString& databaseName = mCommonParams.metadata().name();
   PersistenceType persistenceType = mCommonParams.metadata().persistenceType();
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsCOMPtr<nsIFile> directory;
   nsresult rv = quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin,
                                                     getter_AddRefs(directory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -21531,17 +21577,17 @@ nsresult DeleteDatabaseOp::DispatchToWor
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   mState = State::DatabaseWorkVersionChange;
 
   RefPtr<VersionChangeOp> versionChangeOp = new VersionChangeOp(this);
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsresult rv = quotaManager->IOThread()->Dispatch(versionChangeOp.forget(),
                                                    NS_DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
@@ -22325,17 +22371,17 @@ nsresult DatabaseOp::SendToIOThread() {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State::Initial);
 
   if (!OperationMayProceed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   if (NS_WARN_IF(!quotaManager)) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   // Must set this before dispatching otherwise we will race with the IO thread.
   mState = State::DatabaseWork;
 
@@ -25603,17 +25649,18 @@ void Cursor::CursorOpBase::Cleanup() {
   // assertions happy.
   NoteActorDestroyed();
 #endif
 
   TransactionDatabaseOperationBase::Cleanup();
 }
 
 nsresult Cursor::CursorOpBase::PopulateResponseFromStatement(
-    DatabaseConnection::CachedStatement& aStmt, bool aInitializeResponse) {
+    DatabaseConnection::CachedStatement& aStmt,
+    const bool aInitializeResponse) {
   Transaction()->AssertIsOnConnectionThread();
   MOZ_ASSERT(mResponse.type() == CursorResponse::T__None);
   MOZ_ASSERT_IF(mFiles.IsEmpty(), aInitializeResponse);
 
   nsresult rv = mCursor->mPosition.SetFromStatement(aStmt, 0);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -25930,31 +25977,31 @@ nsresult Cursor::OpenOp::DoObjectStoreKe
   MOZ_ASSERT(mCursor->mType ==
              OpenCursorParams::TObjectStoreOpenKeyCursorParams);
   MOZ_ASSERT(mCursor->mObjectStoreId);
 
   AUTO_PROFILER_LABEL("Cursor::OpenOp::DoObjectStoreKeyDatabaseWork", DOM);
 
   const bool usingKeyRange = mOptionalKeyRange.isSome();
 
-  nsCString queryStart = NS_LITERAL_CSTRING("SELECT ") + kColumnNameKey +
-                         NS_LITERAL_CSTRING(
-                             " FROM object_data "
-                             "WHERE object_store_id = :") +
-                         kStmtParamNameId;
+  const nsCString queryStart = NS_LITERAL_CSTRING("SELECT ") + kColumnNameKey +
+                               NS_LITERAL_CSTRING(
+                                   " FROM object_data "
+                                   "WHERE object_store_id = :") +
+                               kStmtParamNameId;
 
   const auto keyRangeClause =
       MaybeGetBindingClauseForKeyRange(mOptionalKeyRange, kColumnNameKey);
 
   const auto& directionClause = MakeDirectionClause(mCursor->mDirection);
 
   // Note: Changing the number or order of SELECT columns in the query will
   // require changes to CursorOpBase::PopulateResponseFromStatement.
-  nsCString firstQuery = queryStart + keyRangeClause + directionClause +
-                         kOpenLimit + NS_LITERAL_CSTRING("1");
+  const nsCString firstQuery = queryStart + keyRangeClause + directionClause +
+                               kOpenLimit + NS_LITERAL_CSTRING("1");
 
   DatabaseConnection::CachedStatement stmt;
   nsresult rv = aConnection->GetCachedStatement(firstQuery, &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(kStmtParamNameId, mCursor->mObjectStoreId);
@@ -25998,32 +26045,29 @@ nsresult Cursor::OpenOp::DoIndexDatabase
   MOZ_ASSERT(mCursor->mType == OpenCursorParams::TIndexOpenCursorParams);
   MOZ_ASSERT(mCursor->mObjectStoreId);
   MOZ_ASSERT(mCursor->mIndexId);
 
   AUTO_PROFILER_LABEL("Cursor::OpenOp::DoIndexDatabaseWork", DOM);
 
   const bool usingKeyRange = mOptionalKeyRange.isSome();
 
-  nsCString indexTable = mCursor->mUniqueIndex
-                             ? NS_LITERAL_CSTRING("unique_index_data")
-                             : NS_LITERAL_CSTRING("index_data");
+  const auto& indexTable = mCursor->mUniqueIndex
+                               ? NS_LITERAL_CSTRING("unique_index_data")
+                               : NS_LITERAL_CSTRING("index_data");
 
   NS_NAMED_LITERAL_CSTRING(sortColumn, "sort_column");
 
-  nsAutoCString sortColumnAlias;
-  if (mCursor->IsLocaleAware()) {
-    sortColumnAlias =
-        "SELECT index_table.value, "
-        "index_table.value_locale as sort_column, ";
-  } else {
-    sortColumnAlias =
-        "SELECT index_table.value as sort_column, "
-        "index_table.value_locale, ";
-  }
+  const nsCString sortColumnAlias =
+      NS_LITERAL_CSTRING("SELECT ") +
+      MakeColumnPairSelectionList(
+          NS_LITERAL_CSTRING("index_table.value"),
+          NS_LITERAL_CSTRING("index_table.value_locale"), sortColumn,
+          mCursor->IsLocaleAware()) +
+      NS_LITERAL_CSTRING(", ");
 
   nsAutoCString queryStart = sortColumnAlias +
                              NS_LITERAL_CSTRING(
                                  "index_table.object_data_key, "
                                  "object_data.file_ids, "
                                  "object_data.data "
                                  "FROM ") +
                              indexTable +
@@ -26057,18 +26101,18 @@ nsresult Cursor::OpenOp::DoIndexDatabase
       break;
 
     default:
       MOZ_CRASH("Should never get here!");
   }
 
   // Note: Changing the number or order of SELECT columns in the query will
   // require changes to CursorOpBase::PopulateResponseFromStatement.
-  nsCString firstQuery = queryStart + keyRangeClause + directionClause +
-                         kOpenLimit + NS_LITERAL_CSTRING("1");
+  const nsCString firstQuery = queryStart + keyRangeClause + directionClause +
+                               kOpenLimit + NS_LITERAL_CSTRING("1");
 
   DatabaseConnection::CachedStatement stmt;
   nsresult rv = aConnection->GetCachedStatement(firstQuery, &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(kStmtParamNameId, mCursor->mIndexId);
@@ -26120,32 +26164,28 @@ nsresult Cursor::OpenOp::DoIndexKeyDatab
   MOZ_ASSERT(mCursor->mType == OpenCursorParams::TIndexOpenKeyCursorParams);
   MOZ_ASSERT(mCursor->mObjectStoreId);
   MOZ_ASSERT(mCursor->mIndexId);
 
   AUTO_PROFILER_LABEL("Cursor::OpenOp::DoIndexKeyDatabaseWork", DOM);
 
   const bool usingKeyRange = mOptionalKeyRange.isSome();
 
-  nsCString table = mCursor->mUniqueIndex
-                        ? NS_LITERAL_CSTRING("unique_index_data")
-                        : NS_LITERAL_CSTRING("index_data");
+  const auto& table = mCursor->mUniqueIndex
+                          ? NS_LITERAL_CSTRING("unique_index_data")
+                          : NS_LITERAL_CSTRING("index_data");
 
   NS_NAMED_LITERAL_CSTRING(sortColumn, "sort_column");
 
-  nsAutoCString sortColumnAlias;
-  if (mCursor->IsLocaleAware()) {
-    sortColumnAlias =
-        "SELECT value, "
-        "value_locale as sort_column, ";
-  } else {
-    sortColumnAlias =
-        "SELECT value as sort_column, "
-        "value_locale, ";
-  }
+  const nsCString sortColumnAlias =
+      NS_LITERAL_CSTRING("SELECT ") +
+      MakeColumnPairSelectionList(NS_LITERAL_CSTRING("value"),
+                                  NS_LITERAL_CSTRING("value_locale"),
+                                  sortColumn, mCursor->IsLocaleAware()) +
+      NS_LITERAL_CSTRING(", ");
 
   nsAutoCString queryStart = sortColumnAlias +
                              NS_LITERAL_CSTRING(
                                  "object_data_key "
                                  " FROM ") +
                              table + NS_LITERAL_CSTRING(" WHERE index_id = :") +
                              kStmtParamNameId;
 
@@ -26169,18 +26209,18 @@ nsresult Cursor::OpenOp::DoIndexKeyDatab
       break;
 
     default:
       MOZ_CRASH("Should never get here!");
   }
 
   // Note: Changing the number or order of SELECT columns in the query will
   // require changes to CursorOpBase::PopulateResponseFromStatement.
-  nsCString firstQuery = queryStart + keyRangeClause + directionClause +
-                         kOpenLimit + NS_LITERAL_CSTRING("1");
+  const nsCString firstQuery = queryStart + keyRangeClause + directionClause +
+                               kOpenLimit + NS_LITERAL_CSTRING("1");
 
   DatabaseConnection::CachedStatement stmt;
   nsresult rv = aConnection->GetCachedStatement(firstQuery, &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(kStmtParamNameId, mCursor->mIndexId);
@@ -26553,17 +26593,17 @@ nsresult GetFileReferencesHelper::Dispat
     int32_t* aMemRefCnt, int32_t* aDBRefCnt, int32_t* aSliceRefCnt,
     bool* aResult) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aMemRefCnt);
   MOZ_ASSERT(aDBRefCnt);
   MOZ_ASSERT(aSliceRefCnt);
   MOZ_ASSERT(aResult);
 
-  QuotaManager* quotaManager = QuotaManager::Get();
+  QuotaManager* const quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsresult rv = quotaManager->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   mozilla::MutexAutoLock autolock(mMutex);
@@ -26813,17 +26853,17 @@ nsresult FileHelper::RemoveFile(nsIFile*
   }
 
   rv = aFile->Remove(false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (mFileManager->EnforcingQuota()) {
-    QuotaManager* quotaManager = QuotaManager::Get();
+    QuotaManager* const quotaManager = QuotaManager::Get();
     MOZ_ASSERT(quotaManager);
 
     quotaManager->DecreaseUsageForOrigin(
         mFileManager->Type(), mFileManager->Group(), mFileManager->Origin(),
         Client::IDB, fileSize);
   }
 
   rv = aJournalFile->Remove(false);
--- a/dom/indexedDB/IDBCursor.cpp
+++ b/dom/indexedDB/IDBCursor.cpp
@@ -734,22 +734,19 @@ already_AddRefed<IDBRequest> IDBCursor::
       mType == Type_IndexKey || mContinueCalled) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
     return nullptr;
   }
 
   MOZ_ASSERT(mType == Type_ObjectStore || mType == Type_Index);
   MOZ_ASSERT(!mKey.IsUnset());
 
-  IDBObjectStore* objectStore;
-  if (mType == Type_ObjectStore) {
-    objectStore = mSourceObjectStore;
-  } else {
-    objectStore = mSourceIndex->ObjectStore();
-  }
+  IDBObjectStore* const objectStore = mType == Type_ObjectStore
+                                          ? mSourceObjectStore.get()
+                                          : mSourceIndex->ObjectStore();
 
   MOZ_ASSERT(objectStore);
 
   const Key& primaryKey = (mType == Type_ObjectStore) ? mKey : mPrimaryKey;
 
   JS::Rooted<JS::Value> key(aCx);
   aRv = primaryKey.ToJSVal(aCx, &key);
   if (NS_WARN_IF(aRv.Failed())) {
--- a/dom/indexedDB/IDBCursor.h
+++ b/dom/indexedDB/IDBCursor.h
@@ -61,17 +61,17 @@ class IDBCursor final : public nsISuppor
   // TODO: mRequest, mSourceObjectStore and mSourceIndex could be made const if
   // Bug 1575173 is resolved. They are initialized in the constructor and never
   // modified/cleared.
   RefPtr<IDBRequest> mRequest;
   RefPtr<IDBObjectStore> mSourceObjectStore;
   RefPtr<IDBIndex> mSourceIndex;
 
   // mSourceObjectStore or mSourceIndex will hold this alive.
-  IDBTransaction* mTransaction;
+  IDBTransaction* const mTransaction;
 
   // These are cycle-collected!
   JS::Heap<JS::Value> mCachedKey;
   JS::Heap<JS::Value> mCachedPrimaryKey;
   JS::Heap<JS::Value> mCachedValue;
 
   Key mKey;
   Key mSortKey;
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -29,17 +29,17 @@ namespace dom {
 using namespace mozilla::dom::indexedDB;
 
 namespace {
 
 already_AddRefed<IDBRequest> GenerateRequest(JSContext* aCx, IDBIndex* aIndex) {
   MOZ_ASSERT(aIndex);
   aIndex->AssertIsOnOwningThread();
 
-  IDBTransaction* transaction = aIndex->ObjectStore()->Transaction();
+  IDBTransaction* const transaction = aIndex->ObjectStore()->Transaction();
 
   RefPtr<IDBRequest> request =
       IDBRequest::Create(aCx, aIndex, transaction->Database(), transaction);
   MOZ_ASSERT(request);
 
   return request.forget();
 }
 
@@ -133,17 +133,17 @@ const nsString& IDBIndex::Name() const {
   MOZ_ASSERT(mMetadata);
 
   return mMetadata->name();
 }
 
 void IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv) {
   AssertIsOnOwningThread();
 
-  IDBTransaction* transaction = mObjectStore->Transaction();
+  IDBTransaction* const transaction = mObjectStore->Transaction();
 
   if (transaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
       mDeletedMetadata) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   if (!transaction->IsOpen()) {
@@ -367,23 +367,21 @@ already_AddRefed<IDBRequest> IDBIndex::G
   if (keyRange) {
     SerializedKeyRange serializedKeyRange;
     keyRange->ToSerialized(serializedKeyRange);
     optionalKeyRange.emplace(serializedKeyRange);
   }
 
   const uint32_t limit = aLimit.WasPassed() ? aLimit.Value() : 0;
 
-  RequestParams params;
-  if (aKeysOnly) {
-    params =
-        IndexGetAllKeysParams(objectStoreId, indexId, optionalKeyRange, limit);
-  } else {
-    params = IndexGetAllParams(objectStoreId, indexId, optionalKeyRange, limit);
-  }
+  const auto& params =
+      aKeysOnly ? RequestParams{IndexGetAllKeysParams(objectStoreId, indexId,
+                                                      optionalKeyRange, limit)}
+                : RequestParams{IndexGetAllParams(objectStoreId, indexId,
+                                                  optionalKeyRange, limit)};
 
   RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
   MOZ_ASSERT(request);
 
   if (aKeysOnly) {
     IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
         "database(%s).transaction(%s).objectStore(%s).index(%s)."
         "getAllKeys(%s, %s)",
@@ -427,29 +425,30 @@ already_AddRefed<IDBRequest> IDBIndex::O
   }
 
   RefPtr<IDBKeyRange> keyRange;
   IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  int64_t objectStoreId = mObjectStore->Id();
-  int64_t indexId = Id();
+  const int64_t objectStoreId = mObjectStore->Id();
+  const int64_t indexId = Id();
 
   Maybe<SerializedKeyRange> optionalKeyRange;
 
   if (keyRange) {
     SerializedKeyRange serializedKeyRange;
     keyRange->ToSerialized(serializedKeyRange);
 
     optionalKeyRange.emplace(std::move(serializedKeyRange));
   }
 
-  IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
+  const IDBCursor::Direction direction =
+      IDBCursor::ConvertDirection(aDirection);
 
   const CommonIndexOpenCursorParams commonIndexParams = {
       {objectStoreId, std::move(optionalKeyRange), direction}, indexId};
 
   const auto params =
       aKeysOnly ? OpenCursorParams{IndexOpenKeyCursorParams{commonIndexParams}}
                 : OpenCursorParams{IndexOpenCursorParams{commonIndexParams}};
 
@@ -473,17 +472,17 @@ already_AddRefed<IDBRequest> IDBIndex::O
         "IDBObjectStore.openCursor()", transaction->LoggingSerialNumber(),
         request->LoggingSerialNumber(),
         IDB_LOG_STRINGIFY(transaction->Database()),
         IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
         IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange),
         IDB_LOG_STRINGIFY(direction));
   }
 
-  BackgroundCursorChild* actor =
+  BackgroundCursorChild* const actor =
       new BackgroundCursorChild(request, this, direction);
 
   mObjectStore->Transaction()->OpenCursor(actor, params);
 
   return request.forget();
 }
 
 already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
@@ -491,17 +490,17 @@ already_AddRefed<IDBRequest> IDBIndex::C
                                              ErrorResult& aRv) {
   AssertIsOnOwningThread();
 
   if (mDeletedMetadata) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
     return nullptr;
   }
 
-  IDBTransaction* transaction = mObjectStore->Transaction();
+  IDBTransaction* const transaction = mObjectStore->Transaction();
   if (!transaction->IsOpen()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
     return nullptr;
   }
 
   RefPtr<IDBKeyRange> keyRange;
   IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange), aRv);
   if (aRv.Failed()) {
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -177,33 +177,33 @@ struct MOZ_STACK_CLASS GetAddInfoClosure
   ~GetAddInfoClosure() { MOZ_COUNT_DTOR(GetAddInfoClosure); }
 };
 
 already_AddRefed<IDBRequest> GenerateRequest(JSContext* aCx,
                                              IDBObjectStore* aObjectStore) {
   MOZ_ASSERT(aObjectStore);
   aObjectStore->AssertIsOnOwningThread();
 
-  IDBTransaction* transaction = aObjectStore->Transaction();
+  IDBTransaction* const transaction = aObjectStore->Transaction();
 
   RefPtr<IDBRequest> request = IDBRequest::Create(
       aCx, aObjectStore, transaction->Database(), transaction);
   MOZ_ASSERT(request);
 
   return request.forget();
 }
 
 bool StructuredCloneWriteCallback(JSContext* aCx,
                                   JSStructuredCloneWriter* aWriter,
                                   JS::Handle<JSObject*> aObj, void* aClosure) {
   MOZ_ASSERT(aCx);
   MOZ_ASSERT(aWriter);
   MOZ_ASSERT(aClosure);
 
-  auto* cloneWriteInfo =
+  auto* const cloneWriteInfo =
       static_cast<IDBObjectStore::StructuredCloneWriteInfo*>(aClosure);
 
   if (JS_GetClass(aObj) == IDBObjectStore::DummyPropClass()) {
     MOZ_ASSERT(!cloneWriteInfo->mOffsetToKeyProp);
     cloneWriteInfo->mOffsetToKeyProp = js::GetSCOffset(aWriter);
 
     uint64_t value = 0;
     // Omit endian swap
@@ -214,17 +214,17 @@ bool StructuredCloneWriteCallback(JSCont
   JS::Rooted<JSObject*> obj(aCx, aObj);
 
   IDBMutableFile* mutableFile;
   if (NS_SUCCEEDED(UNWRAP_OBJECT(IDBMutableFile, &obj, mutableFile))) {
     if (cloneWriteInfo->mDatabase->IsFileHandleDisabled()) {
       return false;
     }
 
-    IDBDatabase* database = mutableFile->Database();
+    IDBDatabase* const database = mutableFile->Database();
     MOZ_ASSERT(database);
 
     // Throw when trying to store IDBMutableFile objects that live in a
     // different database.
     if (database != cloneWriteInfo->mDatabase) {
       MOZ_ASSERT(!SameCOMIdentity(database, cloneWriteInfo->mDatabase));
 
       if (database->Name() != cloneWriteInfo->mDatabase->Name()) {
@@ -252,53 +252,53 @@ bool StructuredCloneWriteCallback(JSCont
 
     if (cloneWriteInfo->mFiles.Length() > size_t(UINT32_MAX)) {
       MOZ_ASSERT(false, "Fix the structured clone data to use a bigger type!");
       return false;
     }
 
     const uint32_t index = cloneWriteInfo->mFiles.Length();
 
-    NS_ConvertUTF16toUTF8 convType(mutableFile->Type());
-    uint32_t convTypeLength =
+    const NS_ConvertUTF16toUTF8 convType(mutableFile->Type());
+    const uint32_t convTypeLength =
         NativeEndian::swapToLittleEndian(convType.Length());
 
-    NS_ConvertUTF16toUTF8 convName(mutableFile->Name());
-    uint32_t convNameLength =
+    const NS_ConvertUTF16toUTF8 convName(mutableFile->Name());
+    const uint32_t convNameLength =
         NativeEndian::swapToLittleEndian(convName.Length());
 
     if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_MUTABLEFILE, uint32_t(index)) ||
         !JS_WriteBytes(aWriter, &convTypeLength, sizeof(uint32_t)) ||
         !JS_WriteBytes(aWriter, convType.get(), convType.Length()) ||
         !JS_WriteBytes(aWriter, &convNameLength, sizeof(uint32_t)) ||
         !JS_WriteBytes(aWriter, convName.get(), convName.Length())) {
       return false;
     }
 
-    StructuredCloneFile* newFile = cloneWriteInfo->mFiles.AppendElement();
+    StructuredCloneFile* const newFile = cloneWriteInfo->mFiles.AppendElement();
     newFile->mMutableFile = mutableFile;
     newFile->mType = StructuredCloneFile::eMutableFile;
 
     return true;
   }
 
   {
     Blob* blob = nullptr;
     if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, &obj, blob))) {
       ErrorResult rv;
-      uint64_t size = blob->GetSize(rv);
+      const uint64_t nativeEndianSize = blob->GetSize(rv);
       MOZ_ASSERT(!rv.Failed());
 
-      size = NativeEndian::swapToLittleEndian(size);
+      const uint64_t size = NativeEndian::swapToLittleEndian(nativeEndianSize);
 
       nsString type;
       blob->GetType(type);
 
-      NS_ConvertUTF16toUTF8 convType(type);
-      uint32_t convTypeLength =
+      const NS_ConvertUTF16toUTF8 convType(type);
+      const uint32_t convTypeLength =
           NativeEndian::swapToLittleEndian(convType.Length());
 
       if (cloneWriteInfo->mFiles.Length() > size_t(UINT32_MAX)) {
         MOZ_ASSERT(false,
                    "Fix the structured clone data to use a bigger type!");
         return false;
       }
 
@@ -308,40 +308,42 @@ bool StructuredCloneWriteCallback(JSCont
                               blob->IsFile() ? SCTAG_DOM_FILE : SCTAG_DOM_BLOB,
                               index) ||
           !JS_WriteBytes(aWriter, &size, sizeof(size)) ||
           !JS_WriteBytes(aWriter, &convTypeLength, sizeof(convTypeLength)) ||
           !JS_WriteBytes(aWriter, convType.get(), convType.Length())) {
         return false;
       }
 
-      RefPtr<File> file = blob->ToFile();
+      const RefPtr<File> file = blob->ToFile();
       if (file) {
         ErrorResult rv;
-        int64_t lastModifiedDate = file->GetLastModified(rv);
+        const int64_t nativeEndianLastModifiedDate = file->GetLastModified(rv);
         MOZ_ALWAYS_TRUE(!rv.Failed());
 
-        lastModifiedDate = NativeEndian::swapToLittleEndian(lastModifiedDate);
+        const int64_t lastModifiedDate =
+            NativeEndian::swapToLittleEndian(nativeEndianLastModifiedDate);
 
         nsString name;
         file->GetName(name);
 
-        NS_ConvertUTF16toUTF8 convName(name);
-        uint32_t convNameLength =
+        const NS_ConvertUTF16toUTF8 convName(name);
+        const uint32_t convNameLength =
             NativeEndian::swapToLittleEndian(convName.Length());
 
         if (!JS_WriteBytes(aWriter, &lastModifiedDate,
                            sizeof(lastModifiedDate)) ||
             !JS_WriteBytes(aWriter, &convNameLength, sizeof(convNameLength)) ||
             !JS_WriteBytes(aWriter, convName.get(), convName.Length())) {
           return false;
         }
       }
 
-      StructuredCloneFile* newFile = cloneWriteInfo->mFiles.AppendElement();
+      StructuredCloneFile* const newFile =
+          cloneWriteInfo->mFiles.AppendElement();
       newFile->mBlob = blob;
       newFile->mType = StructuredCloneFile::eBlob;
 
       return true;
     }
   }
 
   return StructuredCloneHolder::WriteFullySerializableObjects(aCx, aWriter,
@@ -351,17 +353,18 @@ bool StructuredCloneWriteCallback(JSCont
 bool CopyingStructuredCloneWriteCallback(JSContext* aCx,
                                          JSStructuredCloneWriter* aWriter,
                                          JS::Handle<JSObject*> aObj,
                                          void* aClosure) {
   MOZ_ASSERT(aCx);
   MOZ_ASSERT(aWriter);
   MOZ_ASSERT(aClosure);
 
-  auto* cloneInfo = static_cast<IDBObjectStore::StructuredCloneInfo*>(aClosure);
+  auto* const cloneInfo =
+      static_cast<IDBObjectStore::StructuredCloneInfo*>(aClosure);
 
   // UNWRAP_OBJECT calls might mutate this.
   JS::Rooted<JSObject*> obj(aCx, aObj);
 
   {
     Blob* blob = nullptr;
     if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, &obj, blob))) {
       if (cloneInfo->mFiles.Length() > size_t(UINT32_MAX)) {
@@ -373,17 +376,17 @@ bool CopyingStructuredCloneWriteCallback
       const uint32_t index = cloneInfo->mFiles.Length();
 
       if (!JS_WriteUint32Pair(aWriter,
                               blob->IsFile() ? SCTAG_DOM_FILE : SCTAG_DOM_BLOB,
                               index)) {
         return false;
       }
 
-      StructuredCloneFile* newFile = cloneInfo->mFiles.AppendElement();
+      StructuredCloneFile* const newFile = cloneInfo->mFiles.AppendElement();
       newFile->mBlob = blob;
       newFile->mType = StructuredCloneFile::eBlob;
 
       return true;
     }
   }
 
   {
@@ -396,17 +399,17 @@ bool CopyingStructuredCloneWriteCallback
       }
 
       const uint32_t index = cloneInfo->mFiles.Length();
 
       if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_MUTABLEFILE, index)) {
         return false;
       }
 
-      StructuredCloneFile* newFile = cloneInfo->mFiles.AppendElement();
+      StructuredCloneFile* const newFile = cloneInfo->mFiles.AppendElement();
       newFile->mMutableFile = mutableFile;
       newFile->mType = StructuredCloneFile::eMutableFile;
 
       return true;
     }
   }
 
   return StructuredCloneHolder::WriteFullySerializableObjects(aCx, aWriter,
@@ -421,17 +424,17 @@ nsresult GetAddInfoCallback(JSContext* a
       nullptr /* readTransfer */,
       nullptr /* writeTransfer */,
       nullptr /* freeTransfer */,
       nullptr /* canTransfer */
   };
 
   MOZ_ASSERT(aCx);
 
-  auto* data = static_cast<GetAddInfoClosure*>(aClosure);
+  auto* const data = static_cast<GetAddInfoClosure*>(aClosure);
   MOZ_ASSERT(data);
 
   data->mCloneWriteInfo.mOffsetToKeyProp = 0;
 
   if (!data->mCloneWriteInfo.mCloneBuffer.write(aCx, data->mValue,
                                                 &kStructuredCloneCallbacks,
                                                 &data->mCloneWriteInfo)) {
     return NS_ERROR_DOM_DATA_CLONE_ERR;
@@ -455,17 +458,17 @@ bool StructuredCloneReadString(JSStructu
     return false;
   }
   length = NativeEndian::swapFromLittleEndian(length);
 
   if (!aString.SetLength(length, fallible)) {
     NS_WARNING("Out of memory?");
     return false;
   }
-  char* buffer = aString.BeginWriting();
+  char* const buffer = aString.BeginWriting();
 
   if (!JS_ReadBytes(aReader, buffer, length)) {
     NS_WARNING("Failed to read type!");
     return false;
   }
 
   return true;
 }
@@ -625,22 +628,23 @@ class ValueDeserializationHelper {
 
     /* If we are creating an index, we do not have an mBlob but do have an
      * mInfo.  Unlike other index or upgrade cases, we do need a real-looking
      * Blob/File instance because the index's key path can reference their
      * properties.  Rather than create a fake-looking object, create a real
      * Blob. */
     if (!blob) {
       MOZ_ASSERT(aFile.mFileInfo);
-      nsCOMPtr<nsIFile> file = FileInfo::GetFileForFileInfo(aFile.mFileInfo);
+      const nsCOMPtr<nsIFile> file =
+          FileInfo::GetFileForFileInfo(aFile.mFileInfo);
       if (!file) {
         return false;
       }
 
-      RefPtr<FileBlobImpl> impl = new FileBlobImpl(file);
+      const RefPtr<FileBlobImpl> impl = new FileBlobImpl(file);
       impl->SetFileId(aFile.mFileInfo->Id());
       blob = File::Create(nullptr, impl);
     }
 
     // It can happen that this IDB is chrome code, so there is no parent, but
     // still we want to set a correct parent for the new File object.
     nsCOMPtr<nsISupports> parent;
     if (NS_IsMainThread()) {
@@ -668,33 +672,33 @@ class ValueDeserializationHelper {
 
       // ActorsParent sends here a kind of half blob and half file wrapped into
       // a DOM File object. DOM File and DOM Blob are a WebIDL wrapper around a
       // BlobImpl object. SetLazyData() has just changed the BlobImpl to be a
       // Blob (see the previous assert), but 'blob' still has the WebIDL DOM
       // File wrapping.
       // Before exposing it to content, we must recreate a DOM Blob object.
 
-      RefPtr<Blob> exposedBlob =
+      const RefPtr<Blob> exposedBlob =
           Blob::Create(blob->GetParentObject(), blob->Impl());
       MOZ_ASSERT(exposedBlob);
       JS::Rooted<JS::Value> wrappedBlob(aCx);
       if (!ToJSValue(aCx, exposedBlob, &wrappedBlob)) {
         return false;
       }
 
       aResult.set(&wrappedBlob.toObject());
       return true;
     }
 
     blob->Impl()->SetLazyData(aData.name, aData.type, aData.size,
                               aData.lastModifiedDate * PR_USEC_PER_MSEC);
 
     MOZ_ASSERT(blob->IsFile());
-    RefPtr<File> file = blob->ToFile();
+    const RefPtr<File> file = blob->ToFile();
     MOZ_ASSERT(file);
 
     JS::Rooted<JS::Value> wrappedFile(aCx);
     if (!ToJSValue(aCx, file, &wrappedFile)) {
       return false;
     }
 
     aResult.set(&wrappedFile.toObject());
@@ -735,17 +739,17 @@ JSObject* CommonStructuredCloneReadCallb
                     SCTAG_DOM_FILE == 0xffff8005 &&
                     SCTAG_DOM_WASM == 0xffff8006,
                 "You changed our structured clone tag values and just ate "
                 "everyone's IndexedDB data.  I hope you are happy.");
 
   if (aTag == SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE ||
       aTag == SCTAG_DOM_BLOB || aTag == SCTAG_DOM_FILE ||
       aTag == SCTAG_DOM_MUTABLEFILE || aTag == SCTAG_DOM_WASM) {
-    auto* cloneReadInfo = static_cast<StructuredCloneReadInfo*>(aClosure);
+    auto* const cloneReadInfo = static_cast<StructuredCloneReadInfo*>(aClosure);
 
     JS::Rooted<JSObject*> result(aCx);
 
     if (aTag == SCTAG_DOM_WASM) {
       WasmModuleData data(aData);
       if (NS_WARN_IF(!ReadWasmModule(aReader, &data))) {
         return nullptr;
       }
@@ -810,17 +814,17 @@ JSObject* CommonStructuredCloneReadCallb
 JSObject* CopyingStructuredCloneReadCallback(JSContext* aCx,
                                              JSStructuredCloneReader* aReader,
                                              uint32_t aTag, uint32_t aData,
                                              void* aClosure) {
   MOZ_ASSERT(aTag != SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE);
 
   if (aTag == SCTAG_DOM_BLOB || aTag == SCTAG_DOM_FILE ||
       aTag == SCTAG_DOM_MUTABLEFILE) {
-    auto* cloneInfo =
+    auto* const cloneInfo =
         static_cast<IDBObjectStore::StructuredCloneInfo*>(aClosure);
 
     JS::Rooted<JSObject*> result(aCx);
 
     if (aData >= cloneInfo->mFiles.Length()) {
       MOZ_ASSERT(false, "Bad index value!");
       return nullptr;
     }
@@ -842,20 +846,20 @@ JSObject* CopyingStructuredCloneReadCall
     }
 
     if (aTag == SCTAG_DOM_FILE) {
       MOZ_ASSERT(file.mType == StructuredCloneFile::eBlob);
 
       {
         // Create a scope so ~RefPtr fires before returning an unwrapped
         // JS::Value.
-        RefPtr<Blob> blob = file.mBlob;
+        const RefPtr<Blob> blob = file.mBlob;
         MOZ_ASSERT(blob->IsFile());
 
-        RefPtr<File> file = blob->ToFile();
+        const RefPtr<File> file = blob->ToFile();
         MOZ_ASSERT(file);
 
         JS::Rooted<JS::Value> wrappedFile(aCx);
         if (NS_WARN_IF(!ToJSValue(aCx, file, &wrappedFile))) {
           return nullptr;
         }
 
         result.set(&wrappedFile.toObject());
@@ -1090,21 +1094,21 @@ class SandboxHolder final {
       sHolder = new SandboxHolder();
       ClearOnShutdown(&sHolder);
     }
     return sHolder;
   }
 
   JSObject* GetSandboxInternal(JSContext* aCx) {
     if (!mSandbox) {
-      nsIXPConnect* xpc = nsContentUtils::XPConnect();
+      nsIXPConnect* const xpc = nsContentUtils::XPConnect();
       MOZ_ASSERT(xpc, "This should never be null!");
 
       // Let's use a null principal.
-      nsCOMPtr<nsIPrincipal> principal =
+      const nsCOMPtr<nsIPrincipal> principal =
           NullPrincipal::CreateWithoutOriginAttributes();
 
       JS::Rooted<JSObject*> sandbox(aCx);
       nsresult rv = xpc->CreateSandbox(aCx, principal, sandbox.address());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return nullptr;
       }
 
@@ -1168,25 +1172,25 @@ class DeserializeIndexValueHelper final 
   }
 
   NS_IMETHOD
   Run() override {
     MOZ_ASSERT(NS_IsMainThread());
 
     AutoJSAPI jsapi;
     jsapi.Init();
-    JSContext* cx = jsapi.cx();
+    JSContext* const cx = jsapi.cx();
 
     JS::Rooted<JSObject*> global(cx, SandboxHolder::GetSandbox(cx));
     if (NS_WARN_IF(!global)) {
       OperationCompleted(NS_ERROR_FAILURE);
       return NS_OK;
     }
 
-    JSAutoRealm ar(cx, global);
+    const JSAutoRealm ar(cx, global);
 
     JS::Rooted<JS::Value> value(cx);
     const nsresult rv = DeserializeIndexValue(cx, &value);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       OperationCompleted(rv);
       return NS_OK;
     }
 
@@ -1229,19 +1233,19 @@ class DeserializeIndexValueHelper final 
     mStatus = aStatus;
 
     MonitorAutoLock lock(mMonitor);
     lock.Notify();
   }
 
   Monitor mMonitor;
 
-  int64_t mIndexID;
+  const int64_t mIndexID;
   const KeyPath& mKeyPath;
-  bool mMultiEntry;
+  const bool mMultiEntry;
   const nsCString mLocale;
   StructuredCloneReadInfo& mCloneReadInfo;
   nsTArray<IndexUpdateInfo>& mUpdateInfoArray;
   nsresult mStatus;
 };
 
 class DeserializeUpgradeValueHelper final : public Runnable {
  public:
@@ -1261,17 +1265,18 @@ class DeserializeUpgradeValueHelper fina
 
     // The operation will continue on the main-thread.
 
     MOZ_ASSERT(!(mCloneReadInfo.mData.Size() % sizeof(uint64_t)));
 
     MonitorAutoLock lock(mMonitor);
 
     RefPtr<Runnable> self = this;
-    nsresult rv = SystemGroup::Dispatch(TaskCategory::Other, self.forget());
+    const nsresult rv =
+        SystemGroup::Dispatch(TaskCategory::Other, self.forget());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     lock.Wait();
 
     if (NS_FAILED(mStatus)) {
       return mStatus;
@@ -1290,20 +1295,20 @@ class DeserializeUpgradeValueHelper fina
     JSContext* cx = jsapi.cx();
 
     JS::Rooted<JSObject*> global(cx, SandboxHolder::GetSandbox(cx));
     if (NS_WARN_IF(!global)) {
       OperationCompleted(NS_ERROR_FAILURE);
       return NS_OK;
     }
 
-    JSAutoRealm ar(cx, global);
+    const JSAutoRealm ar(cx, global);
 
     JS::Rooted<JS::Value> value(cx);
-    nsresult rv = DeserializeUpgradeValue(cx, &value);
+    const nsresult rv = DeserializeUpgradeValue(cx, &value);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       OperationCompleted(rv);
       return NS_OK;
     }
 
     OperationCompleted(NS_OK);
     return NS_OK;
   }
@@ -1328,17 +1333,17 @@ class DeserializeUpgradeValueHelper fina
     }
 
     return NS_OK;
   }
 
   void PopulateFileIds(nsAString& aFileIds) {
     for (uint32_t count = mCloneReadInfo.mFiles.Length(), index = 0;
          index < count; index++) {
-      StructuredCloneFile& file = mCloneReadInfo.mFiles[index];
+      const StructuredCloneFile& file = mCloneReadInfo.mFiles[index];
       MOZ_ASSERT(file.mFileInfo);
 
       const int64_t id = file.mFileInfo->Id();
 
       if (index) {
         aFileIds.Append(' ');
       }
       aFileIds.AppendInt(file.mType == StructuredCloneFile::eBlob ? id : -id);
@@ -1361,28 +1366,28 @@ class DeserializeUpgradeValueHelper fina
 
 // static
 void IDBObjectStore::DeserializeIndexValueToUpdateInfos(
     int64_t aIndexID, const KeyPath& aKeyPath, bool aMultiEntry,
     const nsCString& aLocale, StructuredCloneReadInfo& aCloneReadInfo,
     nsTArray<IndexUpdateInfo>& aUpdateInfoArray, ErrorResult& aRv) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  RefPtr<DeserializeIndexValueHelper> helper =
+  const RefPtr<DeserializeIndexValueHelper> helper =
       new DeserializeIndexValueHelper(aIndexID, aKeyPath, aMultiEntry, aLocale,
                                       aCloneReadInfo, aUpdateInfoArray);
   helper->DispatchAndWait(aRv);
 }
 
 // static
 nsresult IDBObjectStore::DeserializeUpgradeValueToFileIds(
     StructuredCloneReadInfo& aCloneReadInfo, nsAString& aFileIds) {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  RefPtr<DeserializeUpgradeValueHelper> helper =
+  const RefPtr<DeserializeUpgradeValueHelper> helper =
       new DeserializeUpgradeValueHelper(aCloneReadInfo);
   return helper->DispatchAndWait(aFileIds);
 }
 
 #ifdef DEBUG
 
 void IDBObjectStore::AssertIsOnOwningThread() const {
   MOZ_ASSERT(mTransaction);
@@ -1399,21 +1404,21 @@ void IDBObjectStore::GetAddInfo(JSContex
                                 ErrorResult& aRv) {
   // Return DATA_ERR if a key was passed in and this objectStore uses inline
   // keys.
   if (!aKeyVal.isUndefined() && HasValidKeyPath()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
     return;
   }
 
-  bool isAutoIncrement = AutoIncrement();
+  const bool isAutoIncrement = AutoIncrement();
 
   if (!HasValidKeyPath()) {
     // Out-of-line keys must be passed in.
-    auto result = aKey.SetFromJSVal(aCx, aKeyVal, aRv);
+    const auto result = aKey.SetFromJSVal(aCx, aKeyVal, aRv);
     if (!result.Is(Ok, aRv)) {
       if (result.Is(Invalid, aRv)) {
         aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
       }
       return;
     }
   } else if (!isAutoIncrement) {
     if (!aValueWrapper.Clone(aCx)) {
@@ -1438,17 +1443,17 @@ void IDBObjectStore::GetAddInfo(JSContex
 
   if (mSpec->indexes().Length() && !aValueWrapper.Clone(aCx)) {
     aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
     return;
   }
 
   {
     const nsTArray<IndexMetadata>& indexes = mSpec->indexes();
-    uint32_t idxCount = indexes.Length();
+    const uint32_t idxCount = indexes.Length();
 
     aUpdateInfoArray.SetCapacity(idxCount);  // Pretty good estimate
 
     for (uint32_t idxIndex = 0; idxIndex < idxCount; idxIndex++) {
       const IndexMetadata& metadata = indexes[idxIndex];
 
       AppendIndexUpdateInfo(metadata.id(), metadata.keyPath(),
                             metadata.multiEntry(), metadata.locale(), aCx,
@@ -1525,18 +1530,18 @@ already_AddRefed<IDBRequest> IDBObjectSt
   const size_t kMaxMessageSize = maximalSizeFromPref - kMaxIDBMsgOverhead;
 
   size_t indexUpdateInfoSize = 0;
   for (size_t i = 0; i < updateInfo.Length(); i++) {
     indexUpdateInfoSize += updateInfo[i].value().GetBuffer().Length();
     indexUpdateInfoSize += updateInfo[i].localizedValue().GetBuffer().Length();
   }
 
-  size_t messageSize = cloneWriteInfo.mCloneBuffer.data().Size() +
-                       key.GetBuffer().Length() + indexUpdateInfoSize;
+  const size_t messageSize = cloneWriteInfo.mCloneBuffer.data().Size() +
+                             key.GetBuffer().Length() + indexUpdateInfoSize;
 
   if (messageSize > kMaxMessageSize) {
     IDB_REPORT_INTERNAL_ERR();
     aRv.ThrowDOMException(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR,
                           nsPrintfCString("The serialized value is too large"
                                           " (size=%zu bytes, max=%zu bytes).",
                                           messageSize, kMaxMessageSize));
     return nullptr;
@@ -1557,30 +1562,30 @@ already_AddRefed<IDBRequest> IDBObjectSt
     const uint32_t count = files.Length();
 
     FallibleTArray<FileAddInfo> fileAddInfos;
     if (NS_WARN_IF(!fileAddInfos.SetCapacity(count, fallible))) {
       aRv = NS_ERROR_OUT_OF_MEMORY;
       return nullptr;
     }
 
-    IDBDatabase* database = mTransaction->Database();
+    IDBDatabase* const database = mTransaction->Database();
 
     for (uint32_t index = 0; index < count; index++) {
       StructuredCloneFile& file = files[index];
 
-      FileAddInfo* fileAddInfo = fileAddInfos.AppendElement(fallible);
+      FileAddInfo* const fileAddInfo = fileAddInfos.AppendElement(fallible);
       MOZ_ASSERT(fileAddInfo);
 
       switch (file.mType) {
         case StructuredCloneFile::eBlob: {
           MOZ_ASSERT(file.mBlob);
           MOZ_ASSERT(!file.mMutableFile);
 
-          PBackgroundIDBDatabaseFileChild* fileActor =
+          PBackgroundIDBDatabaseFileChild* const fileActor =
               database->GetOrCreateFileActorForBlob(file.mBlob);
           if (NS_WARN_IF(!fileActor)) {
             IDB_REPORT_INTERNAL_ERR();
             aRv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
             return nullptr;
           }
 
           fileAddInfo->file() = fileActor;
@@ -1588,17 +1593,17 @@ already_AddRefed<IDBRequest> IDBObjectSt
 
           break;
         }
 
         case StructuredCloneFile::eMutableFile: {
           MOZ_ASSERT(file.mMutableFile);
           MOZ_ASSERT(!file.mBlob);
 
-          PBackgroundMutableFileChild* mutableFileActor =
+          PBackgroundMutableFileChild* const mutableFileActor =
               file.mMutableFile->GetBackgroundActor();
           if (NS_WARN_IF(!mutableFileActor)) {
             IDB_REPORT_INTERNAL_ERR();
             aRv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
             return nullptr;
           }
 
           fileAddInfo->file() = mutableFileActor;
@@ -1607,17 +1612,17 @@ already_AddRefed<IDBRequest> IDBObjectSt
           break;
         }
 
         case StructuredCloneFile::eWasmBytecode:
         case StructuredCloneFile::eWasmCompiled: {
           MOZ_ASSERT(file.mBlob);
           MOZ_ASSERT(!file.mMutableFile);
 
-          PBackgroundIDBDatabaseFileChild* fileActor =
+          PBackgroundIDBDatabaseFileChild* const fileActor =
               database->GetOrCreateFileActorForBlob(file.mBlob);
           if (NS_WARN_IF(!fileActor)) {
             IDB_REPORT_INTERNAL_ERR();
             aRv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
             return nullptr;
           }
 
           fileAddInfo->file() = fileActor;
@@ -1629,22 +1634,19 @@ already_AddRefed<IDBRequest> IDBObjectSt
         default:
           MOZ_CRASH("Should never get here!");
       }
     }
 
     commonParams.fileAddInfos().SwapElements(fileAddInfos);
   }
 
-  RequestParams params;
-  if (aOverwrite) {
-    params = ObjectStorePutParams(commonParams);
-  } else {
-    params = ObjectStoreAddParams(commonParams);
-  }
+  const auto& params = aOverwrite
+                           ? RequestParams{ObjectStorePutParams(commonParams)}
+                           : RequestParams{ObjectStoreAddParams(commonParams)};
 
   RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
   MOZ_ASSERT(request);
 
   if (!aFromCursor) {
     if (aOverwrite) {
       IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
           "database(%s).transaction(%s).objectStore(%s).put(%s)",
@@ -1750,18 +1752,17 @@ already_AddRefed<IDBRequest> IDBObjectSt
     return nullptr;
   }
 
   if (!mTransaction->IsWriteAllowed()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR);
     return nullptr;
   }
 
-  ObjectStoreClearParams params;
-  params.objectStoreId() = Id();
+  const ObjectStoreClearParams params = {Id()};
 
   RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
   MOZ_ASSERT(request);
 
   IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
       "database(%s).transaction(%s).objectStore(%s).clear()",
       "IDBObjectStore.clear()", mTransaction->LoggingSerialNumber(),
       request->LoggingSerialNumber(),
@@ -1937,22 +1938,19 @@ already_AddRefed<IDBRequest> IDBObjectSt
     return nullptr;
   }
 
   const int64_t id = Id();
 
   SerializedKeyRange serializedKeyRange;
   keyRange->ToSerialized(serializedKeyRange);
 
-  RequestParams params;
-  if (aKeyOnly) {
-    params = ObjectStoreGetKeyParams(id, serializedKeyRange);
-  } else {
-    params = ObjectStoreGetParams(id, serializedKeyRange);
-  }
+  const auto& params =
+      aKeyOnly ? RequestParams{ObjectStoreGetKeyParams(id, serializedKeyRange)}
+               : RequestParams{ObjectStoreGetParams(id, serializedKeyRange)};
 
   RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
   MOZ_ASSERT(request);
 
   IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
       "database(%s).transaction(%s).objectStore(%s).get(%s)",
       "IDBObjectStore.get()", mTransaction->LoggingSerialNumber(),
       request->LoggingSerialNumber(),
@@ -2025,17 +2023,17 @@ already_AddRefed<IDBIndex> IDBObjectStor
   AssertIsOnOwningThread();
 
   if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
       mDeletedSpec) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
     return nullptr;
   }
 
-  IDBTransaction* transaction = IDBTransaction::GetCurrent();
+  IDBTransaction* const transaction = IDBTransaction::GetCurrent();
   if (!transaction || transaction != mTransaction || !transaction->IsOpen()) {
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
     return nullptr;
   }
 
   auto& indexes = const_cast<nsTArray<IndexMetadata>&>(mSpec->indexes());
   for (uint32_t count = indexes.Length(), index = 0; index < count; index++) {
     if (aName == indexes[index].name()) {
@@ -2070,30 +2068,30 @@ already_AddRefed<IDBIndex> IDBObjectStor
   }
 
 #ifdef DEBUG
   for (uint32_t count = mIndexes.Length(), index = 0; index < count; index++) {
     MOZ_ASSERT(mIndexes[index]->Name() != aName);
   }
 #endif
 
-  const IndexMetadata* oldMetadataElements =
+  const IndexMetadata* const oldMetadataElements =
       indexes.IsEmpty() ? nullptr : indexes.Elements();
 
   // With this setup we only validate the passed in locale name by the time we
   // get to encoding Keys. Maybe we should do it here right away and error out.
 
   // Valid locale names are always ASCII as per BCP-47.
   nsCString locale = NS_LossyConvertUTF16toASCII(aOptionalParameters.mLocale);
   bool autoLocale = locale.EqualsASCII("auto");
   if (autoLocale) {
     locale = IndexedDatabaseManager::GetLocale();
   }
 
-  IndexMetadata* metadata = indexes.AppendElement(
+  IndexMetadata* const metadata = indexes.AppendElement(
       IndexMetadata(transaction->NextIndexId(), nsString(aName), keyPath,
                     locale, aOptionalParameters.mUnique,
                     aOptionalParameters.mMultiEntry, autoLocale));
 
   if (oldMetadataElements && oldMetadataElements != indexes.Elements()) {
     MOZ_ASSERT(indexes.Length() > 1);
 
     // Array got moved, update the spec pointers for all live indexes.
@@ -2254,28 +2252,29 @@ already_AddRefed<IDBRequest> IDBObjectSt
   }
 
   RefPtr<IDBKeyRange> keyRange;
   IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  int64_t objectStoreId = Id();
+  const int64_t objectStoreId = Id();
 
   Maybe<SerializedKeyRange> optionalKeyRange;
 
   if (keyRange) {
     SerializedKeyRange serializedKeyRange;
     keyRange->ToSerialized(serializedKeyRange);
 
     optionalKeyRange.emplace(std::move(serializedKeyRange));
   }
 
-  IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
+  const IDBCursor::Direction direction =
+      IDBCursor::ConvertDirection(aDirection);
 
   const CommonOpenCursorParams commonParams = {
       objectStoreId, std::move(optionalKeyRange), direction};
 
   // TODO: It would be great if the IPDL generator created a constructor
   // accepting a CommonOpenCursorParams by value or rvalue reference.
   const auto params =
       aKeysOnly ? OpenCursorParams{ObjectStoreOpenKeyCursorParams{commonParams}}
@@ -2299,17 +2298,17 @@ already_AddRefed<IDBRequest> IDBObjectSt
         "openCursor(%s, %s)",
         "IDBObjectStore.openCursor()", mTransaction->LoggingSerialNumber(),
         request->LoggingSerialNumber(),
         IDB_LOG_STRINGIFY(mTransaction->Database()),
         IDB_LOG_STRINGIFY(mTransaction), IDB_LOG_STRINGIFY(this),
         IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(direction));
   }
 
-  BackgroundCursorChild* actor =
+  BackgroundCursorChild* const actor =
       new BackgroundCursorChild(request, this, direction);
 
   mTransaction->OpenCursor(actor, params);
 
   return request.forget();
 }
 
 void IDBObjectStore::RefreshSpec(bool aMayDelete) {
@@ -2410,17 +2409,17 @@ void IDBObjectStore::SetName(const nsASt
 
   if (aName == mSpec->metadata().name()) {
     return;
   }
 
   // Cache logging string of this object store before renaming.
   const LoggingString loggingOldObjectStore(this);
 
-  nsresult rv =
+  const nsresult rv =
       transaction->Database()->RenameObjectStore(mSpec->metadata().id(), aName);
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
   // Don't do this in the macro because we always need to increment the serial