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 { ...@@ -60,10 +60,12 @@ struct CGroups {
foreground_type == FILE_SYSTEM_CGROUP && foreground_type == FILE_SYSTEM_CGROUP &&
background_type == FILE_SYSTEM_CGROUP; background_type == FILE_SYSTEM_CGROUP;
} }
};
base::LazyInstance<CGroups>::DestructorAtExit g_cgroups = static CGroups& Get() {
LAZY_INSTANCE_INITIALIZER; static auto& groups = *new CGroups;
return groups;
}
};
#else #else
const int kBackgroundPriority = 5; const int kBackgroundPriority = 5;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -87,7 +89,7 @@ struct CheckForNicePermission { ...@@ -87,7 +89,7 @@ struct CheckForNicePermission {
// static // static
bool Process::CanBackgroundProcesses() { bool Process::CanBackgroundProcesses() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (g_cgroups.Get().enabled) if (CGroups::Get().enabled)
return true; return true;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -100,7 +102,7 @@ bool Process::IsProcessBackgrounded() const { ...@@ -100,7 +102,7 @@ bool Process::IsProcessBackgrounded() const {
DCHECK(IsValid()); DCHECK(IsValid());
#if defined(OS_CHROMEOS) #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. // Used to allow reading the process priority from proc on thread launch.
base::ThreadRestrictions::ScopedAllowIO allow_io; base::ThreadRestrictions::ScopedAllowIO allow_io;
std::string proc; std::string proc;
...@@ -119,11 +121,10 @@ bool Process::SetProcessBackgrounded(bool background) { ...@@ -119,11 +121,10 @@ bool Process::SetProcessBackgrounded(bool background) {
DCHECK(IsValid()); DCHECK(IsValid());
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (g_cgroups.Get().enabled) { if (CGroups::Get().enabled) {
std::string pid = IntToString(process_); std::string pid = IntToString(process_);
const base::FilePath file = const base::FilePath file = background ? CGroups::Get().background_file
background ? : CGroups::Get().foreground_file;
g_cgroups.Get().background_file : g_cgroups.Get().foreground_file;
return base::WriteFile(file, pid.c_str(), pid.size()) > 0; return base::WriteFile(file, pid.c_str(), pid.size()) > 0;
} }
#endif // defined(OS_CHROMEOS) #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