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