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

Side by Side Diff: remoting/host/daemon_process.cc

Issue 10837292: [Chromoting] Moving the I/O thread out of DaemonProcess (so it can be shared if needed). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/daemon_process.h ('k') | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "remoting/host/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 11
12 namespace { 12 namespace {
13 13
14 const char kIpcThreadName[] = "Daemon process IPC"; 14 const char kIpcThreadName[] = "Daemon process IPC";
15 15
16 } // namespace 16 } // namespace
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 DaemonProcess::~DaemonProcess() { 20 DaemonProcess::~DaemonProcess() {
21 } 21 }
22 22
23 bool DaemonProcess::OnMessageReceived(const IPC::Message& message) { 23 bool DaemonProcess::OnMessageReceived(const IPC::Message& message) {
24 return true; 24 return true;
25 } 25 }
26 26
27 DaemonProcess::DaemonProcess( 27 DaemonProcess::DaemonProcess(
28 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
29 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
29 const base::Closure& stopped_callback) 30 const base::Closure& stopped_callback)
30 : Stoppable(main_task_runner, stopped_callback), 31 : Stoppable(main_task_runner, stopped_callback),
31 main_task_runner_(main_task_runner) { 32 main_task_runner_(main_task_runner),
33 io_task_runner_(io_task_runner) {
32 // Initialize on the same thread that will be used for shutting down. 34 // Initialize on the same thread that will be used for shutting down.
33 main_task_runner_->PostTask( 35 main_task_runner_->PostTask(
34 FROM_HERE, 36 FROM_HERE,
35 base::Bind(&DaemonProcess::Init, base::Unretained(this))); 37 base::Bind(&DaemonProcess::Init, base::Unretained(this)));
36 } 38 }
37 39
38 void DaemonProcess::Init() { 40 void DaemonProcess::Init() {
39 DCHECK(main_task_runner_->BelongsToCurrentThread()); 41 DCHECK(main_task_runner_->BelongsToCurrentThread());
40 42
41 // Launch the IPC thread.
42 ipc_thread_.reset(new base::Thread(kIpcThreadName));
43 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
44 if (!ipc_thread_->StartWithOptions(io_thread_options)) {
45 LOG(ERROR) << "Failed to start the Daemon process IPC thread.";
46 Stop();
47 return;
48 }
49
50 if (!LaunchNetworkProcess()) { 43 if (!LaunchNetworkProcess()) {
51 LOG(ERROR) << "Failed to launch the networking process."; 44 LOG(ERROR) << "Failed to launch the networking process.";
52 Stop(); 45 Stop();
53 return; 46 return;
54 } 47 }
55 } 48 }
56 49
57 void DaemonProcess::DoStop() { 50 void DaemonProcess::DoStop() {
58 DCHECK(main_task_runner_->BelongsToCurrentThread()); 51 DCHECK(main_task_runner_->BelongsToCurrentThread());
59 52
60 if (ipc_thread_.get()) {
61 ipc_thread_->Stop();
62 }
63
64 CompleteStopping(); 53 CompleteStopping();
65 } 54 }
66 55
67 } // namespace remoting 56 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/daemon_process.h ('k') | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698