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