| 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 "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 class URLRequestContextGetter; | 13 class URLRequestContextGetter; |
| 14 } // namespace net | 14 } // namespace net |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 class AutoThreadTaskRunner; | 18 class AutoThreadTaskRunner; |
| 19 | 19 |
| 20 // 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 |
| 21 // process. This class is virtual only for testing purposes (see below). | 21 // process. This class is virtual only for testing purposes (see below). |
| 22 class ChromotingHostContext { | 22 class ChromotingHostContext |
| 23 : public base::RefCountedThreadSafe<ChromotingHostContext> { |
| 23 public: | 24 public: |
| 24 ~ChromotingHostContext(); | 25 // Creates threads and URLRequestContextGetter for use by a host. |
| 25 | |
| 26 // Create threads and URLRequestContextGetter for use by a host. | |
| 27 // During shutdown the caller should tear-down the ChromotingHostContext and | 26 // During shutdown the caller should tear-down the ChromotingHostContext and |
| 28 // then continue to run until |ui_task_runner| is no longer referenced. | 27 // then continue to run until |ui_task_runner| is no longer referenced. |
| 29 // NULL is returned if any threads fail to start. | 28 // NULL is returned if any threads fail to start. |
| 30 static scoped_ptr<ChromotingHostContext> Create( | 29 static scoped_refptr<ChromotingHostContext> Create( |
| 31 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); | 30 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); |
| 32 | 31 |
| 33 // Task runner for the thread used for audio capture and encoding. | 32 // Task runner for the thread used for audio capture and encoding. |
| 34 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); | 33 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); |
| 35 | 34 |
| 36 // Task runner for the thread that is used for blocking file | 35 // Task runner for the thread that is used for blocking file |
| 37 // IO. This thread is used by the URLRequestContext to read proxy | 36 // IO. This thread is used by the URLRequestContext to read proxy |
| 38 // configuration and by NatConfig to read policy configs. | 37 // configuration and by NatConfig to read policy configs. |
| 39 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); | 38 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); |
| 40 | 39 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 | 53 |
| 55 // Task runner for the thread used by the ScreenRecorder to capture | 54 // Task runner for the thread used by the ScreenRecorder to capture |
| 56 // the screen. | 55 // the screen. |
| 57 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); | 56 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); |
| 58 | 57 |
| 59 // Task runner for the thread used to encode video streams. | 58 // Task runner for the thread used to encode video streams. |
| 60 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); | 59 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); |
| 61 | 60 |
| 62 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); | 61 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); |
| 63 | 62 |
| 64 private: | 63 protected: |
| 64 friend class base::RefCountedThreadSafe<ChromotingHostContext>; |
| 65 virtual ~ChromotingHostContext(); |
| 66 |
| 65 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner); | 67 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner); |
| 66 | 68 |
| 67 // Thread for audio capture and encoding. | 69 // Thread for audio capture and encoding. |
| 68 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; | 70 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; |
| 69 | 71 |
| 70 // Thread for I/O operations. | 72 // Thread for I/O operations. |
| 71 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; | 73 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; |
| 72 | 74 |
| 73 // Thread for input injection. | 75 // Thread for input injection. |
| 74 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; | 76 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 | 89 |
| 88 // Serves URLRequestContexts that use the network and UI task runners. | 90 // Serves URLRequestContexts that use the network and UI task runners. |
| 89 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 91 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 90 | 92 |
| 91 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); | 93 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 } // namespace remoting | 96 } // namespace remoting |
| 95 | 97 |
| 96 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ | 98 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ |
| OLD | NEW |