Bug 1168606 - Use const where easily possible. r=ttung,asuth

Differential Revision: https://phabricator.services.mozilla.com/D43631

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-10-03 07:56:45 +00:00
Родитель 16d87d7487
Коммит cd0b6f05a1
7 изменённых файлов: 334 добавлений и 298 удалений

Просмотреть файл

@ -189,7 +189,7 @@ class MOZ_STACK_CLASS AutoSetCurrentTransaction final {
};
class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
IDBRequest* mRequest;
IDBRequest* const mRequest;
AutoSetCurrentTransaction mAutoTransaction;
union {
@ -372,7 +372,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
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;
@ -383,7 +383,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
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;
@ -415,7 +415,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
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;
}
@ -434,7 +434,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
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;
}
@ -463,7 +463,7 @@ class MOZ_STACK_CLASS ResultHelper final : public IDBRequest::ResultCallback {
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;
}
@ -499,7 +499,7 @@ class PermissionRequestMainProcessHelper final : public PermissionRequestBase {
}
protected:
~PermissionRequestMainProcessHelper() {}
~PermissionRequestMainProcessHelper() = default;
private:
virtual void OnPromptComplete(PermissionValue aPermissionValue) override;
@ -531,13 +531,13 @@ void DeserializeStructuredCloneFiles(
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;
@ -553,7 +553,7 @@ void DeserializeStructuredCloneFiles(
switch (blobOrMutableFile.type()) {
case BlobOrMutableFile::Tnull_t: {
StructuredCloneFile* file = aFiles.AppendElement();
StructuredCloneFile* const file = aFiles.AppendElement();
MOZ_ASSERT(file);
file->mType = StructuredCloneFile::eMutableFile;
@ -562,17 +562,17 @@ void DeserializeStructuredCloneFiles(
}
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;
@ -596,13 +596,14 @@ void DeserializeStructuredCloneFiles(
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;
@ -610,7 +611,7 @@ void DeserializeStructuredCloneFiles(
} else {
MOZ_ASSERT(blobOrMutableFile.type() == BlobOrMutableFile::Tnull_t);
StructuredCloneFile* file = aFiles.AppendElement();
StructuredCloneFile* const file = aFiles.AppendElement();
MOZ_ASSERT(file);
file->mType = StructuredCloneFile::eStructuredClone;
@ -623,7 +624,7 @@ void DeserializeStructuredCloneFiles(
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();
@ -653,8 +654,8 @@ void DispatchErrorEvent(IDBRequest* aRequest, nsresult aErrorCode,
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);
@ -686,7 +687,8 @@ void DispatchErrorEvent(IDBRequest* aRequest, nsresult 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;
}
@ -699,7 +701,7 @@ void DispatchErrorEvent(IDBRequest* aRequest, nsresult aErrorCode,
// 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) {
@ -716,11 +718,11 @@ void DispatchSuccessEvent(ResultHelper* 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);
@ -762,7 +764,7 @@ void DispatchSuccessEvent(ResultHelper* aResultHelper,
return;
}
WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
WidgetEvent* const internalEvent = aEvent->WidgetEventPtr();
MOZ_ASSERT(internalEvent);
if (transaction && transaction->IsOpen()) {
@ -778,13 +780,13 @@ void DispatchSuccessEvent(ResultHelper* aResultHelper,
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;
}
@ -865,7 +867,7 @@ class WorkerPermissionChallenge final : public Runnable {
NS_IMETHOD
Run() override {
bool completed = RunInternal();
const bool completed = RunInternal();
if (completed) {
OperationCompleted();
}
@ -875,7 +877,7 @@ class WorkerPermissionChallenge final : public Runnable {
void OperationCompleted() {
if (NS_IsMainThread()) {
RefPtr<WorkerPermissionOperationCompleted> runnable =
const RefPtr<WorkerPermissionOperationCompleted> runnable =
new WorkerPermissionOperationCompleted(mWorkerPrivate, this);
MOZ_ALWAYS_TRUE(runnable->Dispatch());
@ -907,20 +909,20 @@ class WorkerPermissionChallenge final : public Runnable {
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;
@ -956,10 +958,10 @@ class WorkerPermissionChallenge final : public Runnable {
}
private:
WorkerPrivate* mWorkerPrivate;
WorkerPrivate* const mWorkerPrivate;
BackgroundFactoryRequestChild* mActor;
RefPtr<IDBFactory> mFactory;
PrincipalInfo mPrincipalInfo;
const PrincipalInfo mPrincipalInfo;
};
void WorkerPermissionRequest::OnPromptComplete(
@ -1018,7 +1020,7 @@ class MOZ_STACK_CLASS AutoSetCurrentFileHandle final {
class MOZ_STACK_CLASS FileHandleResultHelper final
: public IDBFileRequest::ResultCallback {
IDBFileRequest* mFileRequest;
IDBFileRequest* const mFileRequest;
AutoSetCurrentFileHandle mAutoFileHandle;
union {
@ -1119,7 +1121,7 @@ class MOZ_STACK_CLASS FileHandleResultHelper final
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;
}
@ -1203,7 +1205,7 @@ class MOZ_STACK_CLASS FileHandleResultHelper final
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);
@ -1216,12 +1218,12 @@ already_AddRefed<File> ConvertActorToFile(
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 =
@ -1238,8 +1240,8 @@ void DispatchFileHandleErrorEvent(IDBFileRequest* aFileRequest,
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);
@ -1251,11 +1253,11 @@ void DispatchFileHandleErrorEvent(IDBFileRequest* aFileRequest,
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()) {
@ -1298,13 +1300,13 @@ class BackgroundRequestChild::PreprocessHelper final
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;
@ -1469,7 +1471,7 @@ 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);

Просмотреть файл

@ -210,7 +210,7 @@ class BackgroundFactoryRequestChild final
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()

Просмотреть файл

@ -561,8 +561,8 @@ struct IndexDataValue final {
* 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);
}
@ -671,7 +671,7 @@ void WriteCompressedNumber(uint64_t aNumber, uint8_t** aIterator) {
uint8_t*& buffer = *aIterator;
#ifdef DEBUG
const uint8_t* bufferStart = buffer;
const uint8_t* const bufferStart = buffer;
const uint64_t originalNumber = aNumber;
#endif
@ -857,7 +857,7 @@ nsresult ReadCompressedIndexDataValuesFromBlob(
}
const uint8_t* blobDataIter = aBlobData;
const uint8_t* blobDataEnd = aBlobData + aBlobDataLength;
const uint8_t* const blobDataEnd = aBlobData + aBlobDataLength;
while (blobDataIter < blobDataEnd) {
int64_t indexId;
@ -3579,7 +3579,7 @@ nsresult UpgradeIndexDataValuesFunction::ReadOldCompressedIDVFromBlob(
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;
@ -4151,7 +4151,7 @@ nsresult OpenDatabaseAndHandleBusy(mozIStorageService* aStorageService,
// 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));
@ -4371,57 +4371,80 @@ nsresult CreateStorageConnection(nsIFile* aDBFile, nsIFile* aFMDirectory,
"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))) {
@ -9267,6 +9290,23 @@ const CommonOpenCursorParams& GetCommonOpenCursorParams(
}
}
// 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 ||
@ -9584,7 +9624,7 @@ nsresult DatabaseConnection::BeginWriteTransaction() {
// 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));
@ -10426,7 +10466,7 @@ void DatabaseConnection::UpdateRefcountFunction::Reset() {
}
if (aFileManager->EnforcingQuota()) {
QuotaManager* quotaManager = QuotaManager::Get();
QuotaManager* const quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
quotaManager->DecreaseUsageForOrigin(
@ -14130,12 +14170,13 @@ bool TransactionBase::StartRequest(PBackgroundIDBRequestParent* aActor) {
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;
}
@ -14150,7 +14191,7 @@ PBackgroundIDBCursorParent* TransactionBase::AllocCursor(
aTrustParams = false;
#endif
OpenCursorParams::Type type = aParams.type();
const OpenCursorParams::Type type = aParams.type();
RefPtr<FullObjectStoreMetadata> objectStoreMetadata;
RefPtr<FullIndexMetadata> indexMetadata;
Cursor::Direction direction;
@ -14194,13 +14235,13 @@ PBackgroundIDBCursorParent* TransactionBase::AllocCursor(
.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;
@ -14209,12 +14250,12 @@ bool TransactionBase::StartCursor(PBackgroundIDBCursorParent* aActor,
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;
}
@ -14235,7 +14276,7 @@ NormalTransaction::NormalTransaction(
bool NormalTransaction::IsSameProcessActor() {
AssertIsOnBackgroundThread();
PBackgroundParent* actor = Manager()->Manager()->Manager();
PBackgroundParent* const actor = Manager()->Manager()->Manager();
MOZ_ASSERT(actor);
return !BackgroundParent::IsOtherProcessActor(actor);
@ -14270,7 +14311,7 @@ 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);
}
@ -14306,7 +14347,7 @@ NormalTransaction::AllocPBackgroundIDBRequestParent(
}
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);
@ -14318,7 +14359,7 @@ mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBRequestConstructor(
}
bool NormalTransaction::DeallocPBackgroundIDBRequestParent(
PBackgroundIDBRequestParent* aActor) {
PBackgroundIDBRequestParent* const aActor) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -14333,7 +14374,7 @@ PBackgroundIDBCursorParent* NormalTransaction::AllocPBackgroundIDBCursorParent(
}
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);
@ -14345,7 +14386,7 @@ mozilla::ipc::IPCResult NormalTransaction::RecvPBackgroundIDBCursorConstructor(
}
bool NormalTransaction::DeallocPBackgroundIDBCursorParent(
PBackgroundIDBCursorParent* aActor) {
PBackgroundIDBCursorParent* const aActor) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -14999,10 +15040,11 @@ bool VersionChangeTransaction::DeallocPBackgroundIDBCursorParent(
* 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),
@ -15051,7 +15093,7 @@ bool Cursor::VerifyRequestParams(const CursorRequestParams& aParams) const {
#ifdef DEBUG
{
RefPtr<FullObjectStoreMetadata> objectStoreMetadata =
const RefPtr<FullObjectStoreMetadata> objectStoreMetadata =
mTransaction->GetMetadataForObjectStoreId(mObjectStoreId);
if (objectStoreMetadata) {
MOZ_ASSERT(objectStoreMetadata == mObjectStoreMetadata);
@ -15062,7 +15104,7 @@ bool Cursor::VerifyRequestParams(const CursorRequestParams& aParams) const {
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);
@ -15167,7 +15209,7 @@ bool Cursor::Start(const OpenCursorParams& aParams) {
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();
@ -15249,7 +15291,7 @@ void Cursor::SendResponseInternal(
}
// 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!");
}
@ -15327,7 +15369,7 @@ mozilla::ipc::IPCResult Cursor::RecvContinue(const CursorRequestParams& aParams,
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);
@ -16522,7 +16564,7 @@ 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));
@ -16547,7 +16589,7 @@ void QuotaClient::DeleteTimerCallback(nsITimer* aTimer, void* aClosure) {
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;
@ -16643,9 +16685,10 @@ nsresult QuotaClient::GetDatabaseFilenames(
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;
@ -16798,7 +16841,7 @@ 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;
}
@ -16831,7 +16874,7 @@ nsresult DeleteFilesRunnable::DeleteFile(int64_t aFileId) {
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(
@ -16930,7 +16973,7 @@ void DeleteFilesRunnable::DirectoryLockAcquired(DirectoryLock* aLock) {
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
@ -17034,7 +17077,7 @@ nsresult Maintenance::CreateIndexedDatabaseManager() {
return NS_ERROR_ABORT;
}
IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
IndexedDatabaseManager* const mgr = IndexedDatabaseManager::GetOrCreate();
if (NS_WARN_IF(!mgr)) {
return NS_ERROR_FAILURE;
}
@ -17079,7 +17122,7 @@ nsresult Maintenance::DirectoryOpen() {
return NS_ERROR_ABORT;
}
QuotaManager* quotaManager = QuotaManager::Get();
QuotaManager* const quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
mState = State::DirectoryWorkOpen;
@ -17108,7 +17151,7 @@ nsresult Maintenance::DirectoryWork() {
return NS_ERROR_ABORT;
}
QuotaManager* quotaManager = QuotaManager::Get();
QuotaManager* const quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
nsresult rv = quotaManager->EnsureStorageIsInitialized();
@ -17116,7 +17159,8 @@ nsresult Maintenance::DirectoryWork() {
return rv;
}
nsCOMPtr<nsIFile> storageDir = GetFileForPath(quotaManager->GetStoragePath());
const nsCOMPtr<nsIFile> storageDir =
GetFileForPath(quotaManager->GetStoragePath());
if (NS_WARN_IF(!storageDir)) {
return NS_ERROR_FAILURE;
}
@ -17422,10 +17466,9 @@ nsresult Maintenance::BeginDatabaseMaintenance() {
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();
@ -17467,7 +17510,7 @@ void Maintenance::Finish() {
// 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);
@ -17609,7 +17652,7 @@ void DatabaseMaintenance::PerformMaintenanceOnDatabase() {
return;
}
nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
const nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
MOZ_ASSERT(databaseFile);
nsCOMPtr<mozIStorageConnection> connection;
@ -17845,7 +17888,7 @@ nsresult DatabaseMaintenance::DetermineMaintenanceAction(
"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)) {
@ -18167,9 +18210,9 @@ 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))) {
@ -18350,8 +18393,8 @@ nsresult DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob(
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,
@ -18364,7 +18407,8 @@ nsresult DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob(
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))) {
@ -18408,7 +18452,7 @@ nsresult DatabaseOperationBase::GetStructuredCloneReadInfoFromExternalBlob(
// 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!");
@ -18424,7 +18468,8 @@ nsresult DatabaseOperationBase::GetStructuredCloneReadInfoFromExternalBlob(
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;
}
@ -18435,8 +18480,8 @@ nsresult DatabaseOperationBase::GetStructuredCloneReadInfoFromExternalBlob(
return rv;
}
RefPtr<SnappyUncompressInputStream> snappyInputStream =
new SnappyUncompressInputStream(fileInputStream);
const auto snappyInputStream =
MakeRefPtr<SnappyUncompressInputStream>(fileInputStream);
do {
char buffer[kFileCopyBufferSize];
@ -18579,12 +18624,12 @@ nsresult DatabaseOperationBase::GetUniqueIndexTableForObjectStore(
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(),
@ -19580,7 +19625,7 @@ nsresult FactoryOp::SendToIOThread() {
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.
@ -19895,7 +19940,7 @@ nsresult FactoryOp::OpenDirectory() {
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;
@ -20171,7 +20216,7 @@ nsresult OpenDatabaseOp::DoDatabaseWork() {
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;
@ -21508,7 +21553,7 @@ nsresult DeleteDatabaseOp::DoDatabaseWork() {
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;
@ -21628,7 +21673,7 @@ nsresult DeleteDatabaseOp::DispatchToWorkThread() {
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(),
@ -22422,7 +22467,7 @@ nsresult DatabaseOp::SendToIOThread() {
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;
@ -25700,7 +25745,8 @@ void Cursor::CursorOpBase::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);
@ -26027,11 +26073,11 @@ nsresult Cursor::OpenOp::DoObjectStoreKeyDatabaseWork(
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);
@ -26040,8 +26086,8 @@ nsresult Cursor::OpenOp::DoObjectStoreKeyDatabaseWork(
// 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);
@ -26095,22 +26141,19 @@ nsresult Cursor::OpenOp::DoIndexDatabaseWork(DatabaseConnection* aConnection) {
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(
@ -26154,8 +26197,8 @@ nsresult Cursor::OpenOp::DoIndexDatabaseWork(DatabaseConnection* aConnection) {
// 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);
@ -26217,22 +26260,18 @@ nsresult Cursor::OpenOp::DoIndexKeyDatabaseWork(
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(
@ -26266,8 +26305,8 @@ nsresult Cursor::OpenOp::DoIndexKeyDatabaseWork(
// 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);
@ -26650,7 +26689,7 @@ nsresult GetFileReferencesHelper::DispatchAndReturnFileReferences(
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);
@ -26910,7 +26949,7 @@ nsresult FileHelper::RemoveFile(nsIFile* aFile, nsIFile* aJournalFile) {
}
if (mFileManager->EnforcingQuota()) {
QuotaManager* quotaManager = QuotaManager::Get();
QuotaManager* const quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
quotaManager->DecreaseUsageForOrigin(

Просмотреть файл

@ -739,12 +739,9 @@ already_AddRefed<IDBRequest> IDBCursor::Delete(JSContext* aCx,
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);

Просмотреть файл

@ -66,7 +66,7 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
RefPtr<IDBIndex> mSourceIndex;
// mSourceObjectStore or mSourceIndex will hold this alive.
IDBTransaction* mTransaction;
IDBTransaction* const mTransaction;
// These are cycle-collected!
JS::Heap<JS::Value> mCachedKey;

Просмотреть файл

@ -34,7 +34,7 @@ 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);
@ -138,7 +138,7 @@ const nsString& IDBIndex::Name() const {
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) {
@ -372,13 +372,11 @@ already_AddRefed<IDBRequest> IDBIndex::GetAllInternal(
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);
@ -432,8 +430,8 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
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;
@ -444,7 +442,8 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
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};
@ -478,7 +477,7 @@ already_AddRefed<IDBRequest> IDBIndex::OpenCursorInternal(
IDB_LOG_STRINGIFY(direction));
}
BackgroundCursorChild* actor =
BackgroundCursorChild* const actor =
new BackgroundCursorChild(request, this, direction);
mObjectStore->Transaction()->OpenCursor(actor, params);
@ -496,7 +495,7 @@ already_AddRefed<IDBRequest> IDBIndex::Count(JSContext* aCx,
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;

Просмотреть файл

@ -182,7 +182,7 @@ already_AddRefed<IDBRequest> GenerateRequest(JSContext* aCx,
MOZ_ASSERT(aObjectStore);
aObjectStore->AssertIsOnOwningThread();
IDBTransaction* transaction = aObjectStore->Transaction();
IDBTransaction* const transaction = aObjectStore->Transaction();
RefPtr<IDBRequest> request = IDBRequest::Create(
aCx, aObjectStore, transaction->Database(), transaction);
@ -198,7 +198,7 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
MOZ_ASSERT(aWriter);
MOZ_ASSERT(aClosure);
auto* cloneWriteInfo =
auto* const cloneWriteInfo =
static_cast<IDBObjectStore::StructuredCloneWriteInfo*>(aClosure);
if (JS_GetClass(aObj) == IDBObjectStore::DummyPropClass()) {
@ -219,7 +219,7 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
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
@ -257,12 +257,12 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
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)) ||
@ -273,7 +273,7 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
return false;
}
StructuredCloneFile* newFile = cloneWriteInfo->mFiles.AppendElement();
StructuredCloneFile* const newFile = cloneWriteInfo->mFiles.AppendElement();
newFile->mMutableFile = mutableFile;
newFile->mType = StructuredCloneFile::eMutableFile;
@ -284,16 +284,16 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
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)) {
@ -313,19 +313,20 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
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,
@ -336,7 +337,8 @@ bool StructuredCloneWriteCallback(JSContext* aCx,
}
}
StructuredCloneFile* newFile = cloneWriteInfo->mFiles.AppendElement();
StructuredCloneFile* const newFile =
cloneWriteInfo->mFiles.AppendElement();
newFile->mBlob = blob;
newFile->mType = StructuredCloneFile::eBlob;
@ -356,7 +358,8 @@ bool CopyingStructuredCloneWriteCallback(JSContext* 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);
@ -378,7 +381,7 @@ bool CopyingStructuredCloneWriteCallback(JSContext* aCx,
return false;
}
StructuredCloneFile* newFile = cloneInfo->mFiles.AppendElement();
StructuredCloneFile* const newFile = cloneInfo->mFiles.AppendElement();
newFile->mBlob = blob;
newFile->mType = StructuredCloneFile::eBlob;
@ -401,7 +404,7 @@ bool CopyingStructuredCloneWriteCallback(JSContext* aCx,
return false;
}
StructuredCloneFile* newFile = cloneInfo->mFiles.AppendElement();
StructuredCloneFile* const newFile = cloneInfo->mFiles.AppendElement();
newFile->mMutableFile = mutableFile;
newFile->mType = StructuredCloneFile::eMutableFile;
@ -426,7 +429,7 @@ nsresult GetAddInfoCallback(JSContext* aCx, void* aClosure) {
MOZ_ASSERT(aCx);
auto* data = static_cast<GetAddInfoClosure*>(aClosure);
auto* const data = static_cast<GetAddInfoClosure*>(aClosure);
MOZ_ASSERT(data);
data->mCloneWriteInfo.mOffsetToKeyProp = 0;
@ -460,7 +463,7 @@ bool StructuredCloneReadString(JSStructuredCloneReader* aReader,
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!");
@ -630,12 +633,13 @@ class ValueDeserializationHelper {
* 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);
}
@ -673,7 +677,7 @@ class ValueDeserializationHelper {
// 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);
@ -689,7 +693,7 @@ class ValueDeserializationHelper {
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);
@ -740,7 +744,7 @@ JSObject* CommonStructuredCloneReadCallback(JSContext* aCx,
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);
@ -815,7 +819,7 @@ JSObject* CopyingStructuredCloneReadCallback(JSContext* aCx,
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);
@ -847,10 +851,10 @@ JSObject* CopyingStructuredCloneReadCallback(JSContext* aCx,
{
// 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);
@ -1095,11 +1099,11 @@ class SandboxHolder final {
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);
@ -1173,7 +1177,7 @@ class DeserializeIndexValueHelper final : public Runnable {
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)) {
@ -1181,7 +1185,7 @@ class DeserializeIndexValueHelper final : public Runnable {
return NS_OK;
}
JSAutoRealm ar(cx, global);
const JSAutoRealm ar(cx, global);
JS::Rooted<JS::Value> value(cx);
const nsresult rv = DeserializeIndexValue(cx, &value);
@ -1234,9 +1238,9 @@ class DeserializeIndexValueHelper final : public Runnable {
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;
@ -1266,7 +1270,8 @@ class DeserializeUpgradeValueHelper final : public Runnable {
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;
}
@ -1295,10 +1300,10 @@ class DeserializeUpgradeValueHelper final : public Runnable {
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;
@ -1333,7 +1338,7 @@ class DeserializeUpgradeValueHelper final : public Runnable {
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();
@ -1366,7 +1371,7 @@ void IDBObjectStore::DeserializeIndexValueToUpdateInfos(
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);
@ -1377,7 +1382,7 @@ 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);
}
@ -1404,11 +1409,11 @@ void IDBObjectStore::GetAddInfo(JSContext* aCx, ValueWrapper& aValueWrapper,
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);
@ -1443,7 +1448,7 @@ void IDBObjectStore::GetAddInfo(JSContext* aCx, ValueWrapper& aValueWrapper,
{
const nsTArray<IndexMetadata>& indexes = mSpec->indexes();
uint32_t idxCount = indexes.Length();
const uint32_t idxCount = indexes.Length();
aUpdateInfoArray.SetCapacity(idxCount); // Pretty good estimate
@ -1530,8 +1535,8 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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();
@ -1562,12 +1567,12 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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) {
@ -1575,7 +1580,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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();
@ -1593,7 +1598,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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();
@ -1612,7 +1617,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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();
@ -1634,12 +1639,9 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
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);
@ -1755,8 +1757,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::Clear(JSContext* aCx,
return nullptr;
}
ObjectStoreClearParams params;
params.objectStoreId() = Id();
const ObjectStoreClearParams params = {Id()};
RefPtr<IDBRequest> request = GenerateRequest(aCx, this);
MOZ_ASSERT(request);
@ -1942,12 +1943,9 @@ already_AddRefed<IDBRequest> IDBObjectStore::GetInternal(
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);
@ -2030,7 +2028,7 @@ already_AddRefed<IDBIndex> IDBObjectStore::CreateIndex(
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;
@ -2075,7 +2073,7 @@ already_AddRefed<IDBIndex> IDBObjectStore::CreateIndex(
}
#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
@ -2088,7 +2086,7 @@ already_AddRefed<IDBIndex> IDBObjectStore::CreateIndex(
locale = IndexedDatabaseManager::GetLocale();
}
IndexMetadata* metadata = indexes.AppendElement(
IndexMetadata* const metadata = indexes.AppendElement(
IndexMetadata(transaction->NextIndexId(), nsString(aName), keyPath,
locale, aOptionalParameters.mUnique,
aOptionalParameters.mMultiEntry, autoLocale));
@ -2259,7 +2257,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::OpenCursorInternal(
return nullptr;
}
int64_t objectStoreId = Id();
const int64_t objectStoreId = Id();
Maybe<SerializedKeyRange> optionalKeyRange;
@ -2270,7 +2268,8 @@ already_AddRefed<IDBRequest> IDBObjectStore::OpenCursorInternal(
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};
@ -2304,7 +2303,7 @@ already_AddRefed<IDBRequest> IDBObjectStore::OpenCursorInternal(
IDB_LOG_STRINGIFY(keyRange), IDB_LOG_STRINGIFY(direction));
}
BackgroundCursorChild* actor =
BackgroundCursorChild* const actor =
new BackgroundCursorChild(request, this, direction);
mTransaction->OpenCursor(actor, params);
@ -2415,7 +2414,7 @@ void IDBObjectStore::SetName(const nsAString& aName, ErrorResult& aRv) {
// 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)) {