Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: remoting/host/chromoting_host_context.h

Issue 11018004: Fix ChromotingHost and DesktopEnvironmentFactory references to TaskRunners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/threading/thread.h" 10 #include "base/threading/thread.h"
11 11
12 namespace base { 12 namespace base {
13 class SingleThreadTaskRunner; 13 class SingleThreadTaskRunner;
14 } // namespace base 14 } // namespace base
15 15
16 namespace net { 16 namespace net {
17 class URLRequestContextGetter; 17 class URLRequestContextGetter;
18 } // namespace net 18 } // namespace net
19 19
20 namespace remoting { 20 namespace remoting {
21
21 class AutoThreadTaskRunner; 22 class AutoThreadTaskRunner;
22 23
23 // A class that manages threads and running context for the chromoting host 24 // A class that manages threads and running context for the chromoting host
24 // process. This class is virtual only for testing purposes (see below). 25 // process. This class is virtual only for testing purposes (see below).
25 class ChromotingHostContext { 26 class ChromotingHostContext {
26 public: 27 public:
27 // Create a context. 28 // Create a context.
28 ChromotingHostContext( 29 ChromotingHostContext(
29 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); 30 scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
30 virtual ~ChromotingHostContext(); 31 virtual ~ChromotingHostContext();
31 32
32 void ReleaseTaskRunners(); 33 void ReleaseTaskRunners();
33 34
34 // TODO(ajwong): Move the Start method out of this class. Then 35 // TODO(ajwong): Move the Start method out of this class. Then
35 // create a static factory for construction, and destruction. We 36 // create a static factory for construction, and destruction. We
36 // should be able to remove the need for virtual functions below 37 // should be able to remove the need for virtual functions below
37 // with that design, while preserving the relative simplicity of 38 // with that design, while preserving the relative simplicity of
38 // this API. 39 // this API.
39 virtual bool Start(); 40 virtual bool Start();
40 41
41 // Task runner for the thread used for audio capture and encoding. 42 // Task runner for the thread used for audio capture and encoding.
42 virtual base::SingleThreadTaskRunner* audio_task_runner(); 43 virtual base::SingleThreadTaskRunner* audio_task_runner();
43 44
44 // Task runner for the thread used by the ScreenRecorder to capture 45 // Task runner for the thread used by the ScreenRecorder to capture
45 // the screen. 46 // the screen.
46 virtual base::SingleThreadTaskRunner* capture_task_runner(); 47 virtual base::SingleThreadTaskRunner* capture_task_runner();
47 48
48 // Task runner for the thread that is used by the EventExecutor.
49 //
50 // TODO(sergeyu): Do we need a separate thread for EventExecutor?
51 // Can we use some other thread instead?
52 virtual base::SingleThreadTaskRunner* desktop_task_runner();
53
54 // Task runner for the thread used to encode video streams. 49 // Task runner for the thread used to encode video streams.
55 virtual base::SingleThreadTaskRunner* encode_task_runner(); 50 virtual base::SingleThreadTaskRunner* encode_task_runner();
56 51
57 // Task runner for the thread that is used for blocking file 52 // Task runner for the thread that is used for blocking file
58 // IO. This thread is used by the URLRequestContext to read proxy 53 // IO. This thread is used by the URLRequestContext to read proxy
59 // configuration and by NatConfig to read policy configs. 54 // configuration and by NatConfig to read policy configs.
60 virtual base::SingleThreadTaskRunner* file_task_runner(); 55 virtual base::SingleThreadTaskRunner* file_task_runner();
61 56
57 // Task runner for the thread that is used by the EventExecutor.
58 //
59 // TODO(sergeyu): Do we need a separate thread for EventExecutor?
60 // Can we use some other thread instead?
61 virtual base::SingleThreadTaskRunner* input_task_runner();
alexeypa (please no reviews) 2012/10/01 18:31:34 nit: Make sure that this renaming is mentioned in
Wez 2012/10/02 05:19:44 Done.
62
62 // Task runner for the thread used for network IO. This thread runs 63 // Task runner for the thread used for network IO. This thread runs
63 // a libjingle message loop, and is the only thread on which 64 // a libjingle message loop, and is the only thread on which
64 // libjingle code may be run. 65 // libjingle code may be run.
65 virtual base::SingleThreadTaskRunner* network_task_runner(); 66 virtual base::SingleThreadTaskRunner* network_task_runner();
66 67
67 // Task runner for the thread that is used for the UI. In the NPAPI 68 // Task runner for the thread that is used for the UI. In the NPAPI
68 // plugin this corresponds to the main plugin thread. 69 // plugin this corresponds to the main plugin thread.
69 virtual base::SingleThreadTaskRunner* ui_task_runner(); 70 virtual base::SingleThreadTaskRunner* ui_task_runner();
70 71
71 const scoped_refptr<net::URLRequestContextGetter>& 72 const scoped_refptr<net::URLRequestContextGetter>&
72 url_request_context_getter(); 73 url_request_context_getter();
73 74
74 private: 75 private:
75 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); 76 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
76 77
77 // A thread that hosts audio capture and encoding. 78 // A thread that hosts audio capture and encoding.
78 base::Thread audio_thread_; 79 base::Thread audio_thread_;
79 80
80 // A thread that hosts screen capture. 81 // A thread that hosts screen capture.
81 base::Thread capture_thread_; 82 base::Thread capture_thread_;
82 83
83 // A thread that hosts input injection.
84 base::Thread desktop_thread_;
85
86 // A thread that hosts all encode operations. 84 // A thread that hosts all encode operations.
87 base::Thread encode_thread_; 85 base::Thread encode_thread_;
88 86
89 // Thread for blocking IO operations. 87 // Thread for blocking IO operations.
90 base::Thread file_thread_; 88 base::Thread file_thread_;
91 89
90 // A thread that hosts input injection.
91 base::Thread input_thread_;
92
92 // A thread that hosts all network operations. 93 // A thread that hosts all network operations.
93 base::Thread network_thread_; 94 base::Thread network_thread_;
94 95
95 // Task runners wrapping the above threads. These should be declared after 96 // Task runners wrapping the above threads. These should be declared after
96 // the corresponding threads to guarantee proper order of destruction. 97 // the corresponding threads to guarantee proper order of destruction.
97 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; 98 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
98 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; 99 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
99 scoped_refptr<base::SingleThreadTaskRunner> desktop_task_runner_;
100 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; 100 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
101 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 101 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
102 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
102 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 103 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
103 104
104 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 105 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
105 106
106 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 107 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
107 108
108 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 109 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
109 }; 110 };
110 111
111 } // namespace remoting 112 } // namespace remoting
112 113
113 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 114 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698