Commit 419a4b26 authored by alexeypa@chromium.org's avatar alexeypa@chromium.org

[Chromoting] Moving the I/O thread out of DaemonProcess (so it can be shared if needed).

BUG=134694


Review URL: https://chromiumcodereview.appspot.com/10837292

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152299 0039d316-1c4b-4281-b951-d872f2087c98
parent b0e1ac9a
......@@ -26,9 +26,11 @@ bool DaemonProcess::OnMessageReceived(const IPC::Message& message) {
DaemonProcess::DaemonProcess(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback)
: Stoppable(main_task_runner, stopped_callback),
main_task_runner_(main_task_runner) {
main_task_runner_(main_task_runner),
io_task_runner_(io_task_runner) {
// Initialize on the same thread that will be used for shutting down.
main_task_runner_->PostTask(
FROM_HERE,
......@@ -38,15 +40,6 @@ DaemonProcess::DaemonProcess(
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();
......@@ -57,10 +50,6 @@ void DaemonProcess::Init() {
void DaemonProcess::DoStop() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
if (ipc_thread_.get()) {
ipc_thread_->Stop();
}
CompleteStopping();
}
......
......@@ -34,6 +34,7 @@ class DaemonProcess : public Stoppable, public IPC::Listener {
// Creates a platform-specific implementation of the daemon process object.
static scoped_ptr<DaemonProcess> Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback);
// IPC::Listener implementation.
......@@ -41,6 +42,7 @@ class DaemonProcess : public Stoppable, public IPC::Listener {
protected:
DaemonProcess(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback);
// Reads the host configuration and launches the networking process.
......@@ -56,8 +58,8 @@ class DaemonProcess : public Stoppable, public IPC::Listener {
// The main task runner. Typically it is the UI message loop.
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
// A dedicated thread for handling IPC requests.
scoped_ptr<base::Thread> ipc_thread_;
// Handles IPC and background I/O tasks.
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
// The IPC channel connecting the daemon process to the networking process.
scoped_ptr<IPC::ChannelProxy> network_process_channel_;
......
......@@ -13,6 +13,7 @@ namespace remoting {
class DaemonProcessWin : public DaemonProcess {
public:
DaemonProcessWin(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback);
virtual ~DaemonProcessWin();
......@@ -25,8 +26,9 @@ class DaemonProcessWin : public DaemonProcess {
DaemonProcessWin::DaemonProcessWin(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback)
: DaemonProcess(main_task_runner, stopped_callback) {
: DaemonProcess(main_task_runner, io_task_runner, stopped_callback) {
}
DaemonProcessWin::~DaemonProcessWin() {
......@@ -39,9 +41,10 @@ bool DaemonProcessWin::LaunchNetworkProcess() {
scoped_ptr<DaemonProcess> DaemonProcess::Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback) {
scoped_ptr<DaemonProcessWin> daemon_process(
new DaemonProcessWin(main_task_runner, stopped_callback));
new DaemonProcessWin(main_task_runner, io_task_runner, stopped_callback));
return daemon_process.PassAs<DaemonProcess>();
}
......
......@@ -197,15 +197,6 @@ int HostService::Run() {
}
void HostService::RunMessageLoop(MessageLoop* message_loop) {
#if defined(REMOTING_MULTI_PROCESS)
child_ = DaemonProcess::Create(
main_task_runner_,
base::Bind(&HostService::OnChildStopped,
base::Unretained(this))).PassAs<Stoppable>();
#else // !defined(REMOTING_MULTI_PROCESS)
// Launch the I/O thread.
base::Thread io_thread(kIoThreadName);
base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
......@@ -215,6 +206,16 @@ void HostService::RunMessageLoop(MessageLoop* message_loop) {
return;
}
#if defined(REMOTING_MULTI_PROCESS)
child_ = DaemonProcess::Create(
main_task_runner_,
io_thread.message_loop_proxy(),
base::Bind(&HostService::OnChildStopped,
base::Unretained(this))).PassAs<Stoppable>();
#else // !defined(REMOTING_MULTI_PROCESS)
// Create the session process launcher.
child_.reset(new WtsSessionProcessLauncher(
base::Bind(&HostService::OnChildStopped, base::Unretained(this)),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment