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

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

Issue 2933203002: [Chromoting] Use ProcessStatsSender in DesktopSessionAgent (desktop process) (Closed)
Patch Set: Resolve review comments Created 3 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
« no previous file with comments | « remoting/host/chromoting_param_traits.cc ('k') | remoting/host/desktop_session_agent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DESKTOP_SESSION_AGENT_H_ 5 #ifndef REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
6 #define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ 6 #define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/time/time.h"
19 #include "ipc/ipc_listener.h" 20 #include "ipc/ipc_listener.h"
20 #include "mojo/public/cpp/system/message_pipe.h" 21 #include "mojo/public/cpp/system/message_pipe.h"
21 #include "remoting/host/client_session_control.h" 22 #include "remoting/host/client_session_control.h"
23 #include "remoting/host/current_process_stats_agent.h"
22 #include "remoting/host/desktop_environment_options.h" 24 #include "remoting/host/desktop_environment_options.h"
23 #include "remoting/protocol/clipboard_stub.h" 25 #include "remoting/protocol/clipboard_stub.h"
26 #include "remoting/protocol/process_stats_stub.h"
24 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 27 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
25 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 28 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
26 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" 29 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
27 30
28 namespace IPC { 31 namespace IPC {
29 class ChannelProxy; 32 class ChannelProxy;
30 class Message; 33 class Message;
31 } // namespace IPC 34 } // namespace IPC
32 35
33 namespace remoting { 36 namespace remoting {
34 37
35 class AudioCapturer; 38 class AudioCapturer;
36 class AudioPacket; 39 class AudioPacket;
37 class AutoThreadTaskRunner; 40 class AutoThreadTaskRunner;
38 class DesktopEnvironment; 41 class DesktopEnvironment;
39 class DesktopEnvironmentFactory; 42 class DesktopEnvironmentFactory;
40 class InputInjector; 43 class InputInjector;
44 class ProcessStatsSender;
41 class RemoteInputFilter; 45 class RemoteInputFilter;
42 class ScreenControls; 46 class ScreenControls;
43 class ScreenResolution; 47 class ScreenResolution;
44 48
45 namespace protocol { 49 namespace protocol {
46 class InputEventTracker; 50 class InputEventTracker;
47 } // namespace protocol 51 } // namespace protocol
48 52
49 // Provides screen/audio capturing and input injection services for 53 // Provides screen/audio capturing and input injection services for
50 // the network process. 54 // the network process.
51 class DesktopSessionAgent 55 class DesktopSessionAgent
52 : public base::RefCountedThreadSafe<DesktopSessionAgent>, 56 : public base::RefCountedThreadSafe<DesktopSessionAgent>,
53 public IPC::Listener, 57 public IPC::Listener,
54 public webrtc::DesktopCapturer::Callback, 58 public webrtc::DesktopCapturer::Callback,
55 public webrtc::MouseCursorMonitor::Callback, 59 public webrtc::MouseCursorMonitor::Callback,
56 public ClientSessionControl { 60 public ClientSessionControl,
61 public protocol::ProcessStatsStub {
57 public: 62 public:
58 class Delegate { 63 class Delegate {
59 public: 64 public:
60 virtual ~Delegate(); 65 virtual ~Delegate();
61 66
62 // Returns an instance of desktop environment factory used. 67 // Returns an instance of desktop environment factory used.
63 virtual DesktopEnvironmentFactory& desktop_environment_factory() = 0; 68 virtual DesktopEnvironmentFactory& desktop_environment_factory() = 0;
64 69
65 // Notifies the delegate that the network-to-desktop channel has been 70 // Notifies the delegate that the network-to-desktop channel has been
66 // disconnected. 71 // disconnected.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 friend class base::RefCountedThreadSafe<DesktopSessionAgent>; 110 friend class base::RefCountedThreadSafe<DesktopSessionAgent>;
106 111
107 ~DesktopSessionAgent() override; 112 ~DesktopSessionAgent() override;
108 113
109 // ClientSessionControl interface. 114 // ClientSessionControl interface.
110 const std::string& client_jid() const override; 115 const std::string& client_jid() const override;
111 void DisconnectSession(protocol::ErrorCode error) override; 116 void DisconnectSession(protocol::ErrorCode error) override;
112 void OnLocalMouseMoved(const webrtc::DesktopVector& position) override; 117 void OnLocalMouseMoved(const webrtc::DesktopVector& position) override;
113 void SetDisableInputs(bool disable_inputs) override; 118 void SetDisableInputs(bool disable_inputs) override;
114 119
120 // ProcessStatsStub interface.
121 void OnProcessStats(
122 const protocol::AggregatedProcessResourceUsage& usage) override;
123
115 // Handles StartSessionAgent request from the client. 124 // Handles StartSessionAgent request from the client.
116 void OnStartSessionAgent(const std::string& authenticated_jid, 125 void OnStartSessionAgent(const std::string& authenticated_jid,
117 const ScreenResolution& resolution, 126 const ScreenResolution& resolution,
118 const DesktopEnvironmentOptions& options); 127 const DesktopEnvironmentOptions& options);
119 128
120 // Handles CaptureFrame requests from the client. 129 // Handles CaptureFrame requests from the client.
121 void OnCaptureFrame(); 130 void OnCaptureFrame();
122 131
123 // Handles event executor requests from the client. 132 // Handles event executor requests from the client.
124 void OnInjectClipboardEvent(const std::string& serialized_event); 133 void OnInjectClipboardEvent(const std::string& serialized_event);
125 void OnInjectKeyEvent(const std::string& serialized_event); 134 void OnInjectKeyEvent(const std::string& serialized_event);
126 void OnInjectTextEvent(const std::string& serialized_event); 135 void OnInjectTextEvent(const std::string& serialized_event);
127 void OnInjectMouseEvent(const std::string& serialized_event); 136 void OnInjectMouseEvent(const std::string& serialized_event);
128 void OnInjectTouchEvent(const std::string& serialized_event); 137 void OnInjectTouchEvent(const std::string& serialized_event);
129 138
130 // Handles ChromotingNetworkDesktopMsg_SetScreenResolution request from 139 // Handles ChromotingNetworkDesktopMsg_SetScreenResolution request from
131 // the client. 140 // the client.
132 void SetScreenResolution(const ScreenResolution& resolution); 141 void SetScreenResolution(const ScreenResolution& resolution);
133 142
134 // Sends a message to the network process. 143 // Sends a message to the network process.
135 void SendToNetwork(std::unique_ptr<IPC::Message> message); 144 void SendToNetwork(std::unique_ptr<IPC::Message> message);
136 145
137 // Posted to |audio_capture_task_runner_| to start the audio capturer. 146 // Posted to |audio_capture_task_runner_| to start the audio capturer.
138 void StartAudioCapturer(); 147 void StartAudioCapturer();
139 148
140 // Posted to |audio_capture_task_runner_| to stop the audio capturer. 149 // Posted to |audio_capture_task_runner_| to stop the audio capturer.
141 void StopAudioCapturer(); 150 void StopAudioCapturer();
142 151
152 // Starts to report process statistic data to network process. If
153 // |interval| is less than or equal to 0, a default non-zero value will be
154 // used.
155 void StartProcessStatsReport(base::TimeDelta interval);
156
157 // Stops sending process statistic data to network process.
158 void StopProcessStatsReport();
159
143 private: 160 private:
144 // Task runner dedicated to running methods of |audio_capturer_|. 161 // Task runner dedicated to running methods of |audio_capturer_|.
145 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner_; 162 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner_;
146 163
147 // Task runner on which public methods of this class should be called. 164 // Task runner on which public methods of this class should be called.
148 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; 165 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;
149 166
150 // Task runner on which keyboard/mouse input is injected. 167 // Task runner on which keyboard/mouse input is injected.
151 scoped_refptr<AutoThreadTaskRunner> input_task_runner_; 168 scoped_refptr<AutoThreadTaskRunner> input_task_runner_;
152 169
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Captures the screen. 201 // Captures the screen.
185 std::unique_ptr<webrtc::DesktopCapturer> video_capturer_; 202 std::unique_ptr<webrtc::DesktopCapturer> video_capturer_;
186 203
187 // Captures mouse shapes. 204 // Captures mouse shapes.
188 std::unique_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; 205 std::unique_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_;
189 206
190 // Keep reference to the last frame sent to make sure shared buffer is alive 207 // Keep reference to the last frame sent to make sure shared buffer is alive
191 // before it's received. 208 // before it's received.
192 std::unique_ptr<webrtc::DesktopFrame> last_frame_; 209 std::unique_ptr<webrtc::DesktopFrame> last_frame_;
193 210
211 // Reports process statistic data to network process.
212 std::unique_ptr<ProcessStatsSender> stats_sender_;
213
214 CurrentProcessStatsAgent current_process_stats_;
215
194 // Used to disable callbacks to |this|. 216 // Used to disable callbacks to |this|.
195 base::WeakPtrFactory<DesktopSessionAgent> weak_factory_; 217 base::WeakPtrFactory<DesktopSessionAgent> weak_factory_;
196 218
197 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); 219 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent);
198 }; 220 };
199 221
200 } // namespace remoting 222 } // namespace remoting
201 223
202 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ 224 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
OLDNEW
« no previous file with comments | « remoting/host/chromoting_param_traits.cc ('k') | remoting/host/desktop_session_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698