| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "remoting/jingle_glue/jingle_thread.h" | 12 #include "remoting/jingle_glue/jingle_thread.h" |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 // A class that manages threads and running context for the chromoting host | 16 // A class that manages threads and running context for the chromoting host |
| 17 // process. | 17 // process. |
| 18 class ChromotingHostContext { | 18 class ChromotingHostContext { |
| 19 public: | 19 public: |
| 20 ChromotingHostContext(); | 20 // Create a context attached to the specified ui message loop. Since there |
| 21 // can only be one such loop on UNIX platforms, it has to be passed into |
| 22 // this object rather than being owned by it. |
| 23 explicit ChromotingHostContext(MessageLoop* ui_message_loop); |
| 21 virtual ~ChromotingHostContext(); | 24 virtual ~ChromotingHostContext(); |
| 22 | 25 |
| 23 // TODO(ajwong): Move the Start/Stop methods out of this class. Then | 26 // TODO(ajwong): Move the Start/Stop methods out of this class. Then |
| 24 // create a static factory for construction, and destruction. We | 27 // create a static factory for construction, and destruction. We |
| 25 // should be able to remove the need for virtual functions below with that | 28 // should be able to remove the need for virtual functions below with that |
| 26 // design, while preserving the relative simplicity of this API. | 29 // design, while preserving the relative simplicity of this API. |
| 27 virtual void Start(); | 30 virtual void Start(); |
| 28 virtual void Stop(); | 31 virtual void Stop(); |
| 29 | 32 |
| 30 virtual JingleThread* jingle_thread(); | 33 virtual JingleThread* jingle_thread(); |
| 31 | 34 |
| 32 virtual MessageLoop* main_message_loop(); | 35 virtual MessageLoop* main_message_loop(); |
| 33 virtual MessageLoop* encode_message_loop(); | 36 virtual MessageLoop* encode_message_loop(); |
| 34 virtual MessageLoop* network_message_loop(); | 37 virtual MessageLoop* network_message_loop(); |
| 38 MessageLoop* ui_message_loop(); |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); | 41 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); |
| 38 | 42 |
| 39 // A thread that hosts all network operations. | 43 // A thread that hosts all network operations. |
| 40 JingleThread jingle_thread_; | 44 JingleThread jingle_thread_; |
| 41 | 45 |
| 42 // A thread that hosts ChromotingHost and performs rate control. | 46 // A thread that hosts ChromotingHost and performs rate control. |
| 43 base::Thread main_thread_; | 47 base::Thread main_thread_; |
| 44 | 48 |
| 45 // A thread that hosts all encode operations. | 49 // A thread that hosts all encode operations. |
| 46 base::Thread encode_thread_; | 50 base::Thread encode_thread_; |
| 47 | 51 |
| 52 // The main message loop. |
| 53 MessageLoop* ui_message_loop_; |
| 54 |
| 48 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 55 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 } // namespace remoting | 58 } // namespace remoting |
| 52 | 59 |
| 53 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingHostContext); | 60 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingHostContext); |
| 54 | 61 |
| 55 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 62 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| OLD | NEW |