зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1756675 - Post: Add logging for BackgroundTask temporary profile setup and teardown. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D139329
This commit is contained in:
Родитель
e6b2a28c1c
Коммит
832f6289ae
|
@ -19,6 +19,15 @@ namespace mozilla {
|
|||
|
||||
NS_IMPL_ISUPPORTS(BackgroundTasks, nsIBackgroundTasks);
|
||||
|
||||
BackgroundTasks::BackgroundTasks(Maybe<nsCString> aBackgroundTask)
|
||||
: mBackgroundTask(std::move(aBackgroundTask)) {
|
||||
// Log when a background task is created.
|
||||
if (mBackgroundTask.isSome()) {
|
||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Info,
|
||||
("Created background task: %s", mBackgroundTask->get()));
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundTasks::Init(Maybe<nsCString> aBackgroundTask) {
|
||||
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
|
@ -31,6 +40,8 @@ void BackgroundTasks::Init(Maybe<nsCString> aBackgroundTask) {
|
|||
void BackgroundTasks::Shutdown() {
|
||||
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
MOZ_LOG(sBackgroundTasksLog, LogLevel::Info, ("Shutdown"));
|
||||
|
||||
if (!sSingleton) {
|
||||
return;
|
||||
}
|
||||
|
@ -38,6 +49,16 @@ void BackgroundTasks::Shutdown() {
|
|||
if (sSingleton->mProfD) {
|
||||
AutoSuspendLateWriteChecks suspend;
|
||||
|
||||
// Log that the temporary profile is being removed.
|
||||
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Info)) {
|
||||
nsAutoString path;
|
||||
if (NS_SUCCEEDED(sSingleton->mProfD->GetPath(path))) {
|
||||
MOZ_LOG(
|
||||
sBackgroundTasksLog, mozilla::LogLevel::Info,
|
||||
("Removing profile: %s", NS_LossyConvertUTF16toASCII(path).get()));
|
||||
}
|
||||
}
|
||||
|
||||
Unused << sSingleton->mProfD->Remove(/* aRecursive */ true);
|
||||
}
|
||||
|
||||
|
@ -83,8 +104,25 @@ nsresult BackgroundTasks::CreateTemporaryProfileDirectory(
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return GetSingleton()->CreateTemporaryProfileDirectoryImpl(aInstallHash,
|
||||
aFile);
|
||||
nsresult rv =
|
||||
GetSingleton()->CreateTemporaryProfileDirectoryImpl(aInstallHash, aFile);
|
||||
|
||||
// Log whether the temporary profile was created.
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Warning,
|
||||
("Failed to create temporary profile directory!"));
|
||||
} else {
|
||||
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Info)) {
|
||||
nsAutoString path;
|
||||
if (aFile && *aFile && NS_SUCCEEDED((*aFile)->GetPath(path))) {
|
||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Info,
|
||||
("Created temporary profile directory: %s",
|
||||
NS_LossyConvertUTF16toASCII(path).get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool BackgroundTasks::IsUsingTemporaryProfile() {
|
||||
|
@ -175,4 +213,6 @@ nsresult BackgroundTasks::OverrideBackgroundTaskNameForTesting(
|
|||
|
||||
StaticRefPtr<BackgroundTasks> BackgroundTasks::sSingleton;
|
||||
|
||||
LazyLogModule BackgroundTasks::sBackgroundTasksLog("BackgroundTasks");
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
|
@ -25,8 +26,7 @@ class BackgroundTasks final : public nsIBackgroundTasks {
|
|||
NS_DECL_NSIBACKGROUNDTASKS
|
||||
|
||||
public:
|
||||
explicit BackgroundTasks(Maybe<nsCString> aBackgroundTask)
|
||||
: mBackgroundTask(aBackgroundTask) {}
|
||||
explicit BackgroundTasks(Maybe<nsCString> aBackgroundTask);
|
||||
|
||||
static void Init(Maybe<nsCString> aBackgroundTask);
|
||||
|
||||
|
@ -67,6 +67,7 @@ class BackgroundTasks final : public nsIBackgroundTasks {
|
|||
|
||||
protected:
|
||||
static StaticRefPtr<BackgroundTasks> sSingleton;
|
||||
static LazyLogModule sBackgroundTasksLog;
|
||||
|
||||
Maybe<nsCString> mBackgroundTask;
|
||||
nsCOMPtr<nsIFile> mProfD;
|
||||
|
|
Загрузка…
Ссылка в новой задаче