chromium/components/named_mojo_ipc_server/named_mojo_server_endpoint_connector.h

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

#ifndef COMPONENTS_NAMED_MOJO_IPC_SERVER_NAMED_MOJO_SERVER_ENDPOINT_CONNECTOR_H_
#define COMPONENTS_NAMED_MOJO_IPC_SERVER_NAMED_MOJO_SERVER_ENDPOINT_CONNECTOR_H_

#include <memory>

#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process_handle.h"
#include "base/sequence_checker.h"
#include "base/threading/sequence_bound.h"
#include "build/buildflag.h"
#include "components/named_mojo_ipc_server/endpoint_options.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h"

namespace base {
class SequencedTaskRunner;
}  // namespace base

namespace named_mojo_ipc_server {

struct ConnectionInfo;

// Interface to allow platform-specific implementations to establish connection
// between the server endpoint and the client. mojo::IsolatedConnection can
// take a PlatformChannelServerEndpoint directly, but our implementations allow:
// 1. Reliably knowing when a new invitation needs to be sent; with the
//    alternative approach, the best we could do is to wait for an incoming IPC
//    call, which isn't reliable since a (malicious) client may clog the channel
//    by connecting and hanging without making any IPCs.
// 2. Observing the client process' PID without passing it via IPC, which
//    wouldn't be feasible with the alternative approach, since mojo doesn't
//    expose the underlying socket/named pipe.
class NamedMojoServerEndpointConnector {};

}  // namespace named_mojo_ipc_server

#endif  // COMPONENTS_NAMED_MOJO_IPC_SERVER_NAMED_MOJO_SERVER_ENDPOINT_CONNECTOR_H_