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_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ | 5 #ifndef REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ |
6 #define REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ | 6 #define REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/file_path.h" | |
12 #include "base/memory/scoped_ptr.h" | |
Wez
2012/02/28 00:22:07
nit: This include goes after compiler_specific.h
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/process.h" | |
15 #include "base/time.h" | |
16 #include "base/timer.h" | |
17 #include "base/win/object_watcher.h" | |
12 | 18 |
13 #include "remoting/host/wts_console_observer_win.h" | 19 #include "remoting/host/wts_console_observer_win.h" |
14 | 20 |
21 namespace base { | |
22 namespace win { | |
23 | |
24 class ScopedHandle; | |
25 | |
26 } // namespace win | |
27 } // namespace base | |
28 | |
15 namespace remoting { | 29 namespace remoting { |
16 | 30 |
17 class WtsConsoleMonitor; | 31 class WtsConsoleMonitor; |
18 | 32 |
19 class WtsSessionProcessLauncher : public WtsConsoleObserver { | 33 class WtsSessionProcessLauncher |
34 : public base::win::ObjectWatcher::Delegate, | |
35 public WtsConsoleObserver { | |
20 public: | 36 public: |
21 // Constructs a WtsSessionProcessLauncher object. |monitor| must outlive this | 37 // Constructs a WtsSessionProcessLauncher object. |monitor| must outlive this |
22 // class. | 38 // class. |host_binary| is the host executable name to be launched in |
Wez
2012/02/28 00:22:07
nit: ... is the name of the executable to be launc
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
23 WtsSessionProcessLauncher(WtsConsoleMonitor* monitor); | 39 // the session(s) attached to the console. |
Wez
2012/02/28 00:22:07
nit: the console session.
There can't be >1 conso
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
40 WtsSessionProcessLauncher(WtsConsoleMonitor* monitor, | |
41 const FilePath& host_binary); | |
42 | |
24 virtual ~WtsSessionProcessLauncher(); | 43 virtual ~WtsSessionProcessLauncher(); |
25 | 44 |
45 // base::win::ObjectWatcher::Delegate implementation | |
46 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | |
47 | |
26 // WtsConsoleObserver implementation | 48 // WtsConsoleObserver implementation |
27 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; | 49 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; |
28 virtual void OnSessionDetached() OVERRIDE; | 50 virtual void OnSessionDetached() OVERRIDE; |
29 | 51 |
30 private: | 52 private: |
53 // Attempts to launch the host process in the currently attached session. | |
54 // Schedules next launch attempt if creation of the process fails for any | |
55 // reason. | |
56 void LaunchProcess(); | |
57 | |
58 // Name of the host executable. | |
59 FilePath host_binary_; | |
60 | |
61 // Time of the last launch attempt. | |
62 base::Time launch_time_; | |
63 | |
64 // Current backoff delay. | |
65 base::TimeDelta launch_backoff_; | |
66 | |
67 // Number of times we tried to launch the process. | |
68 int launch_attempts_; | |
alexeypa (please no reviews)
2012/02/28 01:14:04
launch_attempts_ is not used BTW. I removed it.
| |
69 | |
70 // This pointer is used to unsubscribe from session attach and detach events. | |
31 WtsConsoleMonitor* monitor_; | 71 WtsConsoleMonitor* monitor_; |
32 | 72 |
73 // Impersonation token that has the SE_TCB_NAME privilege enabled. | |
74 scoped_ptr<base::win::ScopedHandle> privileged_token_; | |
75 | |
76 // A handle of the process injected into the watched session. | |
Wez
2012/02/28 00:22:07
nit: A -> The
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
77 base::Process process_; | |
78 | |
79 // Monitors the launched process calling a callback when it terminates. | |
80 base::win::ObjectWatcher process_watcher_; | |
81 | |
82 // A token to be used to launch a process in a different session. | |
Wez
2012/02/28 00:22:07
nit: A -> The
This is the token with the console
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
83 scoped_ptr<base::win::ScopedHandle> session_token_; | |
84 | |
85 // Defines the states the process launcher can be. | |
Wez
2012/02/28 00:22:07
nit: ... can be in.
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
86 enum State { | |
87 StateDetached, | |
88 StateStarting, | |
89 StateAttached, | |
90 }; | |
91 | |
92 // Current state of the process launcher. | |
93 State state_; | |
94 | |
95 // This time is used to delay next attempt to launch the host. | |
Wez
2012/02/28 00:22:07
nit: suggest "Timer used to schedule the next atte
alexeypa (please no reviews)
2012/02/28 01:14:04
Done.
| |
96 base::OneShotTimer<WtsSessionProcessLauncher> timer_; | |
Wez
2012/02/28 00:22:07
Why is this timer down here when the |launch_time_
alexeypa (please no reviews)
2012/02/28 01:14:04
The members are sorted alphabetically. It makes se
Wez
2012/02/28 22:55:36
I'd group them logically and sort alphabetically o
alexeypa (please no reviews)
2012/02/29 04:17:56
Make sense. Coincidentally they are grouped and so
| |
97 | |
33 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); | 98 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); |
34 }; | 99 }; |
35 | 100 |
36 } // namespace remoting | 101 } // namespace remoting |
37 | 102 |
38 #endif // REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ | 103 #endif // REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ |
OLD | NEW |