Commit 6c77b2f4 authored by danakj's avatar danakj Committed by Commit bot

base: Remove LazyInstance with AtExit from process_linux.cc

Replace it with a function static, as it has no destructor to run.

R=dcheng@chromium.org
BUG=698982

Review-Url: https://codereview.chromium.org/2736393004
Cr-Commit-Position: refs/heads/master@{#456079}
parent c34b8926
......@@ -60,10 +60,12 @@ struct CGroups {
foreground_type == FILE_SYSTEM_CGROUP &&
background_type == FILE_SYSTEM_CGROUP;
}
};
base::LazyInstance<CGroups>::DestructorAtExit g_cgroups =
LAZY_INSTANCE_INITIALIZER;
static CGroups& Get() {
static auto& groups = *new CGroups;
return groups;
}
};
#else
const int kBackgroundPriority = 5;
#endif // defined(OS_CHROMEOS)
......@@ -87,7 +89,7 @@ struct CheckForNicePermission {
// static
bool Process::CanBackgroundProcesses() {
#if defined(OS_CHROMEOS)
if (g_cgroups.Get().enabled)
if (CGroups::Get().enabled)
return true;
#endif // defined(OS_CHROMEOS)
......@@ -100,7 +102,7 @@ bool Process::IsProcessBackgrounded() const {
DCHECK(IsValid());
#if defined(OS_CHROMEOS)
if (g_cgroups.Get().enabled) {
if (CGroups::Get().enabled) {
// Used to allow reading the process priority from proc on thread launch.
base::ThreadRestrictions::ScopedAllowIO allow_io;
std::string proc;
......@@ -119,11 +121,10 @@ bool Process::SetProcessBackgrounded(bool background) {
DCHECK(IsValid());
#if defined(OS_CHROMEOS)
if (g_cgroups.Get().enabled) {
if (CGroups::Get().enabled) {
std::string pid = IntToString(process_);
const base::FilePath file =
background ?
g_cgroups.Get().background_file : g_cgroups.Get().foreground_file;
const base::FilePath file = background ? CGroups::Get().background_file
: CGroups::Get().foreground_file;
return base::WriteFile(file, pid.c_str(), pid.size()) > 0;
}
#endif // defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment