| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_ |
| 6 #define REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/url_request/url_request_context_getter.h" |
| 11 #include "remoting/base/auto_thread.h" |
| 12 |
| 13 namespace base { |
| 14 class MessageLoopForUI; |
| 15 } // namespace base |
| 16 |
| 17 // Houses the global resources on which the Chromoting components run |
| 18 // (e.g. message loops and task runners). |
| 19 namespace remoting { |
| 20 |
| 21 class ChromotingClientRuntime { |
| 22 public: |
| 23 // Caller to create is responsible for creating and attaching a new ui thread |
| 24 // for use. Example: |
| 25 // |
| 26 // On Android, the UI thread is managed by Java, so we need to attach and |
| 27 // start a special type of message loop to allow Chromium code to run tasks. |
| 28 // |
| 29 // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI(); |
| 30 // ui_loop_->Start(); |
| 31 // scoped_ptr<ChromotingClientRuntime> runtime = |
| 32 // ChromotingClientRuntime::Create(ui_loop); |
| 33 // |
| 34 // On iOS we created a new message loop and now attach it. |
| 35 // |
| 36 // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI(); |
| 37 // ui_loop_->Attach(); |
| 38 // scoped_ptr<ChromotingClientRuntime> runtime = |
| 39 // ChromotingClientRuntime::Create(ui_loop); |
| 40 // |
| 41 static scoped_ptr<ChromotingClientRuntime> Create( |
| 42 base::MessageLoopForUI* ui_loop); |
| 43 |
| 44 ~ChromotingClientRuntime(); |
| 45 |
| 46 scoped_refptr<AutoThreadTaskRunner> network_task_runner() { |
| 47 return network_task_runner_; |
| 48 } |
| 49 |
| 50 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { |
| 51 return ui_task_runner_; |
| 52 } |
| 53 |
| 54 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
| 55 return display_task_runner_; |
| 56 } |
| 57 |
| 58 scoped_refptr<AutoThreadTaskRunner> file_task_runner() { |
| 59 return file_task_runner_; |
| 60 } |
| 61 |
| 62 scoped_refptr<net::URLRequestContextGetter> url_requester() { |
| 63 return url_requester_; |
| 64 } |
| 65 |
| 66 private: |
| 67 ChromotingClientRuntime(); |
| 68 ChromotingClientRuntime( |
| 69 scoped_refptr<AutoThreadTaskRunner> display_task_runner, |
| 70 scoped_refptr<AutoThreadTaskRunner> network_task_runner, |
| 71 scoped_refptr<AutoThreadTaskRunner> file_task_runner, |
| 72 scoped_refptr<net::URLRequestContextGetter> url_requester); |
| 73 |
| 74 // References to native threads. |
| 75 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
| 76 |
| 77 scoped_refptr<AutoThreadTaskRunner> display_task_runner_; |
| 78 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
| 79 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; |
| 80 |
| 81 scoped_refptr<net::URLRequestContextGetter> url_requester_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(ChromotingClientRuntime); |
| 84 }; |
| 85 |
| 86 } // namespace remoting |
| 87 |
| 88 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_ |
| OLD | NEW |