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

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

Issue 10829467: [Chromoting] Introducing refcount-based life time management of the message loops in the service (d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 3 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 <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
29 void ReleaseTaskRunners();
30
34 // TODO(ajwong): Move the Start method out of this class. Then 31 // TODO(ajwong): Move the Start method out of this class. Then
35 // create a static factory for construction, and destruction. We 32 // create a static factory for construction, and destruction. We
36 // should be able to remove the need for virtual functions below 33 // should be able to remove the need for virtual functions below
37 // with that design, while preserving the relative simplicity of 34 // with that design, while preserving the relative simplicity of
38 // this API. 35 // this API.
39 virtual bool Start(); 36 virtual bool Start();
40 37
41 // Task runner for the thread that is used for the UI. In the NPAPI 38 // Task runner for the thread used for audio capture and encoding.
42 // plugin this corresponds to the main plugin thread. 39 virtual base::SingleThreadTaskRunner* audio_task_runner();
43 virtual base::SingleThreadTaskRunner* ui_task_runner();
44 40
45 // Task runner for the thread used by the ScreenRecorder to capture 41 // Task runner for the thread used by the ScreenRecorder to capture
46 // the screen. 42 // the screen.
47 virtual base::SingleThreadTaskRunner* capture_task_runner(); 43 virtual base::SingleThreadTaskRunner* capture_task_runner();
48 44
49 // Task runner for the thread used to encode video streams.
50 virtual base::SingleThreadTaskRunner* encode_task_runner();
51
52 // Task runner for the thread used for audio capture and encoding.
53 virtual base::SingleThreadTaskRunner* audio_task_runner();
54
55 // Task runner for the thread used for network IO. This thread runs
56 // a libjingle message loop, and is the only thread on which
57 // libjingle code may be run.
58 virtual base::SingleThreadTaskRunner* network_task_runner();
59
60 // Task runner for the thread that is used by the EventExecutor. 45 // Task runner for the thread that is used by the EventExecutor.
61 // 46 //
62 // TODO(sergeyu): Do we need a separate thread for EventExecutor? 47 // TODO(sergeyu): Do we need a separate thread for EventExecutor?
63 // Can we use some other thread instead? 48 // Can we use some other thread instead?
64 virtual base::SingleThreadTaskRunner* desktop_task_runner(); 49 virtual base::SingleThreadTaskRunner* desktop_task_runner();
65 50
51 // Task runner for the thread used to encode video streams.
52 virtual base::SingleThreadTaskRunner* encode_task_runner();
53
66 // Task runner for the thread that is used for blocking file 54 // Task runner for the thread that is used for blocking file
67 // IO. This thread is used by the URLRequestContext to read proxy 55 // IO. This thread is used by the URLRequestContext to read proxy
68 // configuration and by NatConfig to read policy configs. 56 // configuration and by NatConfig to read policy configs.
69 virtual base::SingleThreadTaskRunner* file_task_runner(); 57 virtual base::SingleThreadTaskRunner* file_task_runner();
70 58
59 // Task runner for the thread used for network IO. This thread runs
60 // a libjingle message loop, and is the only thread on which
61 // libjingle code may be run.
62 virtual base::SingleThreadTaskRunner* network_task_runner();
63
64 // Task runner for the thread that is used for the UI. In the NPAPI
65 // plugin this corresponds to the main plugin thread.
66 virtual base::SingleThreadTaskRunner* ui_task_runner();
67
71 const scoped_refptr<net::URLRequestContextGetter>& 68 const scoped_refptr<net::URLRequestContextGetter>&
72 url_request_context_getter(); 69 url_request_context_getter();
73 70
74 private: 71 private:
75 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); 72 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
76 73
77 // A thread that hosts all network operations. 74 // A thread that hosts audio capture and encoding.
78 base::Thread network_thread_; 75 base::Thread audio_thread_;
79 76
80 // A thread that hosts screen capture. 77 // A thread that hosts screen capture.
81 base::Thread capture_thread_; 78 base::Thread capture_thread_;
82 79
80 // A thread that hosts input injection.
81 base::Thread desktop_thread_;
82
83 // A thread that hosts all encode operations. 83 // A thread that hosts all encode operations.
84 base::Thread encode_thread_; 84 base::Thread encode_thread_;
85 85
86 // A thread that hosts audio capture and encoding.
87 base::Thread audio_thread_;
88
89 // A thread that hosts input injection.
90 base::Thread desktop_thread_;
91
92 // Thread for blocking IO operations. 86 // Thread for blocking IO operations.
93 base::Thread file_thread_; 87 base::Thread file_thread_;
94 88
95 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 89 // A thread that hosts all network operations.
90 base::Thread network_thread_;
91
92 // Task runners wrapping the above threads. These should be declared after
93 // the corresponding threads to guarantee proper order of destruction.
94 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
95 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
96 scoped_refptr<base::SingleThreadTaskRunner> desktop_task_runner_;
97 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
98 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
99 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
100
101 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
96 102
97 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 103 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
98 104
99 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 105 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
100 }; 106 };
101 107
102 } // namespace remoting 108 } // namespace remoting
103 109
104 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 110 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW
« no previous file with comments | « remoting/base/auto_thread_task_runner_unittest.cc ('k') | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698