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

Unified Diff: remoting/host/daemon_process.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/daemon_process.cc
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
new file mode 100644
index 0000000000000000000000000000000000000000..18f0d99d5603e7992cc5a99df7f6d06fe9dfb539
--- /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 Shutdownable::Callback& callback)
+ : Shutdownable(main_task_runner, 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.";
+ Shutdown();
+ return;
+ }
+
+ if (!LaunchNetworkProcess()) {
+ LOG(ERROR) << "Failed to launch the networking process.";
+ Shutdown();
+ return;
+ }
+}
+
+void DaemonProcess::DoShutdown() {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+
+ if (ipc_thread_.get()) {
+ ipc_thread_->Stop();
+ }
+
+ CompleteShutdown();
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698