diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 19:58:36 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 19:58:36 +0000 |
commit | df338b7db4dfebd184886fec55db969305c94f07 (patch) | |
tree | 8e0184e81556899615ffac2120efe0ea563a1cce /remoting/host/win | |
parent | e2206627c1f4f26425b7ba51a21e8d021956bea1 (diff) | |
download | chromium_src-df338b7db4dfebd184886fec55db969305c94f07.zip chromium_src-df338b7db4dfebd184886fec55db969305c94f07.tar.gz chromium_src-df338b7db4dfebd184886fec55db969305c94f07.tar.bz2 |
[Chromoting] The daemon process now starts the networking process and passes the host configuration (and updates) over the IPC channel.
This CL also switches to FilePathWatcher (to detect the configuration file changes) on all platforms.
BUG=123696,134694
Review URL: https://chromiumcodereview.appspot.com/10855249
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/win')
-rw-r--r-- | remoting/host/win/host_service.cc | 3 | ||||
-rw-r--r-- | remoting/host/win/worker_process_launcher.cc | 24 | ||||
-rw-r--r-- | remoting/host/win/worker_process_launcher.h | 25 | ||||
-rw-r--r-- | remoting/host/win/wts_session_process_launcher.cc | 21 | ||||
-rw-r--r-- | remoting/host/win/wts_session_process_launcher.h | 15 |
5 files changed, 46 insertions, 42 deletions
diff --git a/remoting/host/win/host_service.cc b/remoting/host/win/host_service.cc index 92dda1d..b882d52 100644 --- a/remoting/host/win/host_service.cc +++ b/remoting/host/win/host_service.cc @@ -80,8 +80,7 @@ const wchar_t kUsageMessage[] = // The command line parameters that should be copied from the service's command // line when launching an elevated child. const char* kCopiedSwitchNames[] = { - "auth-config", "host-config", "chromoting-ipc", switches::kV, - switches::kVModule }; + "host-config", "daemon-pipe", switches::kV, switches::kVModule }; // Exit codes: const int kSuccessExitCode = 0; diff --git a/remoting/host/win/worker_process_launcher.cc b/remoting/host/win/worker_process_launcher.cc index 9f5f35a..834b8bb 100644 --- a/remoting/host/win/worker_process_launcher.cc +++ b/remoting/host/win/worker_process_launcher.cc @@ -21,6 +21,7 @@ #include "base/win/scoped_handle.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_message.h" +#include "remoting/host/worker_process_ipc_delegate.h" using base::win::ScopedHandle; @@ -38,12 +39,14 @@ WorkerProcessLauncher::Delegate::~Delegate() { } WorkerProcessLauncher::WorkerProcessLauncher( - Delegate* delegate, + Delegate* launcher_delegate, + WorkerProcessIpcDelegate* worker_delegate, const base::Closure& stopped_callback, scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner) : Stoppable(main_task_runner, stopped_callback), - delegate_(delegate), + launcher_delegate_(launcher_delegate), + worker_delegate_(worker_delegate), main_task_runner_(main_task_runner), ipc_task_runner_(ipc_task_runner) { } @@ -70,12 +73,13 @@ void WorkerProcessLauncher::Start(const std::string& pipe_sddl) { // Launch the process and attach an object watcher to the returned process // handle so that we get notified if the process terminates. - if (delegate_->DoLaunchProcess(channel_name, &process_exit_event_)) { + if (launcher_delegate_->DoLaunchProcess(channel_name, + &process_exit_event_)) { if (process_watcher_.StartWatching(process_exit_event_, this)) { return; } - delegate_->DoKillProcess(CONTROL_C_EXIT); + launcher_delegate_->DoKillProcess(CONTROL_C_EXIT); } } @@ -85,7 +89,11 @@ void WorkerProcessLauncher::Start(const std::string& pipe_sddl) { void WorkerProcessLauncher::Send(IPC::Message* message) { DCHECK(main_task_runner_->BelongsToCurrentThread()); - ipc_channel_->Send(message); + if (ipc_channel_.get()) { + ipc_channel_->Send(message); + } else { + delete message; + } } void WorkerProcessLauncher::OnObjectSignaled(HANDLE object) { @@ -101,7 +109,7 @@ bool WorkerProcessLauncher::OnMessageReceived(const IPC::Message& message) { DCHECK(pipe_.IsValid()); DCHECK(process_exit_event_.IsValid()); - return delegate_->OnMessageReceived(message); + return worker_delegate_->OnMessageReceived(message); } void WorkerProcessLauncher::OnChannelConnected(int32 peer_pid) { @@ -118,7 +126,7 @@ void WorkerProcessLauncher::OnChannelConnected(int32 peer_pid) { // If we'd like to be able to launch low-privileged workers and let them // connect back, the pipe handle should be passed to the worker instead of // the pipe name. - delegate_->OnChannelConnected(); + worker_delegate_->OnChannelConnected(); } void WorkerProcessLauncher::OnChannelError() { @@ -144,7 +152,7 @@ void WorkerProcessLauncher::DoStop() { // Kill the process if it has been started already. if (process_watcher_.GetWatchedObject() != NULL) { - delegate_->DoKillProcess(CONTROL_C_EXIT); + launcher_delegate_->DoKillProcess(CONTROL_C_EXIT); return; } diff --git a/remoting/host/win/worker_process_launcher.h b/remoting/host/win/worker_process_launcher.h index 1d47022..d53f860 100644 --- a/remoting/host/win/worker_process_launcher.h +++ b/remoting/host/win/worker_process_launcher.h @@ -29,6 +29,8 @@ class Message; namespace remoting { +class WorkerProcessIpcDelegate; + // Launches a worker process that is controlled via an IPC channel. All // interaction with the spawned process is through the IPC::Listener and Send() // method. In case of error the channel is closed and the worker process is @@ -53,25 +55,18 @@ class WorkerProcessLauncher // Terminates the worker process with the given exit code. virtual void DoKillProcess(DWORD exit_code) = 0; - - // Notifies that a client has been connected to the channel. - virtual void OnChannelConnected() = 0; - - // Processes messages sent by the client. - virtual bool OnMessageReceived(const IPC::Message& message) = 0; }; - // Creates the launcher. - // |delegate| will be able to receive messages sent over the channel once - // the worker has been started and until it is stopped by Stop() or an error - // occurs. + // Creates the launcher that will use |launcher_delegate| to manage the worker + // process and |worker_delegate| to handle IPCs. // // |stopped_callback| and |main_task_runner| are passed to the underlying // |Stoppable| implementation. The caller should call all the methods on this // class on the |main_task_runner| thread. |ipc_task_runner| is used to // perform background IPC I/O. WorkerProcessLauncher( - Delegate* delegate, + Delegate* launcher_delegate, + WorkerProcessIpcDelegate* worker_delegate, const base::Closure& stopped_callback, scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner); @@ -80,8 +75,9 @@ class WorkerProcessLauncher // Starts the worker process. void Start(const std::string& pipe_sddl); - // Sends an IPC message to the worker process. This method can be called only - // after successful Start() and until Stop() is called or an error occurred. + // Sends an IPC message to the worker process. The message will be silently + // dropped if Send() is called before Start() or after stutdown has been + // initiated. void Send(IPC::Message* message); // base::win::ObjectWatcher::Delegate implementation. @@ -105,7 +101,8 @@ class WorkerProcessLauncher // Generates random channel ID. std::string GenerateRandomChannelId(); - Delegate* delegate_; + Delegate* launcher_delegate_; + WorkerProcessIpcDelegate* worker_delegate_; // The main service message loop. scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; diff --git a/remoting/host/win/wts_session_process_launcher.cc b/remoting/host/win/wts_session_process_launcher.cc index cf5a908..d659f15 100644 --- a/remoting/host/win/wts_session_process_launcher.cc +++ b/remoting/host/win/wts_session_process_launcher.cc @@ -20,7 +20,6 @@ #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "base/path_service.h" -#include "base/process_util.h" #include "base/rand_util.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" @@ -49,19 +48,19 @@ const FilePath::CharType kMe2meHostBinaryName[] = const FilePath::CharType kMe2meServiceBinaryName[] = FILE_PATH_LITERAL("remoting_service.exe"); -// The IPC channel name is passed to the host in the command line. -const char kChromotingIpcSwitchName[] = "chromoting-ipc"; +// The command line switch specifying the name of the daemon IPC endpoint. +const char kDaemonIpcSwitchName[] = "daemon-pipe"; const char kElevateSwitchName[] = "elevate"; // The command line parameters that should be copied from the service's command // line to the host process. const char* kCopiedSwitchNames[] = { - "auth-config", "host-config", switches::kV, switches::kVModule }; + "host-config", switches::kV, switches::kVModule }; -// The security descriptor of the Chromoting IPC channel. It gives full access +// The security descriptor of the daemon IPC endpoint. It gives full access // to LocalSystem and denies access by anyone else. -const char kChromotingChannelSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; +const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; } // namespace @@ -94,8 +93,8 @@ WtsSessionProcessLauncher::WtsSessionProcessLauncher( WtsSessionProcessLauncher::~WtsSessionProcessLauncher() { // Make sure that the object is completely stopped. The same check exists - // in Stoppable::~Stoppable() but this one allows us to examine the state of - // the object before destruction. + // in Stoppable::~Stoppable() but this one helps us to fail early and + // predictably. CHECK_EQ(stoppable_state(), Stoppable::kStopped); monitor_->RemoveWtsConsoleObserver(this); @@ -141,7 +140,7 @@ bool WtsSessionProcessLauncher::DoLaunchProcess( // to use and copying known switches from the service's command line. CommandLine command_line(service_binary); command_line.AppendSwitchPath(kElevateSwitchName, host_binary); - command_line.AppendSwitchNative(kChromotingIpcSwitchName, + command_line.AppendSwitchNative(kDaemonIpcSwitchName, UTF8ToWide(channel_name)); command_line.CopySwitchesFrom(*CommandLine::ForCurrentProcess(), kCopiedSwitchNames, @@ -375,12 +374,12 @@ void WtsSessionProcessLauncher::LaunchProcess() { launch_time_ = base::Time::Now(); launcher_.reset(new WorkerProcessLauncher( - this, + this, this, base::Bind(&WtsSessionProcessLauncher::OnLauncherStopped, base::Unretained(this)), main_message_loop_, ipc_message_loop_)); - launcher_->Start(kChromotingChannelSecurityDescriptor); + launcher_->Start(kDaemonIpcSecurityDescriptor); } void WtsSessionProcessLauncher::OnLauncherStopped() { diff --git a/remoting/host/win/wts_session_process_launcher.h b/remoting/host/win/wts_session_process_launcher.h index e522748..097e588 100644 --- a/remoting/host/win/wts_session_process_launcher.h +++ b/remoting/host/win/wts_session_process_launcher.h @@ -9,6 +9,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/file_path.h" +#include "base/file_util.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" @@ -20,16 +22,12 @@ #include "remoting/base/stoppable.h" #include "remoting/host/win/worker_process_launcher.h" #include "remoting/host/win/wts_console_observer.h" +#include "remoting/host/worker_process_ipc_delegate.h" namespace base { class SingleThreadTaskRunner; } // namespace base -namespace IPC { -class ChannelProxy; -class Message; -} // namespace IPC - namespace remoting { class WtsConsoleMonitor; @@ -37,6 +35,7 @@ class WtsConsoleMonitor; class WtsSessionProcessLauncher : public base::MessagePumpForIO::IOHandler, public Stoppable, + public WorkerProcessIpcDelegate, public WorkerProcessLauncher::Delegate, public WtsConsoleObserver { public: @@ -57,13 +56,15 @@ class WtsSessionProcessLauncher DWORD bytes_transferred, DWORD error) OVERRIDE; + // WorkerProcessIpcDelegate implementation. + virtual void OnChannelConnected() OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + // WorkerProcessLauncher::Delegate implementation. virtual bool DoLaunchProcess( const std::string& channel_name, base::win::ScopedHandle* process_exit_event_out) OVERRIDE; virtual void DoKillProcess(DWORD exit_code) OVERRIDE; - virtual void OnChannelConnected() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; // WtsConsoleObserver implementation. virtual void OnSessionAttached(uint32 session_id) OVERRIDE; |