| 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_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" |
| 11 #include "base/file_path.h" | |
| 12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/process.h" | 14 #include "base/process.h" |
| 16 #include "base/time.h" | 15 #include "base/time.h" |
| 17 #include "base/timer.h" | 16 #include "base/timer.h" |
| 18 #include "base/win/scoped_handle.h" | 17 #include "base/win/scoped_handle.h" |
| 19 #include "base/win/object_watcher.h" | 18 #include "base/win/object_watcher.h" |
| 20 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
| 21 #include "remoting/base/stoppable.h" | 20 #include "remoting/base/stoppable.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 | 36 |
| 38 class SasInjector; | 37 class SasInjector; |
| 39 class WtsConsoleMonitor; | 38 class WtsConsoleMonitor; |
| 40 | 39 |
| 41 class WtsSessionProcessLauncher | 40 class WtsSessionProcessLauncher |
| 42 : public Stoppable, | 41 : public Stoppable, |
| 43 public base::win::ObjectWatcher::Delegate, | 42 public base::win::ObjectWatcher::Delegate, |
| 44 public IPC::Listener, | 43 public IPC::Listener, |
| 45 public WtsConsoleObserver { | 44 public WtsConsoleObserver { |
| 46 public: | 45 public: |
| 47 // Constructs a WtsSessionProcessLauncher object. |host_binary| is the name of | 46 // Constructs a WtsSessionProcessLauncher object. All interaction with |
| 48 // the executable to be launched in the console session. All interaction with | |
| 49 // |monitor| should happen on |main_message_loop|. |ipc_message_loop| has | 47 // |monitor| should happen on |main_message_loop|. |ipc_message_loop| has |
| 50 // to be an I/O message loop. | 48 // to be an I/O message loop. |
| 51 WtsSessionProcessLauncher( | 49 WtsSessionProcessLauncher( |
| 52 const base::Closure& stopped_callback, | 50 const base::Closure& stopped_callback, |
| 53 WtsConsoleMonitor* monitor, | 51 WtsConsoleMonitor* monitor, |
| 54 const FilePath& host_binary, | |
| 55 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop, | 52 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop, |
| 56 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop); | 53 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop); |
| 57 | 54 |
| 58 virtual ~WtsSessionProcessLauncher(); | 55 virtual ~WtsSessionProcessLauncher(); |
| 59 | 56 |
| 60 // base::win::ObjectWatcher::Delegate implementation. | 57 // base::win::ObjectWatcher::Delegate implementation. |
| 61 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 58 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; |
| 62 | 59 |
| 63 // IPC::Listener implementation. | 60 // IPC::Listener implementation. |
| 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 65 | 62 |
| 66 // WtsConsoleObserver implementation. | 63 // WtsConsoleObserver implementation. |
| 67 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; | 64 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; |
| 68 virtual void OnSessionDetached() OVERRIDE; | 65 virtual void OnSessionDetached() OVERRIDE; |
| 69 | 66 |
| 70 protected: | 67 protected: |
| 71 // Stoppable implementation. | 68 // Stoppable implementation. |
| 72 virtual void DoStop() OVERRIDE; | 69 virtual void DoStop() OVERRIDE; |
| 73 | 70 |
| 74 private: | 71 private: |
| 75 // Attempts to launch the host process in the current console session. | 72 // Attempts to launch the host process in the current console session. |
| 76 // Schedules next launch attempt if creation of the process fails for any | 73 // Schedules next launch attempt if creation of the process fails for any |
| 77 // reason. | 74 // reason. |
| 78 void LaunchProcess(); | 75 void LaunchProcess(); |
| 79 | 76 |
| 80 // Sends the Secure Attention Sequence to the session represented by | 77 // Sends the Secure Attention Sequence to the session represented by |
| 81 // |session_token_|. | 78 // |session_token_|. |
| 82 void OnSendSasToConsole(); | 79 void OnSendSasToConsole(); |
| 83 | 80 |
| 84 // Name of the host executable. | |
| 85 FilePath host_binary_; | |
| 86 | |
| 87 // Time of the last launch attempt. | 81 // Time of the last launch attempt. |
| 88 base::Time launch_time_; | 82 base::Time launch_time_; |
| 89 | 83 |
| 90 // Current backoff delay. | 84 // Current backoff delay. |
| 91 base::TimeDelta launch_backoff_; | 85 base::TimeDelta launch_backoff_; |
| 92 | 86 |
| 93 // Timer used to schedule the next attempt to launch the process. | 87 // Timer used to schedule the next attempt to launch the process. |
| 94 base::OneShotTimer<WtsSessionProcessLauncher> timer_; | 88 base::OneShotTimer<WtsSessionProcessLauncher> timer_; |
| 95 | 89 |
| 96 // The main service message loop. | 90 // The main service message loop. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 scoped_ptr<IPC::ChannelProxy> chromoting_channel_; | 123 scoped_ptr<IPC::ChannelProxy> chromoting_channel_; |
| 130 | 124 |
| 131 scoped_ptr<SasInjector> sas_injector_; | 125 scoped_ptr<SasInjector> sas_injector_; |
| 132 | 126 |
| 133 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); | 127 DISALLOW_COPY_AND_ASSIGN(WtsSessionProcessLauncher); |
| 134 }; | 128 }; |
| 135 | 129 |
| 136 } // namespace remoting | 130 } // namespace remoting |
| 137 | 131 |
| 138 #endif // REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_ | 132 #endif // REMOTING_HOST_WIN_WTS_SESSION_PROCESS_LAUNCHER_H_ |
| OLD | NEW |