Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_DAEMON_PROCESS_H_ | 5 #ifndef REMOTING_HOST_DAEMON_PROCESS_H_ |
| 6 #define REMOTING_HOST_DAEMON_PROCESS_H_ | 6 #define REMOTING_HOST_DAEMON_PROCESS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/time/time.h" | |
| 20 #include "ipc/ipc_channel.h" | 21 #include "ipc/ipc_channel.h" |
| 21 #include "ipc/ipc_channel_handle.h" | 22 #include "ipc/ipc_channel_handle.h" |
| 22 #include "remoting/host/config_watcher.h" | 23 #include "remoting/host/config_watcher.h" |
| 24 #include "remoting/host/current_process_stats_agent.h" | |
| 23 #include "remoting/host/host_status_monitor.h" | 25 #include "remoting/host/host_status_monitor.h" |
| 24 #include "remoting/host/worker_process_ipc_delegate.h" | 26 #include "remoting/host/worker_process_ipc_delegate.h" |
| 27 #include "remoting/protocol/process_stats_stub.h" | |
| 25 | 28 |
| 26 struct SerializedTransportRoute; | 29 struct SerializedTransportRoute; |
| 27 | 30 |
| 28 namespace tracked_objects { | 31 namespace tracked_objects { |
| 29 class Location; | 32 class Location; |
| 30 } // namespace tracked_objects | 33 } // namespace tracked_objects |
| 31 | 34 |
| 32 namespace remoting { | 35 namespace remoting { |
| 33 | 36 |
| 34 class AutoThreadTaskRunner; | 37 class AutoThreadTaskRunner; |
| 35 class DesktopSession; | 38 class DesktopSession; |
| 36 class HostEventLogger; | 39 class HostEventLogger; |
| 37 class HostStatusObserver; | 40 class HostStatusObserver; |
| 41 class ProcessStatsSender; | |
| 38 class ScreenResolution; | 42 class ScreenResolution; |
| 39 | 43 |
| 40 // This class implements core of the daemon process. It manages the networking | 44 // This class implements core of the daemon process. It manages the networking |
| 41 // process running at lower privileges and maintains the list of desktop | 45 // process running at lower privileges and maintains the list of desktop |
| 42 // sessions. | 46 // sessions. |
| 43 class DaemonProcess | 47 class DaemonProcess |
| 44 : public ConfigWatcher::Delegate, | 48 : public ConfigWatcher::Delegate, |
| 45 public HostStatusMonitor, | 49 public HostStatusMonitor, |
| 46 public WorkerProcessIpcDelegate { | 50 public WorkerProcessIpcDelegate, |
| 51 public protocol::ProcessStatsStub { | |
| 47 public: | 52 public: |
| 48 typedef std::list<DesktopSession*> DesktopSessionList; | 53 typedef std::list<DesktopSession*> DesktopSessionList; |
| 49 | 54 |
| 50 ~DaemonProcess() override; | 55 ~DaemonProcess() override; |
| 51 | 56 |
| 52 // Creates a platform-specific implementation of the daemon process object | 57 // Creates a platform-specific implementation of the daemon process object |
| 53 // passing relevant task runners. Public methods of this class must be called | 58 // passing relevant task runners. Public methods of this class must be called |
| 54 // on the |caller_task_runner| thread. |io_task_runner| is used to handle IPC | 59 // on the |caller_task_runner| thread. |io_task_runner| is used to handle IPC |
| 55 // and background I/O tasks. | 60 // and background I/O tasks. |
| 56 static std::unique_ptr<DaemonProcess> Create( | 61 static std::unique_ptr<DaemonProcess> Create( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 // Let the test code analyze the list of desktop sessions. | 156 // Let the test code analyze the list of desktop sessions. |
| 152 friend class DaemonProcessTest; | 157 friend class DaemonProcessTest; |
| 153 const DesktopSessionList& desktop_sessions() const { | 158 const DesktopSessionList& desktop_sessions() const { |
| 154 return desktop_sessions_; | 159 return desktop_sessions_; |
| 155 } | 160 } |
| 156 | 161 |
| 157 private: | 162 private: |
| 158 // Deletes all desktop sessions. | 163 // Deletes all desktop sessions. |
| 159 void DeleteAllDesktopSessions(); | 164 void DeleteAllDesktopSessions(); |
| 160 | 165 |
| 166 // Starts to report process statistic data to network process. If |interval| | |
| 167 // is less then or equal to 0, a default non-zero value will be used. | |
| 168 void StartProcessStatsReport(base::TimeDelta interval); | |
| 169 | |
| 170 // Stops sending process statistic data to network process. | |
| 171 void StopProcessStatsReport(); | |
| 172 | |
| 173 // ProcessStatsStub implementation. | |
| 174 void OnProcessStats( | |
| 175 const protocol::AggregatedProcessResourceUsage& usage) override; | |
| 176 | |
| 161 // Task runner on which public methods of this class must be called. | 177 // Task runner on which public methods of this class must be called. |
| 162 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; | 178 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; |
| 163 | 179 |
| 164 // Handles IPC and background I/O tasks. | 180 // Handles IPC and background I/O tasks. |
| 165 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; | 181 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
| 166 | 182 |
| 167 std::unique_ptr<ConfigWatcher> config_watcher_; | 183 std::unique_ptr<ConfigWatcher> config_watcher_; |
| 168 | 184 |
| 169 // The configuration file contents. | 185 // The configuration file contents. |
| 170 std::string serialized_config_; | 186 std::string serialized_config_; |
| 171 | 187 |
| 172 // The list of active desktop sessions. | 188 // The list of active desktop sessions. |
| 173 DesktopSessionList desktop_sessions_; | 189 DesktopSessionList desktop_sessions_; |
| 174 | 190 |
| 175 // The highest desktop session ID that has been seen so far. | 191 // The highest desktop session ID that has been seen so far. |
| 176 int next_terminal_id_; | 192 int next_terminal_id_; |
| 177 | 193 |
| 178 // Keeps track of observers receiving host status notifications. | 194 // Keeps track of observers receiving host status notifications. |
| 179 base::ObserverList<HostStatusObserver> status_observers_; | 195 base::ObserverList<HostStatusObserver> status_observers_; |
| 180 | 196 |
| 181 // Invoked to ask the owner to delete |this|. | 197 // Invoked to ask the owner to delete |this|. |
| 182 base::Closure stopped_callback_; | 198 base::Closure stopped_callback_; |
| 183 | 199 |
| 184 // Writes host status updates to the system event log. | 200 // Writes host status updates to the system event log. |
| 185 std::unique_ptr<HostEventLogger> host_event_logger_; | 201 std::unique_ptr<HostEventLogger> host_event_logger_; |
| 186 | 202 |
| 203 // Reports process statistic data to network process. | |
| 204 std::unique_ptr<ProcessStatsSender> stats_sender_; | |
| 205 | |
| 206 // The number of StartProcessStatsReport requests received. | |
| 207 // Daemon and Network processes manages multiple desktop sessions. Some of | |
|
joedow
2017/06/21 15:30:50
Process stats data is tied to a specific ClientSes
joedow
2017/06/21 15:32:04
Oops., the top line should say:
Process stats data
Hzj_jie
2017/06/21 21:42:56
After some more detailed investigations, I believe
joedow
2017/06/21 22:00:19
My concerns are:
1.) The ref count code isn't goin
| |
| 208 // them may request for process statistic reports. So the resource usage of | |
| 209 // daemon process and network process will be merged to each desktop session. | |
| 210 // | |
| 211 // As long as at least process statistic reports is enabled for one desktop | |
| 212 // session, daemon process should continually send the reports. | |
| 213 int process_stats_request_count_ = 0; | |
| 214 | |
| 215 CurrentProcessStatsAgent current_process_stats_; | |
| 216 | |
| 187 base::WeakPtrFactory<DaemonProcess> weak_factory_; | 217 base::WeakPtrFactory<DaemonProcess> weak_factory_; |
| 188 | 218 |
| 189 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); | 219 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); |
| 190 }; | 220 }; |
| 191 | 221 |
| 192 } // namespace remoting | 222 } // namespace remoting |
| 193 | 223 |
| 194 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ | 224 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ |
| OLD | NEW |