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

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

Powered by Google App Engine
This is Rietveld 408576698