summaryrefslogtreecommitdiffstats
path: root/remoting/host/daemon_process.cc
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 01:28:58 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 01:28:58 +0000
commit16480f78f7c2eff9b1642eb2270f55f898ce1f63 (patch)
tree5587a6edb30c6b0ff95cd6bca5d940d0269e8215 /remoting/host/daemon_process.cc
parent4d82fad47f12bf876135494e1e353b41f558ba02 (diff)
downloadchromium_src-16480f78f7c2eff9b1642eb2270f55f898ce1f63.zip
chromium_src-16480f78f7c2eff9b1642eb2270f55f898ce1f63.tar.gz
chromium_src-16480f78f7c2eff9b1642eb2270f55f898ce1f63.tar.bz2
Introducing the DaemonProcess class that will implements core of the daemon process functionality. It will manage the networking process running at lower privileges and maintains the list of virtual terminals.
BUG=134694 Review URL: https://chromiumcodereview.appspot.com/10823062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/daemon_process.cc')
-rw-r--r--remoting/host/daemon_process.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
new file mode 100644
index 0000000..d0ccd0c
--- /dev/null
+++ b/remoting/host/daemon_process.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/daemon_process.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread.h"
+
+namespace {
+
+const char kIpcThreadName[] = "Daemon process IPC";
+
+} // namespace
+
+namespace remoting {
+
+DaemonProcess::~DaemonProcess() {
+}
+
+bool DaemonProcess::OnMessageReceived(const IPC::Message& message) {
+ return true;
+}
+
+DaemonProcess::DaemonProcess(
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ const base::Closure& stopped_callback)
+ : Stoppable(main_task_runner, stopped_callback),
+ main_task_runner_(main_task_runner) {
+ // Initialize on the same thread that will be used for shutting down.
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DaemonProcess::Init, base::Unretained(this)));
+}
+
+void DaemonProcess::Init() {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+
+ // Launch the IPC thread.
+ ipc_thread_.reset(new base::Thread(kIpcThreadName));
+ base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
+ if (!ipc_thread_->StartWithOptions(io_thread_options)) {
+ LOG(ERROR) << "Failed to start the Daemon process IPC thread.";
+ Stop();
+ return;
+ }
+
+ if (!LaunchNetworkProcess()) {
+ LOG(ERROR) << "Failed to launch the networking process.";
+ Stop();
+ return;
+ }
+}
+
+void DaemonProcess::DoStop() {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+
+ if (ipc_thread_.get()) {
+ ipc_thread_->Stop();
+ }
+
+ CompleteStopping();
+}
+
+} // namespace remoting