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

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

Issue 10911267: [Chromoting] Don't use a job object to control the me2me host process on Windows XP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made compilable on VS2008. Created 8 years, 3 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
« no previous file with comments | « no previous file | remoting/host/win/wts_session_process_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_WTS_SESSION_PROCESS_LAUNCHER_H_ 5 #ifndef REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_
6 #define REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_ 6 #define REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 13 matching lines...) Expand all
24 #include "remoting/host/win/wts_console_observer.h" 24 #include "remoting/host/win/wts_console_observer.h"
25 #include "remoting/host/worker_process_ipc_delegate.h" 25 #include "remoting/host/worker_process_ipc_delegate.h"
26 26
27 namespace base { 27 namespace base {
28 class SingleThreadTaskRunner; 28 class SingleThreadTaskRunner;
29 } // namespace base 29 } // namespace base
30 30
31 namespace remoting { 31 namespace remoting {
32 32
33 class WtsConsoleMonitor; 33 class WtsConsoleMonitor;
34 class WtsSessionProcessLauncherImpl;
34 35
35 class WtsSessionProcessLauncher 36 class WtsSessionProcessLauncher
36 : public base::MessagePumpForIO::IOHandler, 37 : public Stoppable,
37 public Stoppable,
38 public WorkerProcessIpcDelegate, 38 public WorkerProcessIpcDelegate,
39 public WorkerProcessLauncher::Delegate,
40 public WtsConsoleObserver { 39 public WtsConsoleObserver {
41 public: 40 public:
42 // Constructs a WtsSessionProcessLauncher object. |stopped_callback| and 41 // Constructs a WtsSessionProcessLauncher object. |stopped_callback| and
43 // |main_message_loop| are passed to the undelying |Stoppable| implementation. 42 // |main_message_loop| are passed to the undelying |Stoppable| implementation.
44 // All interaction with |monitor| should happen on |main_message_loop|. 43 // All interaction with |monitor| should happen on |main_message_loop|.
45 // |ipc_message_loop| must be an I/O message loop. 44 // |ipc_message_loop| must be an I/O message loop.
46 WtsSessionProcessLauncher( 45 WtsSessionProcessLauncher(
47 const base::Closure& stopped_callback, 46 const base::Closure& stopped_callback,
48 WtsConsoleMonitor* monitor, 47 WtsConsoleMonitor* monitor,
49 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop, 48 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop,
50 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop); 49 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop);
51 50
52 virtual ~WtsSessionProcessLauncher(); 51 virtual ~WtsSessionProcessLauncher();
53 52
54 // base::MessagePumpForIO::IOHandler implementation.
55 virtual void OnIOCompleted(base::MessagePumpForIO::IOContext* context,
56 DWORD bytes_transferred,
57 DWORD error) OVERRIDE;
58
59 // WorkerProcessIpcDelegate implementation. 53 // WorkerProcessIpcDelegate implementation.
60 virtual void OnChannelConnected() OVERRIDE; 54 virtual void OnChannelConnected() OVERRIDE;
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
62 56
63 // WorkerProcessLauncher::Delegate implementation.
64 virtual bool DoLaunchProcess(
65 const std::string& channel_name,
66 base::win::ScopedHandle* process_exit_event_out) OVERRIDE;
67 virtual void DoKillProcess(DWORD exit_code) OVERRIDE;
68
69 // WtsConsoleObserver implementation. 57 // WtsConsoleObserver implementation.
70 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; 58 virtual void OnSessionAttached(uint32 session_id) OVERRIDE;
71 virtual void OnSessionDetached() OVERRIDE; 59 virtual void OnSessionDetached() OVERRIDE;
72 60
73 protected: 61 protected:
74 // Stoppable implementation. 62 // Stoppable implementation.
75 virtual void DoStop() OVERRIDE; 63 virtual void DoStop() OVERRIDE;
76 64
77 private: 65 private:
78 // Drains the completion port queue to make sure that all job object
79 // notifications has been received.
80 void DrainJobNotifications();
81
82 // Notifies that the completion port queue has been drained.
83 void DrainJobNotificationsCompleted();
84
85 // Creates and initializes the job object that will sandbox the launched child
86 // processes.
87 void InitializeJob();
88
89 // Notifies that the job object initialization is complete.
90 void InitializeJobCompleted(scoped_ptr<base::win::ScopedHandle> job);
91
92 void OnJobNotification(DWORD message, DWORD pid);
93
94 // Attempts to launch the host process in the current console session. 66 // Attempts to launch the host process in the current console session.
95 // Schedules next launch attempt if creation of the process fails for any 67 // Schedules next launch attempt if creation of the process fails for any
96 // reason. 68 // reason.
97 void LaunchProcess(); 69 void LaunchProcess();
98 70
99 // Called when the launcher reports the process to be stopped. 71 // Called when the launcher reports the process to be stopped.
100 void OnLauncherStopped(); 72 void OnLauncherStopped();
101 73
102 // |true| if this object is currently attached to the console session. 74 // |true| if this object is currently attached to the console session.
103 bool attached_; 75 bool attached_;
104 76
77 // The specific code knowing how to launch and control a child process
78 // implemented by |WtsSessionProcessLauncherImpl|.
79 scoped_refptr<WtsSessionProcessLauncherImpl> impl_;
80
105 // Time of the last launch attempt. 81 // Time of the last launch attempt.
106 base::Time launch_time_; 82 base::Time launch_time_;
107 83
108 // Current backoff delay. 84 // Current backoff delay.
109 base::TimeDelta launch_backoff_; 85 base::TimeDelta launch_backoff_;
110 86
111 // Timer used to schedule the next attempt to launch the process. 87 // Timer used to schedule the next attempt to launch the process.
112 base::OneShotTimer<WtsSessionProcessLauncher> timer_; 88 base::OneShotTimer<WtsSessionProcessLauncher> timer_;
113 89
114 // The main service message loop. 90 // The main service message loop.
115 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop_; 91 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop_;
116 92
117 // Message loop used by the IPC channel. 93 // Message loop used by the IPC channel.
118 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop_; 94 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop_;
119 95
120 // This pointer is used to unsubscribe from session attach and detach events. 96 // This pointer is used to unsubscribe from session attach and detach events.
121 WtsConsoleMonitor* monitor_; 97 WtsConsoleMonitor* monitor_;
122 98
123 scoped_ptr<WorkerProcessLauncher> launcher_; 99 scoped_ptr<WorkerProcessLauncher> launcher_;
124 100
125 // The job object used to control the lifetime of child processes.
126 base::win::ScopedHandle job_;
127
128 // A waiting handle that becomes signalled once all process associated with
129 // the job have been terminated.
130 base::win::ScopedHandle process_exit_event_;
131
132 enum JobState {
133 kJobUninitialized,
134 kJobRunning,
135 kJobStopping,
136 kJobStopped
137 };
138
139 JobState job_state_;
140
141 base::win::ScopedHandle worker_process_;
142
143 // The token to be used to launch a process in a different session.
144 base::win::ScopedHandle session_token_;
145
146 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); 101 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher);
147 }; 102 };
148 103
149 } // namespace remoting 104 } // namespace remoting
150 105
151 #endif // REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_ 106 #endif // REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/win/wts_session_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698