| 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 <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/process.h" | 16 #include "base/process.h" |
| 17 #include "ipc/ipc_channel.h" | 17 #include "ipc/ipc_channel.h" |
| 18 #include "ipc/ipc_channel_proxy.h" | 18 #include "ipc/ipc_channel_proxy.h" |
| 19 #include "ipc/ipc_platform_file.h" | 19 #include "ipc/ipc_platform_file.h" |
| 20 #include "remoting/base/stoppable.h" | |
| 21 #include "remoting/host/config_file_watcher.h" | 20 #include "remoting/host/config_file_watcher.h" |
| 22 #include "remoting/host/host_status_monitor.h" | 21 #include "remoting/host/host_status_monitor.h" |
| 23 #include "remoting/host/worker_process_ipc_delegate.h" | 22 #include "remoting/host/worker_process_ipc_delegate.h" |
| 24 | 23 |
| 25 struct SerializedTransportRoute; | 24 struct SerializedTransportRoute; |
| 26 | 25 |
| 27 namespace tracked_objects { | 26 namespace tracked_objects { |
| 28 class Location; | 27 class Location; |
| 29 } // namespace tracked_objects | 28 } // namespace tracked_objects |
| 30 | 29 |
| 31 namespace remoting { | 30 namespace remoting { |
| 32 | 31 |
| 33 class AutoThreadTaskRunner; | 32 class AutoThreadTaskRunner; |
| 34 class DesktopSession; | 33 class DesktopSession; |
| 35 class HostEventLogger; | 34 class HostEventLogger; |
| 36 class HostStatusObserver; | 35 class HostStatusObserver; |
| 37 class ScreenResolution; | 36 class ScreenResolution; |
| 38 | 37 |
| 39 // This class implements core of the daemon process. It manages the networking | 38 // This class implements core of the daemon process. It manages the networking |
| 40 // process running at lower privileges and maintains the list of desktop | 39 // process running at lower privileges and maintains the list of desktop |
| 41 // sessions. | 40 // sessions. |
| 42 class DaemonProcess | 41 class DaemonProcess |
| 43 : public Stoppable, | 42 : public ConfigFileWatcher::Delegate, |
| 44 public ConfigFileWatcher::Delegate, | |
| 45 public HostStatusMonitor, | 43 public HostStatusMonitor, |
| 46 public WorkerProcessIpcDelegate { | 44 public WorkerProcessIpcDelegate { |
| 47 public: | 45 public: |
| 48 typedef std::list<DesktopSession*> DesktopSessionList; | 46 typedef std::list<DesktopSession*> DesktopSessionList; |
| 49 | 47 |
| 50 virtual ~DaemonProcess(); | 48 virtual ~DaemonProcess(); |
| 51 | 49 |
| 52 // Creates a platform-specific implementation of the daemon process object | 50 // Creates a platform-specific implementation of the daemon process object |
| 53 // passing relevant task runners. Public methods of this class must be called | 51 // 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 | 52 // on the |caller_task_runner| thread. |io_task_runner| is used to handle IPC |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Changes the screen resolution of the desktop session identified by | 98 // Changes the screen resolution of the desktop session identified by |
| 101 // |terminal_id|. | 99 // |terminal_id|. |
| 102 void SetScreenResolution(int terminal_id, const ScreenResolution& resolution); | 100 void SetScreenResolution(int terminal_id, const ScreenResolution& resolution); |
| 103 | 101 |
| 104 // Requests the network process to crash. | 102 // Requests the network process to crash. |
| 105 void CrashNetworkProcess(const tracked_objects::Location& location); | 103 void CrashNetworkProcess(const tracked_objects::Location& location); |
| 106 | 104 |
| 107 // Reads the host configuration and launches the network process. | 105 // Reads the host configuration and launches the network process. |
| 108 void Initialize(); | 106 void Initialize(); |
| 109 | 107 |
| 108 // Invokes |stopped_callback_| to ask the owner to delete |this|. |
| 109 void Stop(); |
| 110 |
| 110 // Returns true if |terminal_id| is in the range of allocated IDs. I.e. it is | 111 // Returns true if |terminal_id| is in the range of allocated IDs. I.e. it is |
| 111 // less or equal to the highest ID we have seen so far. | 112 // less or equal to the highest ID we have seen so far. |
| 112 bool WasTerminalIdAllocated(int terminal_id); | 113 bool WasTerminalIdAllocated(int terminal_id); |
| 113 | 114 |
| 114 // Handlers for the host status notifications received from the network | 115 // Handlers for the host status notifications received from the network |
| 115 // process. | 116 // process. |
| 116 void OnAccessDenied(const std::string& jid); | 117 void OnAccessDenied(const std::string& jid); |
| 117 void OnClientAuthenticated(const std::string& jid); | 118 void OnClientAuthenticated(const std::string& jid); |
| 118 void OnClientConnected(const std::string& jid); | 119 void OnClientConnected(const std::string& jid); |
| 119 void OnClientDisconnected(const std::string& jid); | 120 void OnClientDisconnected(const std::string& jid); |
| 120 void OnClientRouteChange(const std::string& jid, | 121 void OnClientRouteChange(const std::string& jid, |
| 121 const std::string& channel_name, | 122 const std::string& channel_name, |
| 122 const SerializedTransportRoute& route); | 123 const SerializedTransportRoute& route); |
| 123 void OnHostStarted(const std::string& xmpp_login); | 124 void OnHostStarted(const std::string& xmpp_login); |
| 124 void OnHostShutdown(); | 125 void OnHostShutdown(); |
| 125 | 126 |
| 126 // Stoppable implementation. | |
| 127 virtual void DoStop() OVERRIDE; | |
| 128 | |
| 129 // Creates a platform-specific desktop session and assigns a unique ID to it. | 127 // Creates a platform-specific desktop session and assigns a unique ID to it. |
| 130 // An implementation should validate |params| as they are received via IPC. | 128 // An implementation should validate |params| as they are received via IPC. |
| 131 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( | 129 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( |
| 132 int terminal_id, | 130 int terminal_id, |
| 133 const ScreenResolution& resolution, | 131 const ScreenResolution& resolution, |
| 134 bool virtual_terminal) = 0; | 132 bool virtual_terminal) = 0; |
| 135 | 133 |
| 136 // Requests the network process to crash. | 134 // Requests the network process to crash. |
| 137 virtual void DoCrashNetworkProcess( | 135 virtual void DoCrashNetworkProcess( |
| 138 const tracked_objects::Location& location) = 0; | 136 const tracked_objects::Location& location) = 0; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 169 |
| 172 // The list of active desktop sessions. | 170 // The list of active desktop sessions. |
| 173 DesktopSessionList desktop_sessions_; | 171 DesktopSessionList desktop_sessions_; |
| 174 | 172 |
| 175 // The highest desktop session ID that has been seen so far. | 173 // The highest desktop session ID that has been seen so far. |
| 176 int next_terminal_id_; | 174 int next_terminal_id_; |
| 177 | 175 |
| 178 // Keeps track of observers receiving host status notifications. | 176 // Keeps track of observers receiving host status notifications. |
| 179 ObserverList<HostStatusObserver> status_observers_; | 177 ObserverList<HostStatusObserver> status_observers_; |
| 180 | 178 |
| 179 // Invoked to ask the owner to delete |this|. |
| 180 base::Closure stopped_callback_; |
| 181 |
| 181 // Writes host status updates to the system event log. | 182 // Writes host status updates to the system event log. |
| 182 scoped_ptr<HostEventLogger> host_event_logger_; | 183 scoped_ptr<HostEventLogger> host_event_logger_; |
| 183 | 184 |
| 184 base::WeakPtrFactory<DaemonProcess> weak_factory_; | 185 base::WeakPtrFactory<DaemonProcess> weak_factory_; |
| 185 | 186 |
| 186 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); | 187 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); |
| 187 }; | 188 }; |
| 188 | 189 |
| 189 } // namespace remoting | 190 } // namespace remoting |
| 190 | 191 |
| 191 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ | 192 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ |
| OLD | NEW |