Chromium Code Reviews| Index: remoting/client/ios/chromoting_client_runtime_ios.cc |
| diff --git a/remoting/client/ios/chromoting_client_runtime_ios.cc b/remoting/client/ios/chromoting_client_runtime_ios.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..69c176a3e2ca9883dcbeb696c877878fc97250f6 |
| --- /dev/null |
| +++ b/remoting/client/ios/chromoting_client_runtime_ios.cc |
| @@ -0,0 +1,72 @@ |
| +// 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 "base/memory/singleton.h" |
| +#include "remoting/base/url_request_context_getter.h" |
| + |
| +namespace { |
| + |
| +void DoNothing() {} |
| +} // namespace |
| + |
| +namespace remoting { |
| + |
| +ChromotingClientRuntimeIos::ChromotingClientRuntime() { |
|
Sergey Ulanov
2016/03/04 22:50:17
There is nothing in this class that's specific to
nicholss
2016/03/07 18:32:36
The Android runtime has a bunch of jni connections
|
| + if (!base::MessageLoop::current()) { |
| + VLOG(1) << "Starting main message loop"; |
| + ui_loop_ = new base::MessageLoop(base::MessageLoop::TYPE_UI); |
| + base::MessageLoopForUI::current()->Attach(); |
| + } else { |
| + VLOG(1) << "Using existing main message loop"; |
| + ui_loop_ = 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(&::DoNothing)); |
| + |
| + network_task_runner_ = AutoThread::CreateWithType( |
| + "native_net", ui_task_runner_, base::MessageLoop::TYPE_IO); |
| + file_task_runner_ = AutoThread::CreateWithType("native_file", ui_task_runner_, |
| + base::MessageLoop::TYPE_IO); |
| + |
| + url_requester_ = |
| + new URLRequestContextGetter(network_task_runner_, file_task_runner_); |
| +} |
| + |
| +// static |
| +ChromotingClientRuntime* ChromotingClientRuntimeIos::GetInstance() { |
| + return base::Singleton<ChromotingClientRuntime>::get(); |
| +} |
| + |
| +ChromotingClientRuntimeIos::~ChromotingClientRuntime() {} |
|
Sergey Ulanov
2016/03/04 22:50:17
You are missing Ios suffix in the name, so this co
nicholss
2016/03/07 18:32:36
Acknowledged.
|
| + |
| +scoped_refptr<AutoThreadTaskRunner> |
| +ChromotingClientRuntimeIos::network_task_runner() { |
| + return network_task_runner_; |
| +} |
| + |
| +scoped_refptr<AutoThreadTaskRunner> |
| +ChromotingClientRuntimeIos::display_task_runner() { |
| + return ui_task_runner_; |
| +} |
| + |
| +scoped_refptr<AutoThreadTaskRunner> |
| +ChromotingClientRuntimeIos::file_task_runner() { |
| + return file_task_runner_; |
| +} |
| + |
| +scoped_refptr<net::URLRequestContextGetter> |
| +ChromotingClientRuntimeIos::url_requester() { |
| + return url_requester_; |
| +} |
| + |
| +} // namespace remoting |