#include "src/ipc/host_impl.h"
#include <algorithm>
#include <cinttypes>
#include <utility>
#include "perfetto/base/build_config.h"
#include "perfetto/base/compiler.h"
#include "perfetto/base/logging.h"
#include "perfetto/base/task_runner.h"
#include "perfetto/base/time.h"
#include "perfetto/ext/base/crash_keys.h"
#include "perfetto/ext/base/sys_types.h"
#include "perfetto/ext/base/unix_socket.h"
#include "perfetto/ext/base/utils.h"
#include "perfetto/ext/ipc/service.h"
#include "perfetto/ext/ipc/service_descriptor.h"
#include "protos/perfetto/ipc/wire_protocol.gen.h"
namespace perfetto {
namespace ipc {
namespace {
constexpr base::SockFamily kHostSockFamily = …;
base::CrashKey g_crash_key_uid("ipc_uid");
base::MachineID GenerateMachineID(base::UnixSocket* sock,
const std::string& machine_id_hint) { … }
}
uid_t HostImpl::ClientConnection::GetPosixPeerUid() const { … }
pid_t HostImpl::ClientConnection::GetLinuxPeerPid() const { … }
std::unique_ptr<Host> Host::CreateInstance(const char* socket_name,
base::TaskRunner* task_runner) { … }
std::unique_ptr<Host> Host::CreateInstance(base::ScopedSocketHandle socket_fd,
base::TaskRunner* task_runner) { … }
std::unique_ptr<Host> Host::CreateInstance_Fuchsia(
base::TaskRunner* task_runner) { … }
HostImpl::HostImpl(base::ScopedSocketHandle socket_fd,
base::TaskRunner* task_runner)
: … { … }
HostImpl::HostImpl(const char* socket_name, base::TaskRunner* task_runner)
: … { … }
HostImpl::HostImpl(base::TaskRunner* task_runner)
: … { … }
HostImpl::~HostImpl() = default;
bool HostImpl::ExposeService(std::unique_ptr<Service> service) { … }
void HostImpl::AdoptConnectedSocket_Fuchsia(
base::ScopedSocketHandle connected_socket,
std::function<bool(int)> send_fd_cb) { … }
void HostImpl::SetSocketSendTimeoutMs(uint32_t timeout_ms) { … }
void HostImpl::OnNewIncomingConnection(
base::UnixSocket*,
std::unique_ptr<base::UnixSocket> new_conn) { … }
void HostImpl::OnDataAvailable(base::UnixSocket* sock) { … }
void HostImpl::OnReceivedFrame(ClientConnection* client,
const Frame& req_frame) { … }
void HostImpl::OnBindService(ClientConnection* client, const Frame& req_frame) { … }
void HostImpl::OnInvokeMethod(ClientConnection* client,
const Frame& req_frame) { … }
void HostImpl::OnSetPeerIdentity(ClientConnection* client,
const Frame& req_frame) { … }
void HostImpl::ReplyToMethodInvocation(ClientID client_id,
RequestID request_id,
AsyncResult<ProtoMessage> reply) { … }
void HostImpl::SendFrame(ClientConnection* client, const Frame& frame, int fd) { … }
void HostImpl::OnDisconnect(base::UnixSocket* sock) { … }
const HostImpl::ExposedService* HostImpl::GetServiceByName(
const std::string& name) { … }
HostImpl::ExposedService::ExposedService(ServiceID id_,
const std::string& name_,
std::unique_ptr<Service> instance_)
: … { … }
HostImpl::ExposedService::ExposedService(ExposedService&&) noexcept = default;
HostImpl::ExposedService& HostImpl::ExposedService::operator=(
HostImpl::ExposedService&&) = default;
HostImpl::ExposedService::~ExposedService() = default;
HostImpl::ClientConnection::~ClientConnection() = default;
}
}