Bug 1600283 - Reduce uses of plain pointers. r=dom-workers-and-storage-reviewers,janv

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-12-13 12:18:21 +00:00
Родитель 3137f60858
Коммит 7e8ae185d6
3 изменённых файлов: 31 добавлений и 39 удалений

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

@ -3438,10 +3438,9 @@ void BackgroundCursorChild::SendContinueInternal(
// This is accompanied by invalidating cached entries at proper locations to
// make it correct. To avoid this, further changes are necessary, see Bug
// 1580499.
nsCOMPtr<nsIRunnable> continueRunnable = new DelayedActionRunnable(
this, &BackgroundCursorChild::CompleteContinueRequestFromCache);
MOZ_ALWAYS_TRUE(
NS_SUCCEEDED(NS_DispatchToCurrentThread(continueRunnable.forget())));
MOZ_ALWAYS_SUCCEEDS(
NS_DispatchToCurrentThread(MakeAndAddRef<DelayedActionRunnable>(
this, &BackgroundCursorChild::CompleteContinueRequestFromCache)));
// TODO: Could we preload further entries in the background when the size of
// mCachedResponses falls under some threshold? Or does the response
@ -3588,10 +3587,10 @@ void BackgroundCursorChild::HandleResponse(const void_t& aResponse) {
DispatchSuccessEvent(&helper);
if (!mCursor) {
nsCOMPtr<nsIRunnable> deleteRunnable = new DelayedActionRunnable(
this, &BackgroundCursorChild::SendDeleteMeInternal);
MOZ_ALWAYS_SUCCEEDS(this->GetActorEventTarget()->Dispatch(
deleteRunnable.forget(), NS_DISPATCH_NORMAL));
MakeAndAddRef<DelayedActionRunnable>(
this, &BackgroundCursorChild::SendDeleteMeInternal),
NS_DISPATCH_NORMAL));
}
}

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

@ -10804,11 +10804,9 @@ void DatabaseConnection::UpdateRefcountFunction::Reset() {
// quota usage) before we fire the commit event.
for (const auto& entry : mFileInfoEntries) {
FileInfoEntry* const value = entry.GetData();
MOZ_ASSERT(value);
FileInfo* const fileInfo = value->mFileInfo.forget().take();
MOZ_ASSERT(fileInfo);
CustomCleanupCallback customCleanupCallback;
@ -11417,9 +11415,8 @@ void ConnectionPool::WaitForDatabasesToComplete(
return;
}
nsAutoPtr<DatabasesCompleteCallback> callback(
mCompleteCallbacks.EmplaceBack(
new DatabasesCompleteCallback(std::move(aDatabaseIds), aCallback));
mCompleteCallbacks.AppendElement(callback.forget());
}
void ConnectionPool::Shutdown() {
@ -11464,10 +11461,13 @@ void ConnectionPool::Cleanup() {
if (!mCompleteCallbacks.IsEmpty()) {
// Run all callbacks manually now.
// TODO: Can a callback cause another entry to be added to
// mCompleteCallbacks? This would be skipped when iterating like this.
for (uint32_t count = mCompleteCallbacks.Length(), index = 0; index < count;
index++) {
nsAutoPtr<DatabasesCompleteCallback> completeCallback(
mCompleteCallbacks[index].forget());
// TODO: Why do we need to move the callback here to a local variable?
// mCompleteCallbacks is cleared afterwards anyway.
const auto completeCallback = std::move(mCompleteCallbacks[index]);
MOZ_ASSERT(completeCallback);
MOZ_ASSERT(completeCallback->mCallback);
@ -11730,13 +11730,8 @@ bool ConnectionPool::ScheduleTransaction(TransactionInfo* aTransactionInfo,
if (!queuedRunnables.IsEmpty()) {
for (auto& queuedRunnable : queuedRunnables) {
// TODO: Why do we need this? queuedRunnables is cleared afterwards
// anyway.
nsCOMPtr<nsIRunnable> runnable;
queuedRunnable.swap(runnable);
MOZ_ALWAYS_SUCCEEDS(dbInfo->mThreadInfo.mThread->Dispatch(
runnable.forget(), NS_DISPATCH_NORMAL));
queuedRunnable.forget(), NS_DISPATCH_NORMAL));
}
queuedRunnables.Clear();
@ -12011,8 +12006,7 @@ void ConnectionPool::PerformIdleDatabaseMaintenance(
MOZ_ASSERT(mIdleDatabases.Contains(aDatabaseInfo));
MOZ_ASSERT(!mDatabasesPerformingIdleMaintenance.Contains(aDatabaseInfo));
nsCOMPtr<nsIRunnable> runnable = new IdleConnectionRunnable(
aDatabaseInfo, aDatabaseInfo->mNeedsCheckpoint);
const bool neededCheckpoint = aDatabaseInfo->mNeedsCheckpoint;
aDatabaseInfo->mNeedsCheckpoint = false;
aDatabaseInfo->mIdle = false;
@ -12020,7 +12014,8 @@ void ConnectionPool::PerformIdleDatabaseMaintenance(
mDatabasesPerformingIdleMaintenance.AppendElement(aDatabaseInfo);
MOZ_ALWAYS_SUCCEEDS(aDatabaseInfo->mThreadInfo.mThread->Dispatch(
runnable.forget(), NS_DISPATCH_NORMAL));
MakeAndAddRef<IdleConnectionRunnable>(aDatabaseInfo, neededCheckpoint),
NS_DISPATCH_NORMAL));
}
void ConnectionPool::CloseDatabase(DatabaseInfo* aDatabaseInfo) {
@ -12035,10 +12030,9 @@ void ConnectionPool::CloseDatabase(DatabaseInfo* aDatabaseInfo) {
aDatabaseInfo->mNeedsCheckpoint = false;
aDatabaseInfo->mClosing = true;
nsCOMPtr<nsIRunnable> runnable = new CloseConnectionRunnable(aDatabaseInfo);
MOZ_ALWAYS_SUCCEEDS(aDatabaseInfo->mThreadInfo.mThread->Dispatch(
runnable.forget(), NS_DISPATCH_NORMAL));
MakeAndAddRef<CloseConnectionRunnable>(aDatabaseInfo),
NS_DISPATCH_NORMAL));
}
bool ConnectionPool::CloseDatabaseWhenIdleInternal(
@ -12625,9 +12619,7 @@ already_AddRefed<Factory> Factory::Create(const LoggingInfo& aLoggingInfo) {
loggingInfo);
}
RefPtr<Factory> actor = new Factory(loggingInfo.forget());
return actor.forget();
return RefPtr<Factory>(new Factory(loggingInfo.forget())).forget();
}
void Factory::ActorDestroy(ActorDestroyReason aWhy) {
@ -12722,12 +12714,15 @@ Factory::AllocPBackgroundIDBFactoryRequestParent(
RefPtr<ContentParent> contentParent =
BackgroundParent::GetContentParent(Manager());
RefPtr<FactoryOp> actor;
if (aParams.type() == FactoryRequestParams::TOpenDatabaseRequestParams) {
actor = new OpenDatabaseOp(this, contentParent.forget(), *commonParams);
} else {
actor = new DeleteDatabaseOp(this, contentParent.forget(), *commonParams);
}
auto actor = [&]() -> RefPtr<FactoryOp> {
if (aParams.type() == FactoryRequestParams::TOpenDatabaseRequestParams) {
return MakeRefPtr<OpenDatabaseOp>(this, contentParent.forget(),
*commonParams);
} else {
return MakeRefPtr<DeleteDatabaseOp>(this, contentParent.forget(),
*commonParams);
}
}();
gFactoryOps->AppendElement(actor);
@ -16685,9 +16680,7 @@ void QuotaClient::StartIdleMaintenance() {
mBackgroundThread = GetCurrentThreadEventTarget();
RefPtr<Maintenance> maintenance = new Maintenance(this);
mMaintenanceQueue.AppendElement(maintenance.forget());
mMaintenanceQueue.EmplaceBack(MakeRefPtr<Maintenance>(this));
ProcessMaintenanceQueue();
}

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

@ -299,9 +299,9 @@ void IDBDatabase::RevertToPreviousState() {
// Hold the current spec alive until RefreshTransactionsSpecEnumerator has
// finished!
nsAutoPtr<DatabaseSpec> currentSpec(mSpec.forget());
auto currentSpec = std::move(mSpec);
mSpec = mPreviousSpec.forget();
mSpec = std::move(mPreviousSpec);
RefreshSpec(/* aMayDelete */ true);
}