| 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> | |
| 9 | |
| 10 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 12 #include "base/threading/platform_thread.h" | 10 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 14 | 12 |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace net { | 13 namespace net { |
| 20 class URLRequestContextGetter; | 14 class URLRequestContextGetter; |
| 21 } // namespace net | 15 } // namespace net |
| 22 | 16 |
| 23 namespace remoting { | 17 namespace remoting { |
| 18 class AutoThreadTaskRunner; |
| 24 | 19 |
| 25 // A class that manages threads and running context for the chromoting host | 20 // A class that manages threads and running context for the chromoting host |
| 26 // process. This class is virtual only for testing purposes (see below). | 21 // process. This class is virtual only for testing purposes (see below). |
| 27 class ChromotingHostContext { | 22 class ChromotingHostContext { |
| 28 public: | 23 public: |
| 29 // Create a context. | 24 // Create a context. |
| 30 ChromotingHostContext( | 25 ChromotingHostContext( |
| 31 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 26 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); |
| 32 virtual ~ChromotingHostContext(); | 27 virtual ~ChromotingHostContext(); |
| 33 | 28 |
| 34 // TODO(ajwong): Move the Start method out of this class. Then | 29 // TODO(ajwong): Move the Start method out of this class. Then |
| 35 // create a static factory for construction, and destruction. We | 30 // create a static factory for construction, and destruction. We |
| 36 // should be able to remove the need for virtual functions below | 31 // should be able to remove the need for virtual functions below |
| 37 // with that design, while preserving the relative simplicity of | 32 // with that design, while preserving the relative simplicity of |
| 38 // this API. | 33 // this API. |
| 39 virtual bool Start(); | 34 virtual bool Start(); |
| 40 | 35 |
| 36 void ReleaseTaskRunners(); |
| 37 |
| 41 // Task runner for the thread that is used for the UI. In the NPAPI | 38 // Task runner for the thread that is used for the UI. In the NPAPI |
| 42 // plugin this corresponds to the main plugin thread. | 39 // plugin this corresponds to the main plugin thread. |
| 43 virtual base::SingleThreadTaskRunner* ui_task_runner(); | 40 virtual base::SingleThreadTaskRunner* ui_task_runner(); |
| 44 | 41 |
| 45 // Task runner for the thread used by the ScreenRecorder to capture | 42 // Task runner for the thread used by the ScreenRecorder to capture |
| 46 // the screen. | 43 // the screen. |
| 47 virtual base::SingleThreadTaskRunner* capture_task_runner(); | 44 virtual base::SingleThreadTaskRunner* capture_task_runner(); |
| 48 | 45 |
| 49 // Task runner for the thread used to encode video streams. | 46 // Task runner for the thread used to encode video streams. |
| 50 virtual base::SingleThreadTaskRunner* encode_task_runner(); | 47 virtual base::SingleThreadTaskRunner* encode_task_runner(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 79 | 76 |
| 80 // A thread that hosts all encode operations. | 77 // A thread that hosts all encode operations. |
| 81 base::Thread encode_thread_; | 78 base::Thread encode_thread_; |
| 82 | 79 |
| 83 // A thread that hosts input injection. | 80 // A thread that hosts input injection. |
| 84 base::Thread desktop_thread_; | 81 base::Thread desktop_thread_; |
| 85 | 82 |
| 86 // Thread for blocking IO operations. | 83 // Thread for blocking IO operations. |
| 87 base::Thread file_thread_; | 84 base::Thread file_thread_; |
| 88 | 85 |
| 89 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 86 // Task runners wrapping the above threads. These should be declared after |
| 87 // the corresponding threads to guarantee proper order of destruction. |
| 88 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 89 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 90 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 91 scoped_refptr<base::SingleThreadTaskRunner> desktop_task_runner_; |
| 92 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 93 |
| 94 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
| 90 | 95 |
| 91 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 96 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 92 | 97 |
| 93 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 98 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
| 94 }; | 99 }; |
| 95 | 100 |
| 96 } // namespace remoting | 101 } // namespace remoting |
| 97 | 102 |
| 98 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 103 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| OLD | NEW |