#include "chrome/browser/extensions/api/processes/processes_api.h"
#include <stdint.h>
#include <memory>
#include <set>
#include <utility>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram.h"
#include "base/process/process.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/task_manager/task_manager_interface.h"
#include "chrome/common/extensions/api/processes.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_host.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/result_codes.h"
#include "extensions/common/error_utils.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
namespace extensions {
namespace errors {
const char kNotAllowedToTerminate[] = …;
const char kProcessNotFound[] = …;
const char kInvalidArgument[] = …;
}
namespace {
base::LazyInstance<BrowserContextKeyedAPIFactory<ProcessesAPI>>::
DestructorAtExit g_processes_api_factory = …;
int64_t GetRefreshTypesFlagOnlyEssentialData() { … }
int64_t GetRefreshTypesForProcessOptionalData() { … }
api::processes::Cache CreateCacheData(
const blink::WebCacheResourceTypeStat& stat) { … }
api::processes::ProcessType GetProcessType(
task_manager::Task::Type task_type) { … }
void FillProcessData(
task_manager::TaskId id,
task_manager::TaskManagerInterface* task_manager,
bool include_optional,
api::processes::Process* out_process) { … }
}
ProcessesEventRouter::ProcessesEventRouter(content::BrowserContext* context)
: … { … }
ProcessesEventRouter::~ProcessesEventRouter() { … }
void ProcessesEventRouter::ListenerAdded() { … }
void ProcessesEventRouter::ListenerRemoved() { … }
void ProcessesEventRouter::OnTaskAdded(task_manager::TaskId id) { … }
void ProcessesEventRouter::OnTaskToBeRemoved(task_manager::TaskId id) { … }
void ProcessesEventRouter::OnTasksRefreshedWithBackgroundCalculations(
const task_manager::TaskIdList& task_ids) { … }
void ProcessesEventRouter::OnTaskUnresponsive(task_manager::TaskId id) { … }
void ProcessesEventRouter::DispatchEvent(events::HistogramValue histogram_value,
const std::string& event_name,
base::Value::List event_args) const { … }
bool ProcessesEventRouter::HasEventListeners(
const std::string& event_name) const { … }
bool ProcessesEventRouter::ShouldReportOnCreatedOrOnExited(
task_manager::TaskId id,
int* out_child_process_host_id) const { … }
void ProcessesEventRouter::UpdateRefreshTypesFlagsBasedOnListeners() { … }
ProcessesAPI::ProcessesAPI(content::BrowserContext* context)
: … { … }
ProcessesAPI::~ProcessesAPI() { … }
BrowserContextKeyedAPIFactory<ProcessesAPI>*
ProcessesAPI::GetFactoryInstance() { … }
ProcessesAPI* ProcessesAPI::Get(content::BrowserContext* context) { … }
void ProcessesAPI::Shutdown() { … }
void ProcessesAPI::OnListenerAdded(const EventListenerInfo& details) { … }
void ProcessesAPI::OnListenerRemoved(const EventListenerInfo& details) { … }
ProcessesEventRouter* ProcessesAPI::processes_event_router() { … }
ExtensionFunction::ResponseAction ProcessesGetProcessIdForTabFunction::Run() { … }
ExtensionFunction::ResponseAction ProcessesTerminateFunction::Run() { … }
base::ProcessHandle ProcessesTerminateFunction::GetProcessHandleOnIO(
int child_process_host_id) const { … }
void ProcessesTerminateFunction::OnProcessHandleOnUI(
base::ProcessHandle handle) { … }
ExtensionFunction::ResponseValue
ProcessesTerminateFunction::TerminateIfAllowed(base::ProcessHandle handle) { … }
ProcessesGetProcessInfoFunction::ProcessesGetProcessInfoFunction()
: … { … }
ExtensionFunction::ResponseAction ProcessesGetProcessInfoFunction::Run() { … }
void ProcessesGetProcessInfoFunction::OnTasksRefreshed(
const task_manager::TaskIdList& task_ids) { … }
void
ProcessesGetProcessInfoFunction::OnTasksRefreshedWithBackgroundCalculations(
const task_manager::TaskIdList& task_ids) { … }
ProcessesGetProcessInfoFunction::~ProcessesGetProcessInfoFunction() { … }
void ProcessesGetProcessInfoFunction::GatherDataAndRespond(
const task_manager::TaskIdList& task_ids) { … }
}