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 policy { | |
17 class PolicyService; | |
18 } // namespace policy | |
19 | |
16 namespace remoting { | 20 namespace remoting { |
17 | 21 |
18 class AutoThreadTaskRunner; | 22 class AutoThreadTaskRunner; |
19 | 23 |
20 // A class that manages threads and running context for the chromoting host | 24 // A class that manages threads and running context for the chromoting host |
21 // process. This class is virtual only for testing purposes (see below). | 25 // process. This class is virtual only for testing purposes (see below). |
22 class ChromotingHostContext { | 26 class ChromotingHostContext { |
23 public: | 27 public: |
24 ~ChromotingHostContext(); | 28 ~ChromotingHostContext(); |
25 | 29 |
26 // Create threads and URLRequestContextGetter for use by a host. | 30 // Create threads and URLRequestContextGetter for use by a host. |
27 // During shutdown the caller should tear-down the ChromotingHostContext and | 31 // During shutdown the caller should tear-down the ChromotingHostContext and |
28 // then continue to run until |ui_task_runner| is no longer referenced. | 32 // then continue to run until |ui_task_runner| is no longer referenced. |
29 // NULL is returned if any threads fail to start. | 33 // NULL is returned if any threads fail to start. |
30 static scoped_ptr<ChromotingHostContext> Create( | 34 static scoped_ptr<ChromotingHostContext> Create( |
31 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); | 35 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); |
32 | 36 |
37 // Must be called on the UI thread of the browser process. | |
38 static scoped_ptr<ChromotingHostContext> CreateForChromeOS( | |
39 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, | |
40 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | |
41 policy::PolicyService* policy_service); | |
Wez
2014/10/17 17:58:00
What are the lifetime/ownership properties of |pol
kelvinp
2014/10/20 00:21:17
Done.
| |
42 | |
33 // Task runner for the thread used for audio capture and encoding. | 43 // Task runner for the thread used for audio capture and encoding. |
34 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); | 44 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); |
35 | 45 |
36 // Task runner for the thread that is used for blocking file | 46 // Task runner for the thread that is used for blocking file |
37 // IO. This thread is used by the URLRequestContext to read proxy | 47 // IO. This thread is used by the URLRequestContext to read proxy |
38 // configuration and by NatConfig to read policy configs. | 48 // configuration and by NatConfig to read policy configs. |
39 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); | 49 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); |
40 | 50 |
41 // Task runner for the thread that is used by the InputInjector. | 51 // Task runner for the thread that is used by the InputInjector. |
42 // | 52 // |
(...skipping 11 matching lines...) Expand all Loading... | |
54 | 64 |
55 // Task runner for the thread used by the ScreenRecorder to capture | 65 // Task runner for the thread used by the ScreenRecorder to capture |
56 // the screen. | 66 // the screen. |
57 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); | 67 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); |
58 | 68 |
59 // Task runner for the thread used to encode video streams. | 69 // Task runner for the thread used to encode video streams. |
60 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); | 70 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); |
61 | 71 |
62 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); | 72 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); |
63 | 73 |
74 policy::PolicyService* policy_service(); | |
Wez
2014/10/17 17:58:00
Wouldn't it be cleaner to push the PolicyWatcher o
Wez
2014/10/17 17:58:00
Add a comment to clarify how this is used / why it
kelvinp
2014/10/20 00:21:17
Done.
kelvinp
2014/10/20 00:21:17
Done.
| |
75 | |
64 private: | 76 private: |
65 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner); | 77 ChromotingHostContext( |
78 AutoThreadTaskRunner* ui_task_runner, | |
79 AutoThreadTaskRunner* file_task_runner, | |
80 AutoThreadTaskRunner* input_task_runner, | |
81 AutoThreadTaskRunner* network_task_runner, | |
82 AutoThreadTaskRunner* video_capture_task_runner, | |
Wez
2014/10/17 17:58:00
Why are these bare pointers?
kelvinp
2014/10/20 00:21:17
Done.
| |
83 net::URLRequestContextGetter* url_request_context_getter, | |
84 policy::PolicyService* policy_service | |
85 ); | |
86 | |
87 // Verify that all threads have started. | |
88 bool VerifyInitialized(); | |
Wez
2014/10/17 17:58:00
Under what circumstances could the threads _not_ b
Wez
2014/10/17 17:58:00
AreThreadsStarted()?
kelvinp
2014/10/20 00:21:17
Done.
| |
89 | |
90 // Caller-supplied UI thread. This is usually the application main thread. | |
91 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | |
66 | 92 |
67 // Thread for audio capture and encoding. | 93 // Thread for audio capture and encoding. |
68 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; | 94 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; |
69 | 95 |
70 // Thread for I/O operations. | 96 // Thread for I/O operations. |
71 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; | 97 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; |
72 | 98 |
73 // Thread for input injection. | 99 // Thread for input injection. |
74 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; | 100 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; |
75 | 101 |
76 // Thread for network operations. | 102 // Thread for network operations. |
77 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; | 103 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
78 | 104 |
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. | 105 // Thread for screen capture. |
83 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_; | 106 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_; |
84 | 107 |
85 // Thread for video encoding. | 108 // Thread for video encoding. |
86 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_; | 109 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_; |
87 | 110 |
88 // Serves URLRequestContexts that use the network and UI task runners. | 111 // Serves URLRequestContexts that use the network and UI task runners. |
89 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 112 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
90 | 113 |
114 policy::PolicyService* policy_service_; | |
115 | |
91 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 116 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
92 }; | 117 }; |
93 | 118 |
94 } // namespace remoting | 119 } // namespace remoting |
95 | 120 |
96 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 121 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
OLD | NEW |