OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 class URLRequestContextGetter; | 13 class URLRequestContextGetter; |
14 } // namespace net | 14 } // namespace net |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class AutoThreadTaskRunner; | 18 class AutoThreadTaskRunner; |
19 | 19 |
20 // A class that manages threads and running context for the chromoting host | 20 // A class that manages threads and running context for the chromoting host |
21 // process. This class is virtual only for testing purposes (see below). | 21 // process. This class is virtual only for testing purposes (see below). |
22 class ChromotingHostContext { | 22 class ChromotingHostContext { |
23 public: | 23 public: |
24 ~ChromotingHostContext(); | |
25 | |
26 // Create threads and URLRequestContextGetter for use by a host. | 24 // Create threads and URLRequestContextGetter for use by a host. |
27 // During shutdown the caller should tear-down the ChromotingHostContext and | 25 // During shutdown the caller should tear-down the ChromotingHostContext and |
28 // then continue to run until |ui_task_runner| is no longer referenced. | 26 // then continue to run until |ui_task_runner| is no longer referenced. |
29 // NULL is returned if any threads fail to start. | 27 // NULL is returned if any threads fail to start. |
30 static scoped_ptr<ChromotingHostContext> Create( | 28 static scoped_ptr<ChromotingHostContext> Create( |
31 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); | 29 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); |
32 | 30 |
31 #if defined(OS_CHROMEOS) | |
32 // Attaches task runners to the relevant browser threads for the chromoting | |
33 // host. Must be called on the UI thread of the browser process. | |
Wez
2014/10/24 23:29:27
Still need to document why |url_request_context_ge
kelvinp
2014/10/29 01:22:52
Done.
| |
34 static scoped_ptr<ChromotingHostContext> CreateForChromeOS( | |
35 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | |
36 #endif // defined(OS_CHROMEOS) | |
37 | |
38 ~ChromotingHostContext(); | |
39 | |
40 scoped_ptr<ChromotingHostContext> Copy(); | |
41 | |
42 // Task runner for the thread that is used for the UI. | |
43 scoped_refptr<AutoThreadTaskRunner> ui_task_runner(); | |
44 | |
33 // Task runner for the thread used for audio capture and encoding. | 45 // Task runner for the thread used for audio capture and encoding. |
34 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); | 46 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); |
35 | 47 |
36 // Task runner for the thread that is used for blocking file | 48 // Task runner for the thread that is used for blocking file |
37 // IO. This thread is used by the URLRequestContext to read proxy | 49 // IO. This thread is used by the URLRequestContext to read proxy |
38 // configuration and by NatConfig to read policy configs. | 50 // configuration and by NatConfig to read policy configs. |
39 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); | 51 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); |
40 | 52 |
41 // Task runner for the thread that is used by the InputInjector. | 53 // Task runner for the thread that is used by the InputInjector. |
42 // | 54 // |
43 // TODO(sergeyu): Do we need a separate thread for InputInjector? | 55 // TODO(sergeyu): Do we need a separate thread for InputInjector? |
44 // Can we use some other thread instead? | 56 // Can we use some other thread instead? |
45 scoped_refptr<AutoThreadTaskRunner> input_task_runner(); | 57 scoped_refptr<AutoThreadTaskRunner> input_task_runner(); |
46 | 58 |
47 // Task runner for the thread used for network IO. This thread runs | 59 // Task runner for the thread used for network IO. This thread runs |
48 // a libjingle message loop, and is the only thread on which | 60 // a libjingle message loop, and is the only thread on which |
49 // libjingle code may be run. | 61 // libjingle code may be run. |
50 scoped_refptr<AutoThreadTaskRunner> network_task_runner(); | 62 scoped_refptr<AutoThreadTaskRunner> network_task_runner(); |
51 | 63 |
52 // Task runner for the thread that is used for the UI. | |
53 scoped_refptr<AutoThreadTaskRunner> ui_task_runner(); | |
54 | |
55 // Task runner for the thread used by the ScreenRecorder to capture | 64 // Task runner for the thread used by the ScreenRecorder to capture |
56 // the screen. | 65 // the screen. |
57 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); | 66 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); |
58 | 67 |
59 // Task runner for the thread used to encode video streams. | 68 // Task runner for the thread used to encode video streams. |
60 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); | 69 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); |
61 | 70 |
62 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); | 71 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); |
63 | 72 |
64 private: | 73 private: |
65 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner); | 74 ChromotingHostContext( |
75 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, | |
76 scoped_refptr<AutoThreadTaskRunner> audio_task_runner, | |
77 scoped_refptr<AutoThreadTaskRunner> file_task_runner, | |
78 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | |
79 scoped_refptr<AutoThreadTaskRunner> network_task_runner, | |
80 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner, | |
81 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner, | |
82 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | |
83 | |
84 // Caller-supplied UI thread. This is usually the application main thread. | |
85 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | |
66 | 86 |
67 // Thread for audio capture and encoding. | 87 // Thread for audio capture and encoding. |
68 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; | 88 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; |
69 | 89 |
70 // Thread for I/O operations. | 90 // Thread for I/O operations. |
71 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; | 91 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; |
72 | 92 |
73 // Thread for input injection. | 93 // Thread for input injection. |
74 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; | 94 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; |
75 | 95 |
76 // Thread for network operations. | 96 // Thread for network operations. |
77 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; | 97 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
78 | 98 |
79 // Caller-supplied UI thread. This is usually the application main thread. | |
80 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | |
81 | |
82 // Thread for screen capture. | 99 // Thread for screen capture. |
83 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_; | 100 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_; |
84 | 101 |
85 // Thread for video encoding. | 102 // Thread for video encoding. |
86 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_; | 103 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_; |
87 | 104 |
88 // Serves URLRequestContexts that use the network and UI task runners. | 105 // Serves URLRequestContexts that use the network and UI task runners. |
89 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 106 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
90 | 107 |
91 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 108 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
92 }; | 109 }; |
93 | 110 |
94 } // namespace remoting | 111 } // namespace remoting |
95 | 112 |
96 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 113 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
OLD | NEW |