1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_
6 #define REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "base/win/scoped_handle.h"
15 #include "ipc/ipc_listener.h"
16 #include "remoting/host/win/worker_process_launcher.h"
21 class SingleThreadTaskRunner;
31 // Implements logic for launching and monitoring a worker process under a less
32 // privileged user account.
33 class UnprivilegedProcessDelegate
34 : public base::NonThreadSafe,
36 public WorkerProcessLauncher::Delegate {
38 UnprivilegedProcessDelegate(
39 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
40 scoped_ptr<CommandLine> target_command);
41 virtual ~UnprivilegedProcessDelegate();
43 // WorkerProcessLauncher::Delegate implementation.
44 virtual void LaunchProcess(WorkerProcessLauncher* event_handler) OVERRIDE;
45 virtual void Send(IPC::Message* message) OVERRIDE;
46 virtual void CloseChannel() OVERRIDE;
47 virtual void KillProcess() OVERRIDE;
50 // IPC::Listener implementation.
51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
52 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
53 virtual void OnChannelError() OVERRIDE;
55 void ReportFatalError();
56 void ReportProcessLaunched(base::win::ScopedHandle worker_process);
58 // The task runner serving job object notifications.
59 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
61 // Command line of the launched process.
62 scoped_ptr<CommandLine> target_command_;
64 // The server end of the IPC channel used to communicate to the worker
66 scoped_ptr<IPC::ChannelProxy> channel_;
68 WorkerProcessLauncher* event_handler_;
70 // The handle of the worker process, if launched.
71 base::win::ScopedHandle worker_process_;
73 DISALLOW_COPY_AND_ASSIGN(UnprivilegedProcessDelegate);
76 } // namespace remoting
78 #endif // REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_