#include "mojo/public/cpp/bindings/connector.h"
#include <stdint.h>
#include <memory>
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/task/current_thread.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/sequence_local_storage_slot.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/c/system/quota.h"
#include "mojo/public/cpp/bindings/features.h"
#include "mojo/public/cpp/bindings/lib/may_auto_lock.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/cpp/bindings/sync_handle_watcher.h"
#include "mojo/public/cpp/bindings/tracing_helpers.h"
#include "mojo/public/cpp/system/wait.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_mojo_event_info.pbzero.h"
#if defined(ENABLE_IPC_FUZZER)
#include "mojo/public/cpp/bindings/message_dumper.h"
#endif
namespace mojo {
namespace {
Connector::OutgoingSerializationMode g_default_outgoing_serialization_mode = …;
Connector::IncomingSerializationMode g_default_incoming_serialization_mode = …;
bool EnableTaskPerMessage() { … }
}
class Connector::ActiveDispatchTracker { … };
class Connector::RunLoopNestingObserver
: public base::RunLoop::NestingObserver { … };
Connector::ActiveDispatchTracker::ActiveDispatchTracker(
const base::WeakPtr<Connector>& connector)
: … { … }
Connector::ActiveDispatchTracker::~ActiveDispatchTracker() { … }
void Connector::ActiveDispatchTracker::NotifyBeginNesting() { … }
Connector::Connector(ScopedMessagePipeHandle message_pipe,
ConnectorConfig config,
const char* interface_name)
: … { … }
Connector::Connector(ScopedMessagePipeHandle message_pipe,
ConnectorConfig config,
scoped_refptr<base::SequencedTaskRunner> runner,
const char* interface_name)
: … { … }
Connector::~Connector() { … }
void Connector::SetOutgoingSerializationMode(OutgoingSerializationMode mode) { … }
void Connector::SetIncomingSerializationMode(IncomingSerializationMode mode) { … }
void Connector::StartReceiving(
scoped_refptr<base::SequencedTaskRunner> task_runner,
bool allow_woken_up_by_others) { … }
void Connector::CloseMessagePipe() { … }
ScopedMessagePipeHandle Connector::PassMessagePipe() { … }
void Connector::RaiseError() { … }
void Connector::SetConnectionGroup(ConnectionGroup::Ref ref) { … }
bool Connector::WaitForIncomingMessage() { … }
void Connector::PauseIncomingMethodCallProcessing() { … }
void Connector::ResumeIncomingMethodCallProcessing() { … }
bool Connector::PrefersSerializedMessages() { … }
bool Connector::Accept(Message* message) { … }
MojoResult Connector::AcceptAndGetResult(Message* message) { … }
void Connector::AllowWokenUpBySyncWatchOnSameThread() { … }
void Connector::OverrideDefaultSerializationBehaviorForTesting(
OutgoingSerializationMode outgoing_mode,
IncomingSerializationMode incoming_mode) { … }
bool Connector::SimulateReadMessage(ScopedMessageHandle message) { … }
void Connector::OnWatcherHandleReady(const char* interface_name,
MojoResult result) { … }
void Connector::OnSyncHandleWatcherHandleReady(const char* interface_name,
MojoResult result) { … }
void Connector::OnHandleReadyInternal(MojoResult result) { … }
void Connector::WaitToReadMore() { … }
uint64_t Connector::QueryPendingMessageCount() const { … }
MojoResult Connector::ReadMessage(ScopedMessageHandle& message) { … }
bool Connector::DispatchMessage(ScopedMessageHandle handle) { … }
void Connector::PostDispatchNextMessageFromPipe() { … }
void Connector::CallDispatchNextMessageFromPipe() { … }
void Connector::ScheduleDispatchOfPendingMessagesOrWaitForMore(
uint64_t pending_message_count) { … }
void Connector::ReadAllAvailableMessages() { … }
void Connector::CancelWait() { … }
void Connector::HandleError(bool force_pipe_reset, bool force_async_handler) { … }
void Connector::EnsureSyncWatcherExists() { … }
}