chromium/chrome/browser/task_manager/sampling/task_manager_impl.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/task_manager/sampling/task_manager_impl.h"

#include <algorithm>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/not_fatal_until.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/task_manager/providers/browser_process_task_provider.h"
#include "chrome/browser/task_manager/providers/child_process_task_provider.h"
#include "chrome/browser/task_manager/providers/fallback_task_provider.h"
#include "chrome/browser/task_manager/providers/render_process_host_task_provider.h"
#include "chrome/browser/task_manager/providers/spare_render_process_host_task_provider.h"
#include "chrome/browser/task_manager/providers/web_contents/web_contents_task_provider.h"
#include "chrome/browser/task_manager/providers/worker_task_provider.h"
#include "chrome/browser/task_manager/sampling/shared_sampler.h"
#include "components/nacl/common/buildflags.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/arc_util.h"
#include "chrome/browser/ash/arc/process/arc_process_service.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#include "chrome/browser/task_manager/providers/arc/arc_process_task_provider.h"
#include "chrome/browser/task_manager/providers/crosapi/crosapi_task_provider_ash.h"
#include "chrome/browser/task_manager/providers/vm/vm_process_task_provider.h"
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

namespace task_manager {

namespace {

base::LazyInstance<TaskManagerImpl>::Leaky lazy_task_manager_instance =;

}  // namespace

TaskManagerImpl::TaskManagerImpl()
    :{}

TaskManagerImpl::~TaskManagerImpl() {}

// static
TaskManagerImpl* TaskManagerImpl::GetInstance() {}

bool TaskManagerImpl::IsCreated() {}

void TaskManagerImpl::ActivateTask(TaskId task_id) {}

bool TaskManagerImpl::IsTaskKillable(TaskId task_id) {}

void TaskManagerImpl::KillTask(TaskId task_id) {}

double TaskManagerImpl::GetPlatformIndependentCPUUsage(TaskId task_id) const {}

base::Time TaskManagerImpl::GetStartTime(TaskId task_id) const {}

base::TimeDelta TaskManagerImpl::GetCpuTime(TaskId task_id) const {}

int64_t TaskManagerImpl::GetMemoryFootprintUsage(TaskId task_id) const {}

int64_t TaskManagerImpl::GetSwappedMemoryUsage(TaskId task_id) const {}

int64_t TaskManagerImpl::GetGpuMemoryUsage(TaskId task_id,
                                           bool* has_duplicates) const {}

int TaskManagerImpl::GetIdleWakeupsPerSecond(TaskId task_id) const {}

int TaskManagerImpl::GetHardFaultsPerSecond(TaskId task_id) const {}

int TaskManagerImpl::GetNaClDebugStubPort(TaskId task_id) const {}

void TaskManagerImpl::GetGDIHandles(TaskId task_id,
                                    int64_t* current,
                                    int64_t* peak) const {}

void TaskManagerImpl::GetUSERHandles(TaskId task_id,
                                     int64_t* current,
                                     int64_t* peak) const {}

int TaskManagerImpl::GetOpenFdCount(TaskId task_id) const {}

bool TaskManagerImpl::IsTaskOnBackgroundedProcess(TaskId task_id) const {}

const std::u16string& TaskManagerImpl::GetTitle(TaskId task_id) const {}

std::u16string TaskManagerImpl::GetProfileName(TaskId task_id) const {}

const gfx::ImageSkia& TaskManagerImpl::GetIcon(TaskId task_id) const {}

const base::ProcessHandle& TaskManagerImpl::GetProcessHandle(
    TaskId task_id) const {}

const base::ProcessId& TaskManagerImpl::GetProcessId(TaskId task_id) const {}

Task::Type TaskManagerImpl::GetType(TaskId task_id) const {}

SessionID TaskManagerImpl::GetTabId(TaskId task_id) const {}

int TaskManagerImpl::GetChildProcessUniqueId(TaskId task_id) const {}

void TaskManagerImpl::GetTerminationStatus(TaskId task_id,
                                           base::TerminationStatus* out_status,
                                           int* out_error_code) const {}

int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const {}

int64_t TaskManagerImpl::GetCumulativeNetworkUsage(TaskId task_id) const {}

int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const {}

int64_t TaskManagerImpl::GetCumulativeProcessTotalNetworkUsage(
    TaskId task_id) const {}

int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const {}

bool TaskManagerImpl::GetV8Memory(TaskId task_id,
                                  int64_t* allocated,
                                  int64_t* used) const {}

bool TaskManagerImpl::GetWebCacheStats(
    TaskId task_id,
    blink::WebCacheResourceTypeStats* stats) const {}

int TaskManagerImpl::GetKeepaliveCount(TaskId task_id) const {}

const TaskIdList& TaskManagerImpl::GetTaskIdsList() const {}

TaskIdList TaskManagerImpl::GetIdsOfTasksSharingSameProcess(
    TaskId task_id) const {}

size_t TaskManagerImpl::GetNumberOfTasksOnSameProcess(TaskId task_id) const {}

bool TaskManagerImpl::IsRunningInVM(TaskId task_id) const {}

TaskId TaskManagerImpl::GetTaskIdForWebContents(
    content::WebContents* web_contents) const {}

void TaskManagerImpl::TaskAdded(Task* task) {}

void TaskManagerImpl::TaskRemoved(Task* task) {}

void TaskManagerImpl::TaskUnresponsive(Task* task) {}

void TaskManagerImpl::ActiveTaskFetched(TaskId active_task_id) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void TaskManagerImpl::TaskIdsListToBeInvalidated() {
  sorted_task_ids_.clear();
  NotifyObserversOnRefresh(GetTaskIdsList());
}
#endif  //  BUILDFLAG(IS_CHROMEOS_ASH)

void TaskManagerImpl::UpdateAccumulatedStatsNetworkForRoute(
    content::GlobalRenderFrameHostId render_frame_host_id,
    int64_t recv_bytes,
    int64_t sent_bytes) {}

void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate(
    const gpu::VideoMemoryUsageStats& gpu_memory_stats) {}

void TaskManagerImpl::OnReceivedMemoryDump(
    bool success,
    std::unique_ptr<memory_instrumentation::GlobalMemoryDump> dump) {}

void TaskManagerImpl::Refresh() {}

void TaskManagerImpl::StartUpdating() {}

void TaskManagerImpl::StopUpdating() {}

Task* TaskManagerImpl::GetTaskByRoute(
    content::GlobalRenderFrameHostId render_frame_host_id) const {}

TaskGroup* TaskManagerImpl::GetTaskGroupByTaskId(TaskId task_id) const {}

Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const {}

void TaskManagerImpl::OnTaskGroupBackgroundCalculationsDone() {}

}  // namespace task_manager