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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/ref_counted.h" | |
11 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
13 #include "remoting/jingle_glue/jingle_thread.h" | 14 #include "remoting/jingle_glue/jingle_thread.h" |
14 | 15 |
16 namespace base { | |
17 class SingleThreadTaskRunner; | |
18 } // namespace base | |
19 | |
15 namespace net { | 20 namespace net { |
16 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
17 } // namespace net | 22 } // namespace net |
18 | 23 |
19 namespace remoting { | 24 namespace remoting { |
20 | 25 |
21 // A class that manages threads and running context for the chromoting host | 26 // A class that manages threads and running context for the chromoting host |
22 // process. This class is virtual only for testing purposes (see below). | 27 // process. This class is virtual only for testing purposes (see below). |
23 class ChromotingHostContext { | 28 class ChromotingHostContext { |
24 public: | 29 public: |
25 // Create a context. | 30 // Create a context. |
26 ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); | 31 ChromotingHostContext( |
32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | |
27 virtual ~ChromotingHostContext(); | 33 virtual ~ChromotingHostContext(); |
28 | 34 |
29 // TODO(ajwong): Move the Start method out of this class. Then | 35 // TODO(ajwong): Move the Start method out of this class. Then |
30 // create a static factory for construction, and destruction. We | 36 // create a static factory for construction, and destruction. We |
31 // should be able to remove the need for virtual functions below | 37 // should be able to remove the need for virtual functions below |
32 // with that design, while preserving the relative simplicity of | 38 // with that design, while preserving the relative simplicity of |
33 // this API. | 39 // this API. |
34 virtual bool Start(); | 40 virtual bool Start(); |
35 | 41 |
36 virtual JingleThread* jingle_thread(); | 42 virtual JingleThread* jingle_thread(); |
37 | 43 |
38 virtual MessageLoop* main_message_loop(); | 44 // Task runned for the thread that is used for UI. In the NPAPI |
Wez
2012/06/19 18:30:21
typo: runned -> runner
typo: UI -> the UI
Sergey Ulanov
2012/06/19 19:01:41
Done.
| |
39 virtual MessageLoop* encode_message_loop(); | 45 // plugin this corresponds to the main plugin thread. |
40 virtual base::MessageLoopProxy* network_message_loop(); | 46 virtual base::SingleThreadTaskRunner* ui_task_runner(); |
41 virtual MessageLoop* desktop_message_loop(); | 47 |
42 virtual base::MessageLoopProxy* ui_message_loop(); | 48 // Task runner for the thread used by the ScreenRecorder to capture |
43 virtual base::MessageLoopProxy* io_message_loop(); | 49 // the screen. |
44 virtual base::MessageLoopProxy* file_message_loop(); | 50 virtual base::SingleThreadTaskRunner* capture_task_runner(); |
51 | |
52 // Task runner for the thread used to encode video streams. | |
53 virtual base::SingleThreadTaskRunner* encode_task_runner(); | |
54 | |
55 // Network thread is the thread use for most networking IO. It runs | |
56 // libjingle's message loop, so libjingle code should be used only | |
57 // on this thread. | |
Wez
2012/06/19 18:30:21
nit: Reword this to the same style as the others e
Sergey Ulanov
2012/06/19 19:01:41
Done.
| |
58 virtual base::SingleThreadTaskRunner* network_task_runner(); | |
59 | |
60 // Task runner for the thread that is used by the EventExecutor. | |
61 // | |
62 // TODO(sergeyu): Do we need a separate thread for EventExecutor? | |
63 // Can we use some other thread instead? | |
64 virtual base::SingleThreadTaskRunner* desktop_task_runner(); | |
65 | |
66 // Task runner for the thread that is used for network IO. Note that | |
67 // most of network IO for remoting happens on a different thread, | |
68 // the one that corresponds to network_task_runner(). This is | |
69 // because libjingle code needs to work on a thread that runs | |
70 // libjingle's message loop. | |
Wez
2012/06/19 18:30:21
This is confusing; what networking do we run on io
Sergey Ulanov
2012/06/19 19:01:41
All HTTP requests, specifically for oauth and rela
| |
71 // | |
72 // TODO(sergeyu): Implement socket server for libjingle that works | |
73 // on a regular chromium thread and use it for network_task_runner() | |
74 // to avoid the need for io_task_runner(). | |
75 virtual base::SingleThreadTaskRunner* io_task_runner(); | |
76 | |
77 // Task runner for the thread that is used for file IO. | |
Wez
2012/06/19 18:30:21
nit: Why do we keep this separate from the IO thre
Sergey Ulanov
2012/06/19 19:01:41
changed "file IO" to "blocking file IO".
| |
78 virtual base::SingleThreadTaskRunner* file_task_runner(); | |
79 | |
45 const scoped_refptr<net::URLRequestContextGetter>& | 80 const scoped_refptr<net::URLRequestContextGetter>& |
46 url_request_context_getter(); | 81 url_request_context_getter(); |
47 | 82 |
48 private: | 83 private: |
49 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); | 84 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); |
50 | 85 |
51 // A thread that hosts all network operations. | 86 // A thread that hosts all network operations. |
52 JingleThread jingle_thread_; | 87 JingleThread jingle_thread_; |
53 | 88 |
54 // TODO(sergeyu): The "main" thread is used just by the | 89 // A thread that hosts screen capture. |
55 // capturer. Consider renaming it. | 90 base::Thread capture_thread_; |
56 base::Thread main_thread_; | |
57 | 91 |
58 // A thread that hosts all encode operations. | 92 // A thread that hosts all encode operations. |
59 base::Thread encode_thread_; | 93 base::Thread encode_thread_; |
60 | 94 |
61 // A thread that hosts desktop integration (capture, input injection, etc) | 95 // A thread that hosts input injection. |
62 // This is NOT a Chrome-style UI thread. | |
63 base::Thread desktop_thread_; | 96 base::Thread desktop_thread_; |
64 | 97 |
65 // Thread for non-blocking IO operations. | 98 // Thread for non-blocking IO operations. |
66 base::Thread io_thread_; | 99 base::Thread io_thread_; |
67 | 100 |
68 // Thread for blocking IO operations. | 101 // Thread for blocking IO operations. |
69 base::Thread file_thread_; | 102 base::Thread file_thread_; |
70 | 103 |
71 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; | 104 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
72 | 105 |
73 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 106 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
74 | 107 |
75 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 108 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
76 }; | 109 }; |
77 | 110 |
78 } // namespace remoting | 111 } // namespace remoting |
79 | 112 |
80 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 113 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
OLD | NEW |