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/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "remoting/jingle_glue/jingle_thread.h" | 13 #include "remoting/jingle_glue/jingle_thread.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 | 16 |
17 // A class that manages threads and running context for the chromoting host | 17 // A class that manages threads and running context for the chromoting host |
18 // process. This class is virtual only for testing purposes (see below). | 18 // process. This class is virtual only for testing purposes (see below). |
19 class ChromotingHostContext { | 19 class ChromotingHostContext { |
20 public: | 20 public: |
21 // Create a context. | 21 // Create a context. |
22 ChromotingHostContext(base::MessageLoopProxy* io_message_loop, | 22 ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); |
23 base::MessageLoopProxy* ui_message_loop); | |
24 virtual ~ChromotingHostContext(); | 23 virtual ~ChromotingHostContext(); |
25 | 24 |
26 // TODO(ajwong): Move the Start method out of this class. Then | 25 // TODO(ajwong): Move the Start method out of this class. Then |
27 // create a static factory for construction, and destruction. We | 26 // create a static factory for construction, and destruction. We |
28 // should be able to remove the need for virtual functions below | 27 // should be able to remove the need for virtual functions below |
29 // with that design, while preserving the relative simplicity of | 28 // with that design, while preserving the relative simplicity of |
30 // this API. | 29 // this API. |
31 virtual bool Start(); | 30 virtual bool Start(); |
32 | 31 |
33 virtual JingleThread* jingle_thread(); | 32 virtual JingleThread* jingle_thread(); |
34 | 33 |
35 virtual base::MessageLoopProxy* io_message_loop(); | 34 |
36 virtual base::MessageLoopProxy* ui_message_loop(); | |
37 virtual MessageLoop* main_message_loop(); | 35 virtual MessageLoop* main_message_loop(); |
38 virtual MessageLoop* encode_message_loop(); | 36 virtual MessageLoop* encode_message_loop(); |
39 virtual base::MessageLoopProxy* network_message_loop(); | 37 virtual base::MessageLoopProxy* network_message_loop(); |
40 virtual MessageLoop* desktop_message_loop(); | 38 virtual MessageLoop* desktop_message_loop(); |
| 39 virtual base::MessageLoopProxy* ui_message_loop(); |
| 40 virtual MessageLoop* file_message_loop(); |
41 | 41 |
42 private: | 42 private: |
43 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); | 43 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); |
44 | 44 |
45 // A thread that hosts all network operations. | 45 // A thread that hosts all network operations. |
46 JingleThread jingle_thread_; | 46 JingleThread jingle_thread_; |
47 | 47 |
48 // A thread that hosts ChromotingHost and performs rate control. | 48 // TODO(sergeyu): The "main" thread is used just by the |
| 49 // capturer. Consider renaming it. |
49 base::Thread main_thread_; | 50 base::Thread main_thread_; |
50 | 51 |
51 // A thread that hosts all encode operations. | 52 // A thread that hosts all encode operations. |
52 base::Thread encode_thread_; | 53 base::Thread encode_thread_; |
53 | 54 |
54 // A thread that hosts desktop integration (capture, input injection, etc) | 55 // A thread that hosts desktop integration (capture, input injection, etc) |
55 // This is NOT a Chrome-style UI thread. | 56 // This is NOT a Chrome-style UI thread. |
56 base::Thread desktop_thread_; | 57 base::Thread desktop_thread_; |
57 | 58 |
58 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 59 // Thread for blocking IO operations. |
| 60 base::Thread file_thread_; |
| 61 |
59 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; | 62 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 64 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
62 }; | 65 }; |
63 | 66 |
64 } // namespace remoting | 67 } // namespace remoting |
65 | 68 |
66 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 69 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
OLD | NEW |