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

Side by Side Diff: remoting/host/wts_session_process_launcher_win.h

Issue 9705065: Introducing the WorkerProcessLauncher class implementing the common logic for spawning a worker pro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 8 years, 9 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_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" 11 #include "base/file_path.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
13 #include "base/process.h" 15 #include "base/process.h"
14 #include "base/time.h" 16 #include "base/time.h"
15 #include "base/timer.h" 17 #include "base/timer.h"
16 #include "base/win/scoped_handle.h" 18 #include "base/win/scoped_handle.h"
17 #include "base/win/object_watcher.h" 19 #include "base/win/object_watcher.h"
18 #include "ipc/ipc_channel.h" 20 #include "ipc/ipc_channel.h"
19 21
20 #include "remoting/host/wts_console_observer_win.h" 22 #include "remoting/host/wts_console_observer_win.h"
21 23
22 namespace base { 24 namespace base {
23 25
24 class Thread; 26 class MessageLoopProxy;
25 27
26 } // namespace base 28 } // namespace base
27 29
28 namespace IPC { 30 namespace IPC {
29 31
30 class ChannelProxy; 32 class ChannelProxy;
31 class Message; 33 class Message;
32 34
33 } // namespace IPC 35 } // namespace IPC
34 36
35 namespace remoting { 37 namespace remoting {
36 38
37 class SasInjector; 39 class SasInjector;
38 class WtsConsoleMonitor; 40 class WtsConsoleMonitor;
41 class WorkerProcessLauncherWin;
39 42
40 class WtsSessionProcessLauncher 43 class WtsSessionProcessLauncher
41 : public base::win::ObjectWatcher::Delegate, 44 : public IPC::Channel::Listener,
42 public IPC::Channel::Listener,
43 public WtsConsoleObserver { 45 public WtsConsoleObserver {
44 public: 46 public:
45 // Constructs a WtsSessionProcessLauncher object. |monitor| and |io_thread| 47 // Constructs a WtsSessionProcessLauncher object. |monitor| must outlive this
46 // must outlive this object. |host_binary| is the name of the executable to 48 // object. |host_binary| is the name of the executable to be launched in
47 // be launched in the console session. 49 // the console session.
48 WtsSessionProcessLauncher(WtsConsoleMonitor* monitor, 50 WtsSessionProcessLauncher(
49 const FilePath& host_binary, 51 WtsConsoleMonitor* monitor,
50 base::Thread* io_thread); 52 const FilePath& host_binary,
53 scoped_refptr<base::MessageLoopProxy> ipc_message_loop);
51 54
52 virtual ~WtsSessionProcessLauncher(); 55 virtual ~WtsSessionProcessLauncher();
53 56
54 // base::win::ObjectWatcher::Delegate implementation.
55 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
56
57 // IPC::Channel::Listener implementation. 57 // IPC::Channel::Listener implementation.
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
59 virtual void OnChannelError() OVERRIDE;
59 60
60 // WtsConsoleObserver implementation. 61 // WtsConsoleObserver implementation.
61 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; 62 virtual void OnSessionAttached(uint32 session_id) OVERRIDE;
62 virtual void OnSessionDetached() OVERRIDE; 63 virtual void OnSessionDetached() OVERRIDE;
63 64
64 private: 65 private:
66 // Takes the channel name and returns a channel handle for the server end of
67 // the channel.
68 bool CreateChannelHandle(const std::string& channel_name,
69 IPC::ChannelHandle* channel_handle_out);
70
71 // Launches a worker process passing the IPC channel name to it.
72 bool LaunchWorker(const std::string& channel_name,
73 base::Process* process_out);
74
65 // Attempts to launch the host process in the current console session. 75 // Attempts to launch the host process in the current console session.
66 // Schedules next launch attempt if creation of the process fails for any 76 // Schedules next launch attempt if creation of the process fails for any
67 // reason. 77 // reason.
68 void LaunchProcess(); 78 void LaunchProcess();
Wez 2012/03/27 16:45:45 nit: Re-name this to LaunchWtsSessionProcess() to
69 79
70 // Sends the Secure Attention Sequence to the session represented by 80 // Sends the Secure Attention Sequence to the session represented by
71 // |session_token_|. 81 // |session_token_|.
72 void OnSendSasToConsole(); 82 void OnSendSasToConsole();
73 83
74 // Name of the host executable. 84 // Name of the host executable.
75 FilePath host_binary_; 85 FilePath host_binary_;
76 86
87 // Message loop used by the IPC channel.
88 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_;
89
90 // This is a place to store pipe handle until the host process has been
Wez 2012/03/27 16:45:45 nit: "Used to store the IPC pipe handle until the
91 // started.
92 base::win::ScopedHandle ipc_pipe_;
93
77 // Time of the last launch attempt. 94 // Time of the last launch attempt.
78 base::Time launch_time_; 95 base::Time launch_time_;
79 96
80 // Current backoff delay. 97 // Current backoff delay.
81 base::TimeDelta launch_backoff_; 98 base::TimeDelta launch_backoff_;
82 99
100 scoped_ptr<WorkerProcessLauncherWin> launcher_;
101
83 // Timer used to schedule the next attempt to launch the process. 102 // Timer used to schedule the next attempt to launch the process.
84 base::OneShotTimer<WtsSessionProcessLauncher> timer_; 103 base::OneShotTimer<WtsSessionProcessLauncher> timer_;
85 104
86 // The I/O thread hosts the Chromoting IPC channel and any other code
87 // requiring an I/O message loop.
88 base::Thread* io_thread_;
89
90 // This pointer is used to unsubscribe from session attach and detach events. 105 // This pointer is used to unsubscribe from session attach and detach events.
91 WtsConsoleMonitor* monitor_; 106 WtsConsoleMonitor* monitor_;
92 107
93 // Impersonation token that has the SE_TCB_NAME privilege enabled. 108 // Impersonation token that has the SE_TCB_NAME privilege enabled.
94 base::win::ScopedHandle privileged_token_; 109 base::win::ScopedHandle privileged_token_;
95 110
96 // The handle of the process injected into the console session.
97 base::Process process_;
98
99 // Used to determine when the launched process terminates.
100 base::win::ObjectWatcher process_watcher_;
101
102 // The token to be used to launch a process in a different session. 111 // The token to be used to launch a process in a different session.
103 base::win::ScopedHandle session_token_; 112 base::win::ScopedHandle session_token_;
104 113
105 // Defines the states the process launcher can be in.
106 enum State {
107 StateDetached,
108 StateStarting,
109 StateAttached,
110 };
111
112 // Current state of the process launcher.
113 State state_;
114
115 // The Chromoting IPC channel connecting the service to the per-session
116 // process.
117 scoped_ptr<IPC::ChannelProxy> chromoting_channel_;
118
119 scoped_ptr<SasInjector> sas_injector_; 114 scoped_ptr<SasInjector> sas_injector_;
120 115
121 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); 116 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher);
122 }; 117 };
123 118
124 } // namespace remoting 119 } // namespace remoting
125 120
126 #endif // REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_ 121 #endif // REMOTING_HOST_WTS_SESSION_PROCESS_LAUNCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698