chromium/mojo/public/cpp/bindings/lib/multiplex_router.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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 {

// InterfaceEndpoint stores the information of an interface endpoint registered
// with the router.
// No one other than the router's |endpoints_| and |tasks_| should hold refs to
// this object.
class MultiplexRouter::InterfaceEndpoint
    : public base::RefCountedThreadSafe<InterfaceEndpoint>,
      public InterfaceEndpointController {};

// MessageWrapper objects are always destroyed under the router's lock. On
// destruction, if the message it wrappers contains interface IDs, the wrapper
// closes the corresponding endpoints.
class MultiplexRouter::MessageWrapper {};

struct MultiplexRouter::Task {};

// static
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) {}

// static
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) {}

}  // namespace internal
}  // namespace mojo