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 explicit ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); | 22 ChromotingHostContext(base::MessageLoopProxy* io_message_loop, |
| 23 base::MessageLoopProxy* ui_message_loop); |
23 virtual ~ChromotingHostContext(); | 24 virtual ~ChromotingHostContext(); |
24 | 25 |
25 // TODO(ajwong): Move the Start method out of this class. Then | 26 // TODO(ajwong): Move the Start method out of this class. Then |
26 // create a static factory for construction, and destruction. We | 27 // create a static factory for construction, and destruction. We |
27 // should be able to remove the need for virtual functions below | 28 // should be able to remove the need for virtual functions below |
28 // with that design, while preserving the relative simplicity of | 29 // with that design, while preserving the relative simplicity of |
29 // this API. | 30 // this API. |
30 virtual bool Start(); | 31 virtual bool Start(); |
31 | 32 |
32 virtual JingleThread* jingle_thread(); | 33 virtual JingleThread* jingle_thread(); |
33 | 34 |
| 35 virtual base::MessageLoopProxy* io_message_loop(); |
34 virtual base::MessageLoopProxy* ui_message_loop(); | 36 virtual base::MessageLoopProxy* ui_message_loop(); |
35 virtual MessageLoop* main_message_loop(); | 37 virtual MessageLoop* main_message_loop(); |
36 virtual MessageLoop* encode_message_loop(); | 38 virtual MessageLoop* encode_message_loop(); |
37 virtual base::MessageLoopProxy* network_message_loop(); | 39 virtual base::MessageLoopProxy* network_message_loop(); |
38 virtual MessageLoop* desktop_message_loop(); | 40 virtual MessageLoop* desktop_message_loop(); |
39 | 41 |
40 private: | 42 private: |
41 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); | 43 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); |
42 | 44 |
43 // A thread that hosts all network operations. | 45 // A thread that hosts all network operations. |
44 JingleThread jingle_thread_; | 46 JingleThread jingle_thread_; |
45 | 47 |
46 // A thread that hosts ChromotingHost and performs rate control. | 48 // A thread that hosts ChromotingHost and performs rate control. |
47 base::Thread main_thread_; | 49 base::Thread main_thread_; |
48 | 50 |
49 // A thread that hosts all encode operations. | 51 // A thread that hosts all encode operations. |
50 base::Thread encode_thread_; | 52 base::Thread encode_thread_; |
51 | 53 |
52 // A thread that hosts desktop integration (capture, input injection, etc) | 54 // A thread that hosts desktop integration (capture, input injection, etc) |
53 // This is NOT a Chrome-style UI thread. | 55 // This is NOT a Chrome-style UI thread. |
54 base::Thread desktop_thread_; | 56 base::Thread desktop_thread_; |
55 | 57 |
| 58 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
56 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; | 59 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 61 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace remoting | 64 } // namespace remoting |
62 | 65 |
63 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 66 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
OLD | NEW |