Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: remoting/host/win/unprivileged_process_delegate.h

Issue 15077010: [Chromoting] Refactored worker process launching code and speeded up the desktop process launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/win/scoped_handle.h" 14 #include "base/win/scoped_handle.h"
15 #include "ipc/ipc_listener.h"
14 #include "remoting/host/win/worker_process_launcher.h" 16 #include "remoting/host/win/worker_process_launcher.h"
15 17
16 class CommandLine; 18 class CommandLine;
17 19
18 namespace base { 20 namespace base {
19 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
20 } // namespace base 22 } // namespace base
21 23
22 namespace IPC { 24 namespace IPC {
23 class ChannelProxy; 25 class ChannelProxy;
24 class Listener;
25 class Message; 26 class Message;
26 } // namespace IPC 27 } // namespace IPC
27 28
28 namespace remoting { 29 namespace remoting {
29 30
30 // Implements logic for launching and monitoring a worker process under a less 31 // Implements logic for launching and monitoring a worker process under a less
31 // privileged user account. 32 // privileged user account.
32 class UnprivilegedProcessDelegate : public WorkerProcessLauncher::Delegate { 33 class UnprivilegedProcessDelegate
34 : public base::NonThreadSafe,
35 public IPC::Listener,
36 public WorkerProcessLauncher::Delegate {
33 public: 37 public:
34 UnprivilegedProcessDelegate( 38 UnprivilegedProcessDelegate(
35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
36 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 39 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
37 scoped_ptr<CommandLine> target_command); 40 scoped_ptr<CommandLine> target_command);
38 virtual ~UnprivilegedProcessDelegate(); 41 virtual ~UnprivilegedProcessDelegate();
39 42
40 // IPC::Sender implementation.
41 virtual bool Send(IPC::Message* message) OVERRIDE;
42
43 // WorkerProcessLauncher::Delegate implementation. 43 // WorkerProcessLauncher::Delegate implementation.
44 virtual void LaunchProcess(WorkerProcessLauncher* event_handler) OVERRIDE;
45 virtual void Send(IPC::Message* message) OVERRIDE;
44 virtual void CloseChannel() OVERRIDE; 46 virtual void CloseChannel() OVERRIDE;
45 virtual DWORD GetProcessId() const OVERRIDE; 47 virtual void KillProcess() OVERRIDE;
46 virtual bool IsPermanentError(int failure_count) const OVERRIDE;
47 virtual void KillProcess(DWORD exit_code) OVERRIDE;
48 virtual bool LaunchProcess(
49 IPC::Listener* delegate,
50 base::win::ScopedHandle* process_exit_event_out) OVERRIDE;
51 48
52 private: 49 private:
53 // The task runner all public methods of this class should be called on. 50 // IPC::Listener implementation.
54 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
52 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
53 virtual void OnChannelError() OVERRIDE;
54
55 void ReportFatalError();
56 void ReportProcessLaunched(base::win::ScopedHandle worker_process);
55 57
56 // The task runner serving job object notifications. 58 // The task runner serving job object notifications.
57 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
58 60
59 // Command line of the launched process. 61 // Command line of the launched process.
60 scoped_ptr<CommandLine> target_command_; 62 scoped_ptr<CommandLine> target_command_;
61 63
62 // The server end of the IPC channel used to communicate to the worker 64 // The server end of the IPC channel used to communicate to the worker
63 // process. 65 // process.
64 scoped_ptr<IPC::ChannelProxy> channel_; 66 scoped_ptr<IPC::ChannelProxy> channel_;
65 67
68 WorkerProcessLauncher* event_handler_;
69
66 // The handle of the worker process, if launched. 70 // The handle of the worker process, if launched.
67 base::win::ScopedHandle worker_process_; 71 base::win::ScopedHandle worker_process_;
68 72
69 DISALLOW_COPY_AND_ASSIGN(UnprivilegedProcessDelegate); 73 DISALLOW_COPY_AND_ASSIGN(UnprivilegedProcessDelegate);
70 }; 74 };
71 75
72 } // namespace remoting 76 } // namespace remoting
73 77
74 #endif // REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_ 78 #endif // REMOTING_HOST_WIN_UNPRIVILEGED_PROCESS_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698