#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/public/cpp/bindings/lib/multiplex_router.h"
#include <stdint.h>
#include <utility>
#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/types/pass_key.h"
#include "mojo/public/cpp/bindings/features.h"
#include "mojo/public/cpp/bindings/interface_endpoint_client.h"
#include "mojo/public/cpp/bindings/interface_endpoint_controller.h"
#include "mojo/public/cpp/bindings/lib/may_auto_lock.h"
#include "mojo/public/cpp/bindings/sequence_local_sync_event_watcher.h"
namespace mojo {
namespace internal {
class MultiplexRouter::InterfaceEndpoint
: public base::RefCountedThreadSafe<InterfaceEndpoint>,
public InterfaceEndpointController { … };
class MultiplexRouter::MessageWrapper { … };
struct MultiplexRouter::Task { … };
scoped_refptr<MultiplexRouter> MultiplexRouter::Create(
ScopedMessagePipeHandle message_pipe,
Config config,
bool set_interface_id_namespace_bit,
scoped_refptr<base::SequencedTaskRunner> runner,
const char* primary_interface_name) { … }
scoped_refptr<MultiplexRouter> MultiplexRouter::CreateAndStartReceiving(
ScopedMessagePipeHandle message_pipe,
Config config,
bool set_interface_id_namespace_bit,
scoped_refptr<base::SequencedTaskRunner> runner,
const char* primary_interface_name) { … }
MultiplexRouter::MultiplexRouter(
base::PassKey<MultiplexRouter>,
ScopedMessagePipeHandle message_pipe,
Config config,
bool set_interface_id_namespace_bit,
scoped_refptr<base::SequencedTaskRunner> runner,
const char* primary_interface_name)
: … { … }
void MultiplexRouter::StartReceiving() { … }
MultiplexRouter::~MultiplexRouter() { … }
void MultiplexRouter::SetIncomingMessageFilter(
std::unique_ptr<MessageFilter> filter) { … }
void MultiplexRouter::SetConnectionGroup(ConnectionGroup::Ref ref) { … }
InterfaceId MultiplexRouter::AssociateInterface(
ScopedInterfaceEndpointHandle handle_to_send) { … }
ScopedInterfaceEndpointHandle MultiplexRouter::CreateLocalEndpointHandle(
InterfaceId id) { … }
void MultiplexRouter::CloseEndpointHandle(
InterfaceId id,
const std::optional<DisconnectReason>& reason) { … }
void MultiplexRouter::NotifyLocalEndpointOfPeerClosure(InterfaceId id) { … }
InterfaceEndpointController* MultiplexRouter::AttachEndpointClient(
const ScopedInterfaceEndpointHandle& handle,
InterfaceEndpointClient* client,
scoped_refptr<base::SequencedTaskRunner> runner) { … }
void MultiplexRouter::DetachEndpointClient(
const ScopedInterfaceEndpointHandle& handle) { … }
void MultiplexRouter::RaiseError() { … }
bool MultiplexRouter::PrefersSerializedMessages() { … }
void MultiplexRouter::CloseMessagePipe() { … }
void MultiplexRouter::PauseIncomingMethodCallProcessing() { … }
void MultiplexRouter::ResumeIncomingMethodCallProcessing() { … }
void MultiplexRouter::FlushAsync(AsyncFlusher flusher) { … }
void MultiplexRouter::PausePeerUntilFlushCompletes(PendingFlush flush) { … }
bool MultiplexRouter::HasAssociatedEndpoints() const { … }
void MultiplexRouter::EnableBatchDispatch() { … }
void MultiplexRouter::EnableTestingMode() { … }
bool MultiplexRouter::CanUnblockExternalSyncWait(const Message& message) { … }
bool MultiplexRouter::CanUnblockExclusiveSameThreadSyncWait(
const Message& message) { … }
bool MultiplexRouter::Accept(Message* message) { … }
bool MultiplexRouter::OnPeerAssociatedEndpointClosed(
InterfaceId id,
const std::optional<DisconnectReason>& reason) { … }
bool MultiplexRouter::WaitForFlushToComplete(ScopedMessagePipeHandle pipe) { … }
void MultiplexRouter::OnPipeConnectionError(bool force_async_dispatch) { … }
void MultiplexRouter::OnFlushPipeSignaled(MojoResult result,
const HandleSignalsState& state) { … }
void MultiplexRouter::PauseInternal(bool must_resume_manually) { … }
bool MultiplexRouter::ExclusiveSyncWaitForReply(InterfaceId interface_id,
uint64_t request_id) { … }
void MultiplexRouter::ProcessTasks(
ClientCallBehavior client_call_behavior,
base::SequencedTaskRunner* current_task_runner) { … }
bool MultiplexRouter::ProcessFirstSyncMessageForEndpoint(InterfaceId id) { … }
bool MultiplexRouter::ProcessNotifyErrorTask(
Task* task,
ClientCallBehavior client_call_behavior,
base::SequencedTaskRunner* current_task_runner) { … }
bool MultiplexRouter::ProcessIncomingMessage(
MessageWrapper* message_wrapper,
ClientCallBehavior client_call_behavior,
base::SequencedTaskRunner* current_task_runner) { … }
void MultiplexRouter::MaybePostToProcessTasks(
base::SequencedTaskRunner* task_runner) { … }
void MultiplexRouter::LockAndCallProcessTasks() { … }
void MultiplexRouter::UpdateEndpointStateMayRemove(
InterfaceEndpoint* endpoint,
EndpointStateUpdateType type) { … }
void MultiplexRouter::RaiseErrorInNonTestingMode() { … }
MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindOrInsertEndpoint(
InterfaceId id,
bool* inserted) { … }
MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindEndpoint(
InterfaceId id) { … }
void MultiplexRouter::AssertLockAcquired() { … }
bool MultiplexRouter::InsertEndpointsForMessage(const Message& message) { … }
void MultiplexRouter::CloseEndpointsForMessage(const Message& message) { … }
}
}