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

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

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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/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: 23 public:
24 ~ChromotingHostContext();
25
26 // Create threads and URLRequestContextGetter for use by a host. 24 // Create threads and URLRequestContextGetter for use by a host.
27 // During shutdown the caller should tear-down the ChromotingHostContext and 25 // During shutdown the caller should tear-down the ChromotingHostContext and
28 // then continue to run until |ui_task_runner| is no longer referenced. 26 // then continue to run until |ui_task_runner| is no longer referenced.
29 // NULL is returned if any threads fail to start. 27 // NULL is returned if any threads fail to start.
30 static scoped_ptr<ChromotingHostContext> Create( 28 static scoped_ptr<ChromotingHostContext> Create(
31 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); 29 scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
32 30
31 #if defined(OS_CHROMEOS)
32 // Attaches task runners to the relevant browser threads for the chromoting
33 // host. Must be called on the UI thread of the browser process.
34 // remoting::UrlRequestContextGetter returns BasicURLRequestContext under
35 // the hood which spawns two new threads per instance. Since
36 // ChromotingHostContext can be destroyed from any thread, as its owner
37 // (It2MeHost) is ref-counted, joining the created threads during shutdown
38 // violates the "Disallow IO" thread restrictions on some task runners (e.g.
39 // the IO Thread of the browser process).
40 // Instead, we re-use the |url_request_context_getter| in the browser process.
Wez 2014/10/29 18:27:51 If this is the only reason you need to re-use the
kelvinp 2014/10/29 22:20:17 Your suggestion involves changing the threading mo
Wez 2014/10/30 01:08:59 Acknowledged.
41 static scoped_ptr<ChromotingHostContext> CreateForChromeOS(
42 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
43 #endif // defined(OS_CHROMEOS)
44
45 ~ChromotingHostContext();
46
47 scoped_ptr<ChromotingHostContext> Copy();
48
49 // Task runner for the thread that is used for the UI.
50 scoped_refptr<AutoThreadTaskRunner> ui_task_runner();
51
33 // Task runner for the thread used for audio capture and encoding. 52 // Task runner for the thread used for audio capture and encoding.
34 scoped_refptr<AutoThreadTaskRunner> audio_task_runner(); 53 scoped_refptr<AutoThreadTaskRunner> audio_task_runner();
35 54
36 // Task runner for the thread that is used for blocking file 55 // Task runner for the thread that is used for blocking file
37 // IO. This thread is used by the URLRequestContext to read proxy 56 // IO. This thread is used by the URLRequestContext to read proxy
38 // configuration and by NatConfig to read policy configs. 57 // configuration and by NatConfig to read policy configs.
39 scoped_refptr<AutoThreadTaskRunner> file_task_runner(); 58 scoped_refptr<AutoThreadTaskRunner> file_task_runner();
40 59
41 // Task runner for the thread that is used by the InputInjector. 60 // Task runner for the thread that is used by the InputInjector.
42 // 61 //
43 // TODO(sergeyu): Do we need a separate thread for InputInjector? 62 // TODO(sergeyu): Do we need a separate thread for InputInjector?
44 // Can we use some other thread instead? 63 // Can we use some other thread instead?
45 scoped_refptr<AutoThreadTaskRunner> input_task_runner(); 64 scoped_refptr<AutoThreadTaskRunner> input_task_runner();
46 65
47 // Task runner for the thread used for network IO. This thread runs 66 // Task runner for the thread used for network IO. This thread runs
48 // a libjingle message loop, and is the only thread on which 67 // a libjingle message loop, and is the only thread on which
49 // libjingle code may be run. 68 // libjingle code may be run.
50 scoped_refptr<AutoThreadTaskRunner> network_task_runner(); 69 scoped_refptr<AutoThreadTaskRunner> network_task_runner();
51 70
52 // Task runner for the thread that is used for the UI.
53 scoped_refptr<AutoThreadTaskRunner> ui_task_runner();
54
55 // Task runner for the thread used by the ScreenRecorder to capture 71 // Task runner for the thread used by the ScreenRecorder to capture
56 // the screen. 72 // the screen.
57 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner(); 73 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner();
58 74
59 // Task runner for the thread used to encode video streams. 75 // Task runner for the thread used to encode video streams.
60 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner(); 76 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner();
61 77
62 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); 78 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter();
63 79
64 private: 80 private:
65 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner); 81 ChromotingHostContext(
82 scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
83 scoped_refptr<AutoThreadTaskRunner> audio_task_runner,
84 scoped_refptr<AutoThreadTaskRunner> file_task_runner,
85 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
86 scoped_refptr<AutoThreadTaskRunner> network_task_runner,
87 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner,
88 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner,
89 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
90
91 // Caller-supplied UI thread. This is usually the application main thread.
92 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
66 93
67 // Thread for audio capture and encoding. 94 // Thread for audio capture and encoding.
68 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_; 95 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_;
69 96
70 // Thread for I/O operations. 97 // Thread for I/O operations.
71 scoped_refptr<AutoThreadTaskRunner> file_task_runner_; 98 scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
72 99
73 // Thread for input injection. 100 // Thread for input injection.
74 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; 101 scoped_refptr<AutoThreadTaskRunner> input_task_runner_;
75 102
76 // Thread for network operations. 103 // Thread for network operations.
77 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; 104 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
78 105
79 // Caller-supplied UI thread. This is usually the application main thread.
80 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
81
82 // Thread for screen capture. 106 // Thread for screen capture.
83 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_; 107 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
84 108
85 // Thread for video encoding. 109 // Thread for video encoding.
86 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_; 110 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_;
87 111
88 // Serves URLRequestContexts that use the network and UI task runners. 112 // Serves URLRequestContexts that use the network and UI task runners.
89 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 113 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
90 114
91 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 115 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
92 }; 116 };
93 117
94 } // namespace remoting 118 } // namespace remoting
95 119
96 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 120 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698