#include "chrome/browser/lifetime/browser_shutdown.h"
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include "base/clang_profiling_buildflags.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "build/config/compiler/compiler_buildflags.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/buildflags.h"
#include "chrome/browser/lifetime/switch_utils.h"
#include "chrome/browser/profiles/nuke_profile_directory_utils.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/crash/core/common/crash_key.h"
#include "components/metrics/metrics_service.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/tracing/common/tracing_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/tracing_controller.h"
#include "content/public/common/content_switches.h"
#include "printing/buildflags/buildflags.h"
#include "rlz/buildflags/buildflags.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/first_run/upgrade_util_win.h"
#include "chrome/browser/win/browser_util.h"
#endif
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/first_run/upgrade_util.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/boot_times_recorder/boot_times_recorder.h"
#include "chrome/browser/lifetime/application_lifetime_chromeos.h"
#include "chrome/browser/lifetime/termination_notification.h"
#endif
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
#include "chrome/browser/background/background_mode_manager.h"
#endif
#if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h"
#endif
#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) && BUILDFLAG(CLANG_PGO)
#include "base/run_loop.h"
#include "content/public/browser/profiling_utils.h"
#endif
namespace browser_shutdown {
namespace {
bool g_trying_to_quit = …;
base::Time* g_shutdown_started = …;
ShutdownType g_shutdown_type = …;
int g_shutdown_num_processes;
int g_shutdown_num_processes_slow;
const char* ToShutdownTypeString(ShutdownType type) { … }
void CheckAccessedOnCorrectThread() { … }
}
void RegisterPrefs(PrefRegistrySimple* registry) { … }
void OnShutdownStarting(ShutdownType type) { … }
bool HasShutdownStarted() { … }
bool ShouldIgnoreUnloadHandlers() { … }
ShutdownType GetShutdownType() { … }
#if !BUILDFLAG(IS_ANDROID)
bool ShutdownPreThreadsStop() { … }
void RecordShutdownMetrics() { … }
bool RecordShutdownInfoPrefs() { … }
void ShutdownPostThreadsStop(RestartMode restart_mode) { … }
#endif
void SetTryingToQuit(bool quitting) { … }
bool IsTryingToQuit() { … }
base::AutoReset<ShutdownType> SetShutdownTypeForTesting(
ShutdownType shutdown_type) { … }
void ResetShutdownGlobalsForTesting() { … }
}