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

Unified Diff: remoting/host/daemon_process_win.cc

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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/daemon_process_unittest.cc ('k') | remoting/host/desktop_process.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/daemon_process_win.cc
diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc
index 5b0a57d4f79cfcdd3aa8ac5e3c9149866fdfd3e6..a5a4358eda467ffff583185eded3f308fed0536f 100644
--- a/remoting/host/daemon_process_win.cc
+++ b/remoting/host/daemon_process_win.cc
@@ -17,6 +17,7 @@
#include "base/win/scoped_handle.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
+#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/desktop_session_win.h"
#include "remoting/host/host_exit_codes.h"
@@ -36,14 +37,20 @@ class WtsConsoleMonitor;
class DaemonProcessWin : public DaemonProcess {
public:
DaemonProcessWin(
- scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback);
virtual ~DaemonProcessWin();
- // Sends an IPC message to the worker process. This method can be called only
- // after successful Start() and until Stop() is called or an error occurred.
+ // WorkerProcessIpcDelegate implementation.
+ virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
+
+ // DaemonProcess overrides.
virtual void SendToNetwork(IPC::Message* message) OVERRIDE;
+ virtual bool OnDesktopSessionAgentAttached(
+ int terminal_id,
+ base::ProcessHandle desktop_process,
+ IPC::PlatformFileForTransit desktop_pipe) OVERRIDE;
protected:
// Stoppable implementation.
@@ -57,12 +64,15 @@ class DaemonProcessWin : public DaemonProcess {
private:
scoped_ptr<WorkerProcessLauncher> network_launcher_;
+ // Handle of the network process.
+ ScopedHandle network_process_;
+
DISALLOW_COPY_AND_ASSIGN(DaemonProcessWin);
};
DaemonProcessWin::DaemonProcessWin(
- scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback)
: DaemonProcess(caller_task_runner, io_task_runner, stopped_callback) {
}
@@ -74,6 +84,17 @@ DaemonProcessWin::~DaemonProcessWin() {
CHECK_EQ(stoppable_state(), Stoppable::kStopped);
}
+void DaemonProcessWin::OnChannelConnected(int32 peer_pid) {
+ // Obtain the handle of the network process.
+ network_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid));
+ if (!network_process_.IsValid()) {
+ CrashNetworkProcess(FROM_HERE);
+ return;
+ }
+
+ DaemonProcess::OnChannelConnected(peer_pid);
+}
+
void DaemonProcessWin::SendToNetwork(IPC::Message* message) {
if (network_launcher_) {
network_launcher_->Send(message);
@@ -82,6 +103,25 @@ void DaemonProcessWin::SendToNetwork(IPC::Message* message) {
}
}
+bool DaemonProcessWin::OnDesktopSessionAgentAttached(
+ int terminal_id,
+ base::ProcessHandle desktop_process,
+ IPC::PlatformFileForTransit desktop_pipe) {
+ // Prepare |desktop_process| handle for sending over to the network process.
+ // |desktop_pipe| is a handle in the desktop process. It will be duplicated
+ // by the network process directly from the desktop process.
+ IPC::PlatformFileForTransit desktop_process_for_transit =
+ IPC::GetFileHandleForProcess(desktop_process, network_process_, false);
+ if (desktop_process_for_transit == IPC::InvalidPlatformFileForTransit()) {
+ LOG(ERROR) << "Failed to duplicate the desktop process handle";
+ return false;
+ }
+
+ SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached(
+ terminal_id, desktop_process_for_transit, desktop_pipe));
+ return true;
+}
+
void DaemonProcessWin::DoStop() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
@@ -117,8 +157,8 @@ void DaemonProcessWin::LaunchNetworkProcess() {
}
scoped_ptr<DaemonProcess> DaemonProcess::Create(
- scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback) {
scoped_ptr<DaemonProcessWin> daemon_process(
new DaemonProcessWin(caller_task_runner, io_task_runner,
« no previous file with comments | « remoting/host/daemon_process_unittest.cc ('k') | remoting/host/desktop_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698