Skip to content

Commit

Permalink
Bug 1726714: Move IsShuttingDownOn(Non)BackgroundThread functions to …
Browse files Browse the repository at this point in the history
…Client base class. r=dom-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D140802
  • Loading branch information
jensstutte committed Apr 14, 2022
1 parent 67c200a commit 8140992
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 48 deletions.
16 changes: 0 additions & 16 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4925,22 +4925,6 @@ class QuotaClient final : public mozilla::dom::quota::Client {
return sInstance;
}

static bool IsShuttingDownOnBackgroundThread() {
AssertIsOnBackgroundThread();

if (sInstance) {
return sInstance->IsShuttingDown();
}

return QuotaManager::IsShuttingDown();
}

static bool IsShuttingDownOnNonBackgroundThread() {
MOZ_ASSERT(!IsOnBackgroundThread());

return QuotaManager::IsShuttingDown();
}

nsIEventTarget* BackgroundThread() const {
MOZ_ASSERT(mBackgroundThread);
return mBackgroundThread;
Expand Down
16 changes: 0 additions & 16 deletions dom/localstorage/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2623,22 +2623,6 @@ class QuotaClient final : public mozilla::dom::quota::Client {
return sInstance;
}

static bool IsShuttingDownOnBackgroundThread() {
AssertIsOnBackgroundThread();

if (sInstance) {
return sInstance->IsShuttingDown();
}

return QuotaManager::IsShuttingDown();
}

static bool IsShuttingDownOnNonBackgroundThread() {
MOZ_ASSERT(!IsOnBackgroundThread());

return QuotaManager::IsShuttingDown();
}

mozilla::Mutex& ShadowDatabaseMutex() {
MOZ_ASSERT(IsOnIOThread() || IsOnGlobalConnectionThread());

Expand Down
13 changes: 13 additions & 0 deletions dom/quota/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace mozilla::dom::quota {

using mozilla::ipc::AssertIsOnBackgroundThread;
using mozilla::ipc::IsOnBackgroundThread;

namespace {

Expand Down Expand Up @@ -246,4 +247,16 @@ void Client::FinalizeShutdownWorkThreads() {
FinalizeShutdown();
}

// static
bool Client::IsShuttingDownOnBackgroundThread() {
MOZ_ASSERT(IsOnBackgroundThread());
return QuotaManager::IsShuttingDown();
}

// static
bool Client::IsShuttingDownOnNonBackgroundThread() {
MOZ_ASSERT(!IsOnBackgroundThread());
return QuotaManager::IsShuttingDown();
}

} // namespace mozilla::dom::quota
8 changes: 8 additions & 0 deletions dom/quota/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class Client {

virtual void StopIdleMaintenance() = 0;

// Both variants just check for QuotaManager::IsShuttingDown()
// but assert to be on the right thread.
// They must not be used for re-entrance checks.
// Deprecated: This distinction is not needed anymore.
// QuotaClients should call QuotaManager::IsShuttingDown instead.
static bool IsShuttingDownOnBackgroundThread();
static bool IsShuttingDownOnNonBackgroundThread();

// Returns true if there is work that needs to be waited for.
bool InitiateShutdownWorkThreads();
void FinalizeShutdownWorkThreads();
Expand Down
16 changes: 0 additions & 16 deletions dom/simpledb/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,22 +452,6 @@ class QuotaClient final : public mozilla::dom::quota::Client {
public:
QuotaClient();

static bool IsShuttingDownOnBackgroundThread() {
AssertIsOnBackgroundThread();

if (sInstance) {
return sInstance->IsShuttingDown();
}

return QuotaManager::IsShuttingDown();
}

static bool IsShuttingDownOnNonBackgroundThread() {
MOZ_ASSERT(!IsOnBackgroundThread());

return QuotaManager::IsShuttingDown();
}

bool IsShuttingDown() const {
AssertIsOnBackgroundThread();

Expand Down

0 comments on commit 8140992

Please sign in to comment.