#include "chrome/browser/task_manager/sampling/task_group_sampler.h"
#include <limits>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/process/process_metrics.h"
#include "base/task/sequenced_task_runner.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/task_manager/task_manager_observer.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_thread.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <psapi.h>
#endif
namespace task_manager {
namespace {
std::unique_ptr<base::ProcessMetrics> CreateProcessMetrics(
base::ProcessHandle handle) { … }
}
TaskGroupSampler::TaskGroupSampler(
base::Process process,
const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner,
const OnCpuRefreshCallback& on_cpu_refresh,
const OnSwappedMemRefreshCallback& on_swapped_mem_refresh,
const OnIdleWakeupsCallback& on_idle_wakeups,
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC)
const OnOpenFdCountCallback& on_open_fd_count,
#endif
const OnProcessPriorityCallback& on_process_priority)
: … { … }
void TaskGroupSampler::Refresh(int64_t refresh_flags) { … }
TaskGroupSampler::~TaskGroupSampler() { … }
double TaskGroupSampler::RefreshCpuUsage() { … }
int64_t TaskGroupSampler::RefreshSwappedMem() { … }
int TaskGroupSampler::RefreshIdleWakeupsPerSecond() { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC)
int TaskGroupSampler::RefreshOpenFdCount() { … }
#endif
base::Process::Priority TaskGroupSampler::RefreshProcessPriority() { … }
}