summaryrefslogtreecommitdiffstats
path: root/remoting/client/chromoting_client_runtime.h
diff options
context:
space:
mode:
authorlambroslambrou <lambroslambrou@chromium.org>2016-03-22 18:21:20 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 01:23:43 +0000
commite0c2d024129428c1e44fb7dfc198de7fdc427eb3 (patch)
treee0f6a023ae2b161173c2aadf4f0b6fb741bdeab3 /remoting/client/chromoting_client_runtime.h
parent1c4eeac676562ac084da146ffad80e78d56c0b62 (diff)
downloadchromium_src-e0c2d024129428c1e44fb7dfc198de7fdc427eb3.zip
chromium_src-e0c2d024129428c1e44fb7dfc198de7fdc427eb3.tar.gz
chromium_src-e0c2d024129428c1e44fb7dfc198de7fdc427eb3.tar.bz2
Reland: Adding container class for chromoting client runtimes.
Reland http://crrev.com/1764503002 with fixes for the Android app and tests: * Initialize ChromotingClientRuntime::ui_task_runner_ * Add new unittest to GN build. * Don't call MessageLoopForUI::Start() in Android test. TBR=nicholss Review URL: https://codereview.chromium.org/1827573002 Cr-Commit-Position: refs/heads/master@{#382757}
Diffstat (limited to 'remoting/client/chromoting_client_runtime.h')
-rw-r--r--remoting/client/chromoting_client_runtime.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/remoting/client/chromoting_client_runtime.h b/remoting/client/chromoting_client_runtime.h
new file mode 100644
index 0000000..b9c45b6
--- /dev/null
+++ b/remoting/client/chromoting_client_runtime.h
@@ -0,0 +1,89 @@
+// 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.
+
+#ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_
+#define REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "remoting/base/auto_thread.h"
+
+namespace base {
+class MessageLoopForUI;
+} // namespace base
+
+// Houses the global resources on which the Chromoting components run
+// (e.g. message loops and task runners).
+namespace remoting {
+
+class ChromotingClientRuntime {
+ public:
+ // Caller to create is responsible for creating and attaching a new ui thread
+ // for use. Example:
+ //
+ // 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.
+ //
+ // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI();
+ // ui_loop_->Start();
+ // scoped_ptr<ChromotingClientRuntime> runtime =
+ // ChromotingClientRuntime::Create(ui_loop);
+ //
+ // On iOS we created a new message loop and now attach it.
+ //
+ // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI();
+ // ui_loop_->Attach();
+ // scoped_ptr<ChromotingClientRuntime> runtime =
+ // ChromotingClientRuntime::Create(ui_loop);
+ //
+ static scoped_ptr<ChromotingClientRuntime> Create(
+ base::MessageLoopForUI* ui_loop);
+
+ ~ChromotingClientRuntime();
+
+ scoped_refptr<AutoThreadTaskRunner> network_task_runner() {
+ return network_task_runner_;
+ }
+
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner() {
+ return ui_task_runner_;
+ }
+
+ scoped_refptr<AutoThreadTaskRunner> display_task_runner() {
+ return display_task_runner_;
+ }
+
+ scoped_refptr<AutoThreadTaskRunner> file_task_runner() {
+ return file_task_runner_;
+ }
+
+ scoped_refptr<net::URLRequestContextGetter> url_requester() {
+ return url_requester_;
+ }
+
+ private:
+ ChromotingClientRuntime();
+ ChromotingClientRuntime(
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> display_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> network_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> file_task_runner,
+ scoped_refptr<net::URLRequestContextGetter> url_requester);
+
+ // References to native threads.
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
+
+ scoped_refptr<AutoThreadTaskRunner> display_task_runner_;
+ scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
+ scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
+
+ scoped_refptr<net::URLRequestContextGetter> url_requester_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromotingClientRuntime);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_