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

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

Issue 11231060: [Chromoting] The desktop process now creates a pre-connected pipe and passes (with some help of the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month 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
« no previous file with comments | « remoting/host/chromoting_messages.h ('k') | remoting/host/daemon_process.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_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/location.h" 12 #include "base/location.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/process.h"
15 #include "ipc/ipc_channel.h" 16 #include "ipc/ipc_channel.h"
16 #include "ipc/ipc_channel_proxy.h" 17 #include "ipc/ipc_channel_proxy.h"
18 #include "ipc/ipc_platform_file.h"
17 #include "remoting/base/stoppable.h" 19 #include "remoting/base/stoppable.h"
18 #include "remoting/host/config_file_watcher.h" 20 #include "remoting/host/config_file_watcher.h"
19 #include "remoting/host/worker_process_ipc_delegate.h" 21 #include "remoting/host/worker_process_ipc_delegate.h"
20 22
21 class FilePath; 23 class FilePath;
22 24
23 namespace base {
24 class SingleThreadTaskRunner;
25 } // namespace base
26
27 namespace remoting { 25 namespace remoting {
28 26
27 class AutoThreadTaskRunner;
29 class DesktopSession; 28 class DesktopSession;
30 29
31 // This class implements core of the daemon process. It manages the networking 30 // This class implements core of the daemon process. It manages the networking
32 // process running at lower privileges and maintains the list of desktop 31 // process running at lower privileges and maintains the list of desktop
33 // sessions. 32 // sessions.
34 class DaemonProcess 33 class DaemonProcess
35 : public Stoppable, 34 : public Stoppable,
36 public ConfigFileWatcher::Delegate, 35 public ConfigFileWatcher::Delegate,
37 public WorkerProcessIpcDelegate { 36 public WorkerProcessIpcDelegate {
38 public: 37 public:
39 typedef std::list<DesktopSession*> DesktopSessionList; 38 typedef std::list<DesktopSession*> DesktopSessionList;
40 39
41 virtual ~DaemonProcess(); 40 virtual ~DaemonProcess();
42 41
43 // Creates a platform-specific implementation of the daemon process object 42 // Creates a platform-specific implementation of the daemon process object
44 // passing relevant task runners. Public methods of this class must be called 43 // passing relevant task runners. Public methods of this class must be called
45 // on the |caller_task_runner| thread. |io_task_runner| is used to handle IPC 44 // on the |caller_task_runner| thread. |io_task_runner| is used to handle IPC
46 // and background I/O tasks. 45 // and background I/O tasks.
47 static scoped_ptr<DaemonProcess> Create( 46 static scoped_ptr<DaemonProcess> Create(
48 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 47 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
49 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 48 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
50 const base::Closure& stopped_callback); 49 const base::Closure& stopped_callback);
51 50
52 // ConfigFileWatcher::Delegate 51 // ConfigFileWatcher::Delegate
53 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE; 52 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE;
54 virtual void OnConfigWatcherError() OVERRIDE; 53 virtual void OnConfigWatcherError() OVERRIDE;
55 54
56 // WorkerProcessIpcDelegate implementation. 55 // WorkerProcessIpcDelegate implementation.
57 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 56 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
59 virtual void OnPermanentError() OVERRIDE; 58 virtual void OnPermanentError() OVERRIDE;
60 59
61 // Sends an IPC message to the network process. The message will be dropped 60 // Sends an IPC message to the network process. The message will be dropped
62 // unless the network process is connected over the IPC channel. 61 // unless the network process is connected over the IPC channel.
63 virtual void SendToNetwork(IPC::Message* message) = 0; 62 virtual void SendToNetwork(IPC::Message* message) = 0;
64 63
64 // Called when a desktop integration process attaches to |terminal_id|.
65 // |desktop_process| is a handle of the desktop integration process.
66 // |desktop_pipe| specifies the client end of the desktop pipe. Returns true
67 // on success, false otherwise.
68 virtual bool OnDesktopSessionAgentAttached(
69 int terminal_id,
70 base::ProcessHandle desktop_process,
71 IPC::PlatformFileForTransit desktop_pipe) = 0;
72
65 // Closes the desktop session identified by |terminal_id|. 73 // Closes the desktop session identified by |terminal_id|.
66 void CloseDesktopSession(int terminal_id); 74 void CloseDesktopSession(int terminal_id);
67 75
68 protected: 76 protected:
69 DaemonProcess(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 77 DaemonProcess(scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
70 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 78 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
71 const base::Closure& stopped_callback); 79 const base::Closure& stopped_callback);
72 80
73 // Creates a desktop session and assigns a unique ID to it. 81 // Creates a desktop session and assigns a unique ID to it.
74 void CreateDesktopSession(int terminal_id); 82 void CreateDesktopSession(int terminal_id);
75 83
76 // Requests the network process to crash. 84 // Requests the network process to crash.
77 void CrashNetworkProcess(const tracked_objects::Location& location); 85 void CrashNetworkProcess(const tracked_objects::Location& location);
78 86
79 // Reads the host configuration and launches the network process. 87 // Reads the host configuration and launches the network process.
80 void Initialize(); 88 void Initialize();
81 89
82 // Returns true if |terminal_id| is considered to be known. I.e. it is 90 // Returns true if |terminal_id| is considered to be known. I.e. it is
83 // less or equal to the highest ID we have seen so far. 91 // less or equal to the highest ID we have seen so far.
84 bool IsTerminalIdKnown(int terminal_id); 92 bool IsTerminalIdKnown(int terminal_id);
85 93
86 // Stoppable implementation. 94 // Stoppable implementation.
87 virtual void DoStop() OVERRIDE; 95 virtual void DoStop() OVERRIDE;
88 96
89 // Creates a platform-specific desktop session and assigns a unique ID to it. 97 // Creates a platform-specific desktop session and assigns a unique ID to it.
90 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession( 98 virtual scoped_ptr<DesktopSession> DoCreateDesktopSession(
91 int terminal_id) = 0; 99 int terminal_id) = 0;
92 100
93 // Launches the network process and establishes an IPC channel with it. 101 // Launches the network process and establishes an IPC channel with it.
94 virtual void LaunchNetworkProcess() = 0; 102 virtual void LaunchNetworkProcess() = 0;
95 103
96 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() { 104 scoped_refptr<AutoThreadTaskRunner> caller_task_runner() {
97 return caller_task_runner_; 105 return caller_task_runner_;
98 } 106 }
99 107
100 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner() { 108 scoped_refptr<AutoThreadTaskRunner> io_task_runner() {
101 return io_task_runner_; 109 return io_task_runner_;
102 } 110 }
103 111
104 // Let the test code analyze the list of desktop sessions. 112 // Let the test code analyze the list of desktop sessions.
105 friend class DaemonProcessTest; 113 friend class DaemonProcessTest;
106 const DesktopSessionList& desktop_sessions() const { 114 const DesktopSessionList& desktop_sessions() const {
107 return desktop_sessions_; 115 return desktop_sessions_;
108 } 116 }
109 117
110 private: 118 private:
111 // Deletes all desktop sessions. 119 // Deletes all desktop sessions.
112 void DeleteAllDesktopSessions(); 120 void DeleteAllDesktopSessions();
113 121
114 // Task runner on which public methods of this class must be called. 122 // Task runner on which public methods of this class must be called.
115 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 123 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;
116 124
117 // Handles IPC and background I/O tasks. 125 // Handles IPC and background I/O tasks.
118 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 126 scoped_refptr<AutoThreadTaskRunner> io_task_runner_;
119 127
120 scoped_ptr<ConfigFileWatcher> config_watcher_; 128 scoped_ptr<ConfigFileWatcher> config_watcher_;
121 129
122 // The configuration file contents. 130 // The configuration file contents.
123 std::string serialized_config_; 131 std::string serialized_config_;
124 132
125 // The list of active desktop sessions. 133 // The list of active desktop sessions.
126 DesktopSessionList desktop_sessions_; 134 DesktopSessionList desktop_sessions_;
127 135
128 // The highest desktop session ID that has been seen so far. 136 // The highest desktop session ID that has been seen so far.
129 int next_terminal_id_; 137 int next_terminal_id_;
130 138
131 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); 139 DISALLOW_COPY_AND_ASSIGN(DaemonProcess);
132 }; 140 };
133 141
134 } // namespace remoting 142 } // namespace remoting
135 143
136 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ 144 #endif // REMOTING_HOST_DAEMON_PROCESS_H_
OLDNEW
« no previous file with comments | « remoting/host/chromoting_messages.h ('k') | remoting/host/daemon_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698