#include "ipc/ipc_channel_mojo.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ref.h"
#include "base/process/process_handle.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message_attachment_set.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_mojo_bootstrap.h"
#include "ipc/ipc_mojo_handle_attachment.h"
#include "ipc/native_handle_type_converters.h"
#include "ipc/trace_ipc_message.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/thread_safe_proxy.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace IPC {
namespace {
class MojoChannelFactory : public ChannelFactory { … };
class ThreadSafeChannelProxy : public mojo::ThreadSafeProxy { … };
base::ProcessId GetSelfPID() { … }
}
std::unique_ptr<ChannelMojo> ChannelMojo::Create(
mojo::ScopedMessagePipeHandle handle,
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner) { … }
std::unique_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
mojo::ScopedMessagePipeHandle handle,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner) { … }
std::unique_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
mojo::ScopedMessagePipeHandle handle,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner) { … }
ChannelMojo::ChannelMojo(
mojo::ScopedMessagePipeHandle handle,
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner)
: … { … }
void ChannelMojo::ForwardMessage(mojo::Message message) { … }
ChannelMojo::~ChannelMojo() { … }
bool ChannelMojo::Connect() { … }
void ChannelMojo::FinishConnectOnIOThread() { … }
void ChannelMojo::Pause() { … }
void ChannelMojo::Unpause(bool flush) { … }
void ChannelMojo::Flush() { … }
void ChannelMojo::Close() { … }
void ChannelMojo::OnPipeError() { … }
void ChannelMojo::OnAssociatedInterfaceRequest(
mojo::GenericPendingAssociatedReceiver receiver) { … }
bool ChannelMojo::Send(Message* message) { … }
Channel::AssociatedInterfaceSupport*
ChannelMojo::GetAssociatedInterfaceSupport() { … }
std::unique_ptr<mojo::ThreadSafeForwarder<mojom::Channel>>
ChannelMojo::CreateThreadSafeChannel() { … }
void ChannelMojo::OnPeerPidReceived(int32_t peer_pid) { … }
void ChannelMojo::OnMessageReceived(const Message& message) { … }
void ChannelMojo::OnBrokenDataReceived() { … }
MojoResult ChannelMojo::ReadFromMessageAttachmentSet(
Message* message,
std::optional<std::vector<mojo::native::SerializedHandlePtr>>* handles) { … }
MojoResult ChannelMojo::WriteToMessageAttachmentSet(
std::optional<std::vector<mojo::native::SerializedHandlePtr>> handles,
Message* message) { … }
void ChannelMojo::AddGenericAssociatedInterface(
const std::string& name,
const GenericAssociatedInterfaceFactory& factory) { … }
void ChannelMojo::GetRemoteAssociatedInterface(
mojo::GenericPendingAssociatedReceiver receiver) { … }
void ChannelMojo::SetUrgentMessageObserver(UrgentMessageObserver* observer) { … }
}