#ifndef REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_
#define REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_
#include <stdint.h>
#include <memory>
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/win/scoped_handle.h"
#include "ipc/ipc_listener.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "remoting/host/mojom/desktop_session.mojom.h"
#include "remoting/host/win/worker_process_launcher.h"
namespace base {
class CommandLine;
class SingleThreadTaskRunner;
}
namespace IPC {
class ChannelProxy;
}
namespace remoting {
class UnprivilegedProcessDelegate : public IPC::Listener,
public WorkerProcessLauncher::Delegate {
public:
UnprivilegedProcessDelegate(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
std::unique_ptr<base::CommandLine> target_command);
UnprivilegedProcessDelegate(const UnprivilegedProcessDelegate&) = delete;
UnprivilegedProcessDelegate& operator=(const UnprivilegedProcessDelegate&) =
delete;
~UnprivilegedProcessDelegate() override;
void LaunchProcess(WorkerProcessLauncher* event_handler) override;
void GetRemoteAssociatedInterface(
mojo::GenericPendingAssociatedReceiver receiver) override;
void CloseChannel() override;
void CrashProcess(const base::Location& location) override;
void KillProcess() override;
private:
void OnChannelConnected(int32_t peer_pid) override;
void OnChannelError() override;
void OnAssociatedInterfaceRequest(
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) override;
void ReportFatalError();
void ReportProcessLaunched(base::win::ScopedHandle worker_process);
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
std::unique_ptr<base::CommandLine> target_command_;
std::unique_ptr<IPC::ChannelProxy> channel_;
raw_ptr<WorkerProcessLauncher> event_handler_;
base::win::ScopedHandle worker_process_;
mojo::AssociatedRemote<mojom::WorkerProcessControl> worker_process_control_;
SEQUENCE_CHECKER(sequence_checker_);
};
}
#endif