#include "components/heap_profiling/multi_process/client_connection_manager.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/rand_util.h"
#include "components/services/heap_profiling/public/cpp/controller.h"
#include "components/services/heap_profiling/public/cpp/profiling_client.h"
#include "components/services/heap_profiling/public/cpp/settings.h"
#include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h"
#include "components/services/heap_profiling/public/mojom/heap_profiling_service.mojom.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/process_type.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace heap_profiling {
namespace {
bool ShouldProfileNonRendererProcessType(Mode mode, int process_type) { … }
void StartProfilingClientOnIOThread(
base::WeakPtr<Controller> controller,
mojo::PendingRemote<mojom::ProfilingClient> client,
base::ProcessId pid,
mojom::ProcessType process_type,
mojom::ProfilingService::AddProfilingClientCallback
started_profiling_closure) { … }
void StartProfilingBrowserProcessOnIOThread(
base::WeakPtr<Controller> controller,
mojom::ProfilingService::AddProfilingClientCallback
started_profiling_closure) { … }
}
ClientConnectionManager::ClientConnectionManager(
base::WeakPtr<Controller> controller,
Mode mode)
: … { … }
ClientConnectionManager::~ClientConnectionManager() { … }
void ClientConnectionManager::Start() { … }
Mode ClientConnectionManager::GetMode() { … }
void ClientConnectionManager::StartProfilingProcess(
base::ProcessId pid,
mojom::ProfilingService::AddProfilingClientCallback
started_profiling_closure) { … }
bool ClientConnectionManager::AllowedToProfileRenderer(
content::RenderProcessHost* host) { … }
void ClientConnectionManager::SetModeForTesting(Mode mode) { … }
void ClientConnectionManager::StartProfilingExistingProcessesIfNecessary() { … }
void ClientConnectionManager::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) { … }
void ClientConnectionManager::StartProfilingNonRendererChild(
const content::ChildProcessData& data,
mojom::ProfilingService::AddProfilingClientCallback
started_profiling_closure) { … }
void ClientConnectionManager::OnRenderProcessHostCreated(
content::RenderProcessHost* host) { … }
void ClientConnectionManager::RenderProcessExited(
content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { … }
void ClientConnectionManager::RenderProcessHostDestroyed(
content::RenderProcessHost* host) { … }
bool ClientConnectionManager::ShouldProfileNewRenderer(
content::RenderProcessHost* renderer) { … }
void ClientConnectionManager::StartProfilingRenderer(
content::RenderProcessHost* host,
mojom::ProfilingService::AddProfilingClientCallback
started_profiling_closure) { … }
}