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

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

Issue 16143004: Use a weak pointer to post service control events and session change notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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_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
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 void Stop();
Wez 2013/06/07 17:48:24 nit: Comment explaining Stop() semantics here, plz
alexeypa (please no reviews) 2013/06/07 18:30:23 Done.
109
110 // Returns true if |terminal_id| is in the range of allocated IDs. I.e. it is 110 // 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. 111 // less or equal to the highest ID we have seen so far.
112 bool WasTerminalIdAllocated(int terminal_id); 112 bool WasTerminalIdAllocated(int terminal_id);
113 113
114 // Handlers for the host status notifications received from the network 114 // Handlers for the host status notifications received from the network
115 // process. 115 // process.
116 void OnAccessDenied(const std::string& jid); 116 void OnAccessDenied(const std::string& jid);
117 void OnClientAuthenticated(const std::string& jid); 117 void OnClientAuthenticated(const std::string& jid);
118 void OnClientConnected(const std::string& jid); 118 void OnClientConnected(const std::string& jid);
119 void OnClientDisconnected(const std::string& jid); 119 void OnClientDisconnected(const std::string& jid);
120 void OnClientRouteChange(const std::string& jid, 120 void OnClientRouteChange(const std::string& jid,
121 const std::string& channel_name, 121 const std::string& channel_name,
122 const SerializedTransportRoute& route); 122 const SerializedTransportRoute& route);
123 void OnHostStarted(const std::string& xmpp_login); 123 void OnHostStarted(const std::string& xmpp_login);
124 void OnHostShutdown(); 124 void OnHostShutdown();
125 125
126 // Stoppable implementation.
127 virtual void DoStop() OVERRIDE;
128
129 // Creates a platform-specific desktop session and assigns a unique ID to it. 126 // 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. 127 // An implementation should validate |params| as they are received via IPC.
131 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( 128 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession(
132 int terminal_id, 129 int terminal_id,
133 const ScreenResolution& resolution, 130 const ScreenResolution& resolution,
134 bool virtual_terminal) = 0; 131 bool virtual_terminal) = 0;
135 132
136 // Requests the network process to crash. 133 // Requests the network process to crash.
137 virtual void DoCrashNetworkProcess( 134 virtual void DoCrashNetworkProcess(
138 const tracked_objects::Location& location) = 0; 135 const tracked_objects::Location& location) = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 168
172 // The list of active desktop sessions. 169 // The list of active desktop sessions.
173 DesktopSessionList desktop_sessions_; 170 DesktopSessionList desktop_sessions_;
174 171
175 // The highest desktop session ID that has been seen so far. 172 // The highest desktop session ID that has been seen so far.
176 int next_terminal_id_; 173 int next_terminal_id_;
177 174
178 // Keeps track of observers receiving host status notifications. 175 // Keeps track of observers receiving host status notifications.
179 ObserverList<HostStatusObserver> status_observers_; 176 ObserverList<HostStatusObserver> status_observers_;
180 177
178 // Invoked to ask the owner to delete |this|.
179 base::Closure stopped_callback_;
180
181 // Writes host status updates to the system event log. 181 // Writes host status updates to the system event log.
182 scoped_ptr<HostEventLogger> host_event_logger_; 182 scoped_ptr<HostEventLogger> host_event_logger_;
183 183
184 base::WeakPtrFactory<DaemonProcess> weak_factory_; 184 base::WeakPtrFactory<DaemonProcess> weak_factory_;
185 185
186 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); 186 DISALLOW_COPY_AND_ASSIGN(DaemonProcess);
187 }; 187 };
188 188
189 } // namespace remoting 189 } // namespace remoting
190 190
191 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ 191 #endif // REMOTING_HOST_DAEMON_PROCESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698