// Copyright 2011 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_PROCESS_PROCESS_H_ #define BASE_PROCESS_PROCESS_H_ #include <string_view> #include "base/base_export.h" #include "base/process/process_handle.h" #include "base/time/time.h" #include "build/blink_buildflags.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #if BUILDFLAG(IS_WIN) #include "base/win/scoped_handle.h" #endif #if BUILDFLAG(IS_FUCHSIA) #include <lib/zx/process.h> #endif #if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) #include "base/feature_list.h" #endif // BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_APPLE) #include "base/process/port_provider_mac.h" #endif // BUILDFLAG(IS_APPLE) namespace base { #if BUILDFLAG(IS_CHROMEOS) // OneGroupPerRenderer feature places each foreground renderer process into // its own cgroup. This will cause the scheduler to use the aggregate runtime // of all threads in the process when deciding on the next thread to schedule. // It will help guarantee fairness between renderers. BASE_EXPORT BASE_DECLARE_FEATURE(kOneGroupPerRenderer); // Set all threads of a background process as backgrounded, which changes the // thread attributes including c-group, latency sensitivity. But the nice value // is unchanged, since background process is under the spell of the background // CPU c-group (via cgroup.procs). BASE_EXPORT BASE_DECLARE_FEATURE(kSetThreadBgForBgProcess); class ProcessPriorityDelegate; #endif #if BUILDFLAG(IS_WIN) BASE_EXPORT BASE_DECLARE_FEATURE(kUseEcoQoSForBackgroundProcess); BASE_EXPORT BASE_DECLARE_FEATURE(kEnableIntermediatePriority); #endif // Provides a move-only encapsulation of a process. // // This object is not tied to the lifetime of the underlying process: the // process may be killed and this object may still around, and it will still // claim to be valid. The actual behavior in that case is OS dependent like so: // // Windows: The underlying ProcessHandle will be valid after the process dies // and can be used to gather some information about that process, but most // methods will obviously fail. // // POSIX: The underlying ProcessHandle is not guaranteed to remain valid after // the process dies, and it may be reused by the system, which means that it may // end up pointing to the wrong process. class BASE_EXPORT Process { … }; #if BUILDFLAG(IS_CHROMEOS) // Exposed for testing. // Given the contents of the /proc/<pid>/cgroup file, determine whether the // process is backgrounded or not. BASE_EXPORT Process::Priority GetProcessPriorityCGroup( std::string_view cgroup_contents); #endif // BUILDFLAG(IS_CHROMEOS) } // namespace base #endif // BASE_PROCESS_PROCESS_H_