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

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

Issue 2080723008: [Chromoting] Use device::PowerSaveBlocker to block screen saver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 5 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
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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 namespace base { 14 namespace base {
15 class SingleThreadTaskRunner; 15 class SingleThreadTaskRunner;
16 } // namespace base 16 } // namespace base
17 17
18 namespace net { 18 namespace net {
19 class URLRequestContextGetter; 19 class URLRequestContextGetter;
20 } // namespace net 20 } // namespace net
21 21
22 namespace remoting { 22 namespace remoting {
23 23
24 class AutoThreadTaskRunner; 24 class AutoThreadTaskRunner;
25 25
26 // 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
27 // process. This class is virtual only for testing purposes (see below). 27 // process. This class is virtual only for testing purposes (see below).
28 class ChromotingHostContext { 28 class ChromotingHostContext {
29 public: 29 public:
30 // Create threads and URLRequestContextGetter for use by a host. 30 // Creates threads and URLRequestContextGetter for use by a host.
31 // During shutdown the caller should tear-down the ChromotingHostContext and 31 // During shutdown the caller should tear-down the ChromotingHostContext and
32 // then continue to run until |ui_task_runner| is no longer referenced. 32 // then continue to run until |ui_task_runner| is no longer referenced.
33 // nullptr is returned if any threads fail to start. 33 // nullptr is returned if any threads fail to start.
34 static std::unique_ptr<ChromotingHostContext> Create( 34 static std::unique_ptr<ChromotingHostContext> Create(
35 scoped_refptr<AutoThreadTaskRunner> ui_task_runner); 35 scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
36 36
37 // Creates a ChromotingHostContext instance, which uses the input task runner
38 // for all jobs. This is for tests only.
39 static std::unique_ptr<ChromotingHostContext> CreateForTest(
40 scoped_refptr<AutoThreadTaskRunner> task_runner);
41
37 #if defined(OS_CHROMEOS) 42 #if defined(OS_CHROMEOS)
38 // Attaches task runners to the relevant browser threads for the chromoting 43 // Attaches task runners to the relevant browser threads for the chromoting
39 // host. Must be called on the UI thread of the browser process. 44 // host. Must be called on the UI thread of the browser process.
40 // remoting::UrlRequestContextGetter returns ContainerURLRequestContext under 45 // remoting::UrlRequestContextGetter returns ContainerURLRequestContext under
41 // the hood which spawns two new threads per instance. Since 46 // the hood which spawns two new threads per instance. Since
42 // ChromotingHostContext can be destroyed from any thread, as its owner 47 // ChromotingHostContext can be destroyed from any thread, as its owner
43 // (It2MeHost) is ref-counted, joining the created threads during shutdown 48 // (It2MeHost) is ref-counted, joining the created threads during shutdown
44 // violates the "Disallow IO" thread restrictions on some task runners (e.g. 49 // violates the "Disallow IO" thread restrictions on some task runners (e.g.
45 // the IO Thread of the browser process). 50 // the IO Thread of the browser process).
46 // Instead, we re-use the |url_request_context_getter| in the browser process. 51 // Instead, we re-use the |url_request_context_getter| in the browser process.
47 static std::unique_ptr<ChromotingHostContext> CreateForChromeOS( 52 static std::unique_ptr<ChromotingHostContext> CreateForChromeOS(
48 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, 53 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
49 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 54 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
50 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 55 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
51 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); 56 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
52 #endif // defined(OS_CHROMEOS) 57 #endif // defined(OS_CHROMEOS)
53 58
54 ~ChromotingHostContext(); 59 ~ChromotingHostContext();
55 60
56 std::unique_ptr<ChromotingHostContext> Copy(); 61 std::unique_ptr<ChromotingHostContext> Copy() const;
57 62
58 // Task runner for the thread that is used for the UI. 63 // Task runner for the thread that is used for the UI.
59 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() const; 64 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() const;
60 65
61 // Task runner for the thread used for audio capture and encoding. 66 // Task runner for the thread used for audio capture and encoding.
62 scoped_refptr<AutoThreadTaskRunner> audio_task_runner() const; 67 scoped_refptr<AutoThreadTaskRunner> audio_task_runner() const;
63 68
64 // Task runner for the thread that is used for blocking file 69 // Task runner for the thread that is used for blocking file
65 // IO. This thread is used by the URLRequestContext to read proxy 70 // IO. This thread is used by the URLRequestContext to read proxy
66 // configuration and by NatConfig to read policy configs. 71 // configuration and by NatConfig to read policy configs.
(...skipping 14 matching lines...) Expand all
81 // the screen. 86 // the screen.
82 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner() const; 87 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner() const;
83 88
84 // Task runner for the thread used to encode video streams. 89 // Task runner for the thread used to encode video streams.
85 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner() const; 90 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner() const;
86 91
87 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter() 92 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter()
88 const; 93 const;
89 94
90 private: 95 private:
96 // Creates a ChromotingHostContext instance. Returns nullptr if any of the
97 // input task runner is nullptr.
98 static std::unique_ptr<ChromotingHostContext> Create(
99 scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
100 scoped_refptr<AutoThreadTaskRunner> audio_task_runner,
101 scoped_refptr<AutoThreadTaskRunner> file_task_runner,
102 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
103 scoped_refptr<AutoThreadTaskRunner> network_task_runner,
104 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner,
105 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner);
106
91 ChromotingHostContext( 107 ChromotingHostContext(
92 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, 108 scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
93 scoped_refptr<AutoThreadTaskRunner> audio_task_runner, 109 scoped_refptr<AutoThreadTaskRunner> audio_task_runner,
94 scoped_refptr<AutoThreadTaskRunner> file_task_runner, 110 scoped_refptr<AutoThreadTaskRunner> file_task_runner,
95 scoped_refptr<AutoThreadTaskRunner> input_task_runner, 111 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
96 scoped_refptr<AutoThreadTaskRunner> network_task_runner, 112 scoped_refptr<AutoThreadTaskRunner> network_task_runner,
97 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner, 113 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner,
98 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner, 114 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner,
99 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); 115 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
100 116
(...skipping 20 matching lines...) Expand all
121 137
122 // Serves URLRequestContexts that use the network and UI task runners. 138 // Serves URLRequestContexts that use the network and UI task runners.
123 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 139 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
124 140
125 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 141 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
126 }; 142 };
127 143
128 } // namespace remoting 144 } // namespace remoting
129 145
130 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 146 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698