Chromium Code Reviews| Index: remoting/client/chromoting_client_runtime.cc |
| diff --git a/remoting/client/chromoting_client_runtime.cc b/remoting/client/chromoting_client_runtime.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e7c527462b60323bdf302ea32a8d753ef1d341e6 |
| --- /dev/null |
| +++ b/remoting/client/chromoting_client_runtime.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2016 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/client/chromoting_client_runtime.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "remoting/base/url_request_context_getter.h" |
| + |
| +namespace remoting { |
| + |
| +scoped_ptr<ChromotingClientRuntime> ChromotingClientRuntime::Create() { |
| + return make_scoped_ptr(new ChromotingClientRuntime()); |
| +} |
| + |
| +ChromotingClientRuntime::ChromotingClientRuntime() { |
| + if (!base::MessageLoop::current()) { |
|
Sergey Ulanov
2016/03/11 01:22:34
Maybe just replace it with a DCHECK and make the c
nicholss
2016/03/11 21:23:02
Ok, I moved this out, it is starting to look more
|
| + VLOG(1) << "Starting main message loop"; |
| + ui_loop_.reset(new base::MessageLoopForUI()); |
| +#if defined(OS_IOS) |
| + // On iOS we created a new message loop and now attach it. |
| + base::MessageLoopForUI::current()->Attach(); |
|
Lambros
2016/03/10 00:52:15
ui_loop_->Attach(); maybe?
nicholss
2016/03/11 21:23:02
Done.
|
| +#elif defined(OS_ANDROID) |
| + // On Android, the UI thread is managed by Java, so we need to attach and |
| + // start a special type of message loop to allow Chromium code to run tasks. |
| + ui_loop_->Start(); |
| +#else |
| + NOTREACHED(); |
|
Lambros
2016/03/10 00:52:15
This file seems to be specific to mobile clients.
nicholss
2016/03/11 21:23:02
This is fixed with the moving of the main thread g
|
| +#endif |
| + } else { |
| + VLOG(1) << "Using existing main message loop"; |
| + ui_loop_.reset(base::MessageLoopForUI::current()); |
| + } |
| + |
| + // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the |
| + // main thread. We can not kill the main thread when the message loop becomes |
| + // idle so the callback function does nothing (as opposed to the typical |
| + // base::MessageLoop::QuitClosure()) |
| + ui_task_runner_ = new AutoThreadTaskRunner(ui_loop_->task_runner(), |
| + base::Bind(&base::DoNothing)); |
| + |
| + display_task_runner_ = AutoThread::Create("native_disp", ui_task_runner_); |
| + network_task_runner_ = AutoThread::CreateWithType( |
| + "native_net", ui_task_runner_, base::MessageLoop::TYPE_IO); |
| + file_task_runner_ = AutoThread::CreateWithType("native_file", ui_task_runner_, |
|
Lambros
2016/03/10 00:52:15
Adding a new thread (and passing it to URLRequestC
nicholss
2016/03/11 21:23:02
Testing now.
|
| + base::MessageLoop::TYPE_IO); |
| + url_requester_ = |
| + new URLRequestContextGetter(network_task_runner_, file_task_runner_); |
| +} |
| + |
| +ChromotingClientRuntime::~ChromotingClientRuntime() {} |
| + |
| +} // namespace remoting |