зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1734151 - Move the shutdown started check into public methods for shutdown step recording; r=hxu
This will allow to add a method like MaybeRecordQuotaManagerShutdownStepWith which will take a function for generating the string. Differential Revision: https://phabricator.services.mozilla.com/D127545
This commit is contained in:
Родитель
9eb751c548
Коммит
53d543c18f
|
@ -3733,13 +3733,28 @@ nsresult QuotaManager::Init() {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void QuotaManager::MaybeRecordQuotaClientShutdownStep(
|
||||||
|
const Client::Type aClientType, const nsACString& aStepDescription) {
|
||||||
|
// Callable on any thread.
|
||||||
|
|
||||||
|
auto* const quotaManager = QuotaManager::Get();
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(quotaManager);
|
||||||
|
|
||||||
|
if (quotaManager->ShutdownStarted()) {
|
||||||
|
quotaManager->RecordShutdownStep(Some(aClientType), aStepDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void QuotaManager::SafeMaybeRecordQuotaClientShutdownStep(
|
void QuotaManager::SafeMaybeRecordQuotaClientShutdownStep(
|
||||||
const Client::Type aClientType, const nsACString& aStepDescription) {
|
const Client::Type aClientType, const nsACString& aStepDescription) {
|
||||||
// Callable on any thread.
|
// Callable on any thread.
|
||||||
|
|
||||||
if (auto* const quotaManager = QuotaManager::Get()) {
|
auto* const quotaManager = QuotaManager::Get();
|
||||||
quotaManager->MaybeRecordShutdownStep(Some(aClientType), aStepDescription);
|
|
||||||
|
if (quotaManager && quotaManager->ShutdownStarted()) {
|
||||||
|
quotaManager->RecordShutdownStep(Some(aClientType), aStepDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3747,17 +3762,16 @@ void QuotaManager::MaybeRecordQuotaManagerShutdownStep(
|
||||||
const nsACString& aStepDescription) {
|
const nsACString& aStepDescription) {
|
||||||
// Callable on any thread.
|
// Callable on any thread.
|
||||||
|
|
||||||
MaybeRecordShutdownStep(Nothing{}, aStepDescription);
|
if (ShutdownStarted()) {
|
||||||
|
RecordShutdownStep(Nothing{}, aStepDescription);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuotaManager::MaybeRecordShutdownStep(
|
bool QuotaManager::ShutdownStarted() const { return mShutdownStarted; }
|
||||||
const Maybe<Client::Type> aClientType, const nsACString& aStepDescription) {
|
|
||||||
if (!mShutdownStarted) {
|
void QuotaManager::RecordShutdownStep(const Maybe<Client::Type> aClientType,
|
||||||
// We are not shutting down yet, we intentionally ignore this here to avoid
|
const nsACString& aStepDescription) {
|
||||||
// that every caller has to make a distinction for shutdown vs. non-shutdown
|
MOZ_ASSERT(mShutdownStarted);
|
||||||
// situations.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TimeDuration elapsedSinceShutdownStart =
|
const TimeDuration elapsedSinceShutdownStart =
|
||||||
TimeStamp::NowLoRes() - *mShutdownStartedAt;
|
TimeStamp::NowLoRes() - *mShutdownStartedAt;
|
||||||
|
|
|
@ -374,13 +374,7 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||||
// Record a quota client shutdown step, if shutting down.
|
// Record a quota client shutdown step, if shutting down.
|
||||||
// Assumes that the QuotaManager singleton is alive.
|
// Assumes that the QuotaManager singleton is alive.
|
||||||
static void MaybeRecordQuotaClientShutdownStep(
|
static void MaybeRecordQuotaClientShutdownStep(
|
||||||
const Client::Type aClientType, const nsACString& aStepDescription) {
|
const Client::Type aClientType, const nsACString& aStepDescription);
|
||||||
// Callable on any thread.
|
|
||||||
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(QuotaManager::Get());
|
|
||||||
QuotaManager::Get()->MaybeRecordShutdownStep(Some(aClientType),
|
|
||||||
aStepDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Record a quota client shutdown step, if shutting down.
|
// Record a quota client shutdown step, if shutting down.
|
||||||
// Checks if the QuotaManager singleton is alive.
|
// Checks if the QuotaManager singleton is alive.
|
||||||
|
@ -553,8 +547,10 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||||
|
|
||||||
int64_t GenerateDirectoryLockId();
|
int64_t GenerateDirectoryLockId();
|
||||||
|
|
||||||
void MaybeRecordShutdownStep(Maybe<Client::Type> aClientType,
|
bool ShutdownStarted() const;
|
||||||
const nsACString& aStepDescription);
|
|
||||||
|
void RecordShutdownStep(Maybe<Client::Type> aClientType,
|
||||||
|
const nsACString& aStepDescription);
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
auto ExecuteInitialization(Initialization aInitialization, Func&& aFunc)
|
auto ExecuteInitialization(Initialization aInitialization, Func&& aFunc)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче