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

Unified Diff: remoting/host/host_service_win.cc

Issue 10823062: Introducing the DaemonProcess class that will implements core of the daemon process functionality. … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/host_service_win.cc
diff --git a/remoting/host/host_service_win.cc b/remoting/host/host_service_win.cc
index b2952a6c69e6e20faebf1cb32e598471b6ae3010..8475ed778b29ee7278ce21606dd90b4c363f3ee8 100644
--- a/remoting/host/host_service_win.cc
+++ b/remoting/host/host_service_win.cc
@@ -27,15 +27,26 @@
#include "remoting/base/scoped_sc_handle_win.h"
#include "remoting/base/shutdownable.h"
#include "remoting/host/branding.h"
+
+#if defined(REMOTING_MULTI_PROCESS)
+#include "remoting/host/daemon_process.h"
+#endif // defined(REMOTING_MULTI_PROCESS)
+
#include "remoting/host/host_service_resource.h"
#include "remoting/host/usage_stats_consent.h"
#include "remoting/host/wts_console_observer_win.h"
+
+#if !defined(REMOTING_MULTI_PROCESS)
#include "remoting/host/wts_session_process_launcher_win.h"
+#endif // !defined(REMOTING_MULTI_PROCESS)
using base::StringPrintf;
namespace {
+// Session id that does not represent any session.
+const uint32 kInvalidSessionId = 0xffffffffu;
+
const char kIoThreadName[] = "I/O thread";
// A window class for the session change notifications window.
@@ -100,8 +111,8 @@ void HostService::RemoveWtsConsoleObserver(WtsConsoleObserver* observer) {
console_observers_.RemoveObserver(observer);
}
-void HostService::OnLauncherShutdown(Shutdownable* /* launcher */) {
- launcher_.reset(NULL);
+void HostService::OnShutdownableStopped(Shutdownable* /* launcher */) {
Sergey Ulanov 2012/07/30 19:50:04 OnChildStopped?
alexeypa (please no reviews) 2012/07/30 21:50:03 Done.
+ child_.reset(NULL);
main_task_runner_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
}
@@ -138,8 +149,7 @@ BOOL WINAPI HostService::ConsoleControlHandler(DWORD event) {
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
self->main_task_runner_->PostTask(FROM_HERE, base::Bind(
- &WtsSessionProcessLauncher::Shutdown,
- base::Unretained(self->launcher_.get())));
+ &Shutdownable::Shutdown, base::Unretained(self->child_.get())));
self->stopped_event_.Wait();
return TRUE;
@@ -182,22 +192,32 @@ int HostService::Run() {
}
void HostService::RunMessageLoop(MessageLoop* message_loop) {
+#if defined(REMOTING_MULTI_PROCESS)
+
+ child_ = DaemonProcess::Create(
+ main_task_runner_,
+ base::Bind(&HostService::OnShutdownableStopped, base::Unretained(this)));
+
+#else
Sergey Ulanov 2012/07/30 19:50:04 // !defined(REMOTING_MULTI_PROCESS)
alexeypa (please no reviews) 2012/07/30 21:50:03 Done.
+
// Launch the I/O thread.
base::Thread io_thread(kIoThreadName);
base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
if (!io_thread.StartWithOptions(io_thread_options)) {
- LOG(FATAL) << "Failed to start the I/O thread";
+ LOG(ERROR) << "Failed to start the I/O thread";
stopped_event_.Signal();
return;
}
// Create the session process launcher.
- launcher_.reset(new WtsSessionProcessLauncher(
- base::Bind(&HostService::OnLauncherShutdown, base::Unretained(this)),
+ child_.reset(new WtsSessionProcessLauncher(
+ base::Bind(&HostService::OnShutdownableStopped, base::Unretained(this)),
this,
main_task_runner_,
io_thread.message_loop_proxy()));
+#endif // defined(REMOTING_MULTI_PROCESS)
Sergey Ulanov 2012/07/30 19:50:04 nit: // !defined(REMOTING_MULTI_PROCESS)
alexeypa (please no reviews) 2012/07/30 21:50:03 Done.
+
// Run the service.
message_loop->Run();
@@ -304,8 +324,7 @@ DWORD WINAPI HostService::ServiceControlHandler(DWORD control,
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
self->main_task_runner_->PostTask(FROM_HERE, base::Bind(
- &WtsSessionProcessLauncher::Shutdown,
- base::Unretained(self->launcher_.get())));
+ &Shutdownable::Shutdown, base::Unretained(self->child_.get())));
self->stopped_event_.Wait();
return NO_ERROR;

Powered by Google App Engine
This is Rietveld 408576698