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

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

Issue 10572005: Use SingleThreadTaskRunner instead of MessageLoopProxy in remoting/host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h"
11 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "remoting/jingle_glue/jingle_thread.h" 14 #include "remoting/jingle_glue/jingle_thread.h"
14 15
16 namespace base {
17 class SingleThreadTaskRunner;
18 } // namespace base
19
15 namespace net { 20 namespace net {
16 class URLRequestContextGetter; 21 class URLRequestContextGetter;
17 } // namespace net 22 } // namespace net
18 23
19 namespace remoting { 24 namespace remoting {
20 25
21 // A class that manages threads and running context for the chromoting host 26 // A class that manages threads and running context for the chromoting host
22 // process. This class is virtual only for testing purposes (see below). 27 // process. This class is virtual only for testing purposes (see below).
23 class ChromotingHostContext { 28 class ChromotingHostContext {
24 public: 29 public:
25 // Create a context. 30 // Create a context.
26 ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); 31 ChromotingHostContext(
32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
27 virtual ~ChromotingHostContext(); 33 virtual ~ChromotingHostContext();
28 34
29 // TODO(ajwong): Move the Start method out of this class. Then 35 // TODO(ajwong): Move the Start method out of this class. Then
30 // create a static factory for construction, and destruction. We 36 // create a static factory for construction, and destruction. We
31 // should be able to remove the need for virtual functions below 37 // should be able to remove the need for virtual functions below
32 // with that design, while preserving the relative simplicity of 38 // with that design, while preserving the relative simplicity of
33 // this API. 39 // this API.
34 virtual bool Start(); 40 virtual bool Start();
35 41
36 virtual JingleThread* jingle_thread(); 42 virtual JingleThread* jingle_thread();
37 43
38 virtual MessageLoop* main_message_loop(); 44 virtual base::SingleThreadTaskRunner* main_task_runner();
39 virtual MessageLoop* encode_message_loop(); 45
40 virtual base::MessageLoopProxy* network_message_loop(); 46 // The task runner for the thread used to encode video streams.
41 virtual MessageLoop* desktop_message_loop(); 47 virtual base::SingleThreadTaskRunner* encode_task_runner();
42 virtual base::MessageLoopProxy* ui_message_loop(); 48
43 virtual base::MessageLoopProxy* io_message_loop(); 49 // Network thread is the thread use for most networking IO. It runs
44 virtual base::MessageLoopProxy* file_message_loop(); 50 // libjingle's message loop, so libjingle code should be used only
51 // on this thread.
52 virtual base::SingleThreadTaskRunner* network_task_runner();
53
54 virtual base::SingleThreadTaskRunner* desktop_task_runner();
55 virtual base::SingleThreadTaskRunner* ui_task_runner();
56 virtual base::SingleThreadTaskRunner* io_task_runner();
57 virtual base::SingleThreadTaskRunner* file_task_runner();
Wez 2012/06/19 03:47:08 You've added comments to clarify some of the TaskR
Sergey Ulanov 2012/06/19 18:16:09 Oh, sorry. I actually had these comments added alr
45 const scoped_refptr<net::URLRequestContextGetter>& 58 const scoped_refptr<net::URLRequestContextGetter>&
46 url_request_context_getter(); 59 url_request_context_getter();
47 60
48 private: 61 private:
49 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); 62 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
50 63
51 // A thread that hosts all network operations. 64 // A thread that hosts all network operations.
52 JingleThread jingle_thread_; 65 JingleThread jingle_thread_;
53 66
54 // TODO(sergeyu): The "main" thread is used just by the 67 // TODO(sergeyu): The "main" thread is used just by the
55 // capturer. Consider renaming it. 68 // capturer. Consider renaming it.
56 base::Thread main_thread_; 69 base::Thread main_thread_;
57 70
58 // A thread that hosts all encode operations. 71 // A thread that hosts all encode operations.
59 base::Thread encode_thread_; 72 base::Thread encode_thread_;
60 73
61 // A thread that hosts desktop integration (capture, input injection, etc) 74 // A thread that hosts desktop integration (capture, input injection, etc)
62 // This is NOT a Chrome-style UI thread. 75 // This is NOT a Chrome-style UI thread.
63 base::Thread desktop_thread_; 76 base::Thread desktop_thread_;
64 77
65 // Thread for non-blocking IO operations. 78 // Thread for non-blocking IO operations.
66 base::Thread io_thread_; 79 base::Thread io_thread_;
67 80
68 // Thread for blocking IO operations. 81 // Thread for blocking IO operations.
69 base::Thread file_thread_; 82 base::Thread file_thread_;
70 83
71 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; 84 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
72 85
73 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 86 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
74 87
75 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 88 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
76 }; 89 };
77 90
78 } // namespace remoting 91 } // namespace remoting
79 92
80 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 93 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698