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

Side by Side Diff: remoting/host/daemon_process_win.cc

Issue 12096071: Adding a unit test to verify the IPC channel between the network and desktop processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 7 years, 10 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 #include "remoting/host/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/process.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/timer.h" 16 #include "base/timer.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "base/win/scoped_handle.h" 18 #include "base/win/scoped_handle.h"
18 #include "ipc/ipc_message.h" 19 #include "ipc/ipc_message.h"
19 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_macros.h"
20 #include "remoting/base/auto_thread_task_runner.h" 21 #include "remoting/base/auto_thread_task_runner.h"
21 #include "remoting/host/chromoting_messages.h" 22 #include "remoting/host/chromoting_messages.h"
22 #include "remoting/host/desktop_session_win.h" 23 #include "remoting/host/desktop_session_win.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } else { 102 } else {
102 delete message; 103 delete message;
103 } 104 }
104 } 105 }
105 106
106 bool DaemonProcessWin::OnDesktopSessionAgentAttached( 107 bool DaemonProcessWin::OnDesktopSessionAgentAttached(
107 int terminal_id, 108 int terminal_id,
108 base::ProcessHandle desktop_process, 109 base::ProcessHandle desktop_process,
109 IPC::PlatformFileForTransit desktop_pipe) { 110 IPC::PlatformFileForTransit desktop_pipe) {
110 // Prepare |desktop_process| handle for sending over to the network process. 111 // Prepare |desktop_process| handle for sending over to the network process.
111 // |desktop_pipe| is a handle in the desktop process. It will be duplicated 112 base::ProcessHandle desktop_process_for_transit;
112 // by the network process directly from the desktop process. 113 if (!DuplicateHandle(GetCurrentProcess(),
113 IPC::PlatformFileForTransit desktop_process_for_transit = 114 desktop_process,
114 IPC::GetFileHandleForProcess(desktop_process, network_process_, false); 115 network_process_,
115 if (desktop_process_for_transit == IPC::InvalidPlatformFileForTransit()) { 116 &desktop_process_for_transit,
116 LOG(ERROR) << "Failed to duplicate the desktop process handle"; 117 0,
118 FALSE,
119 DUPLICATE_SAME_ACCESS)) {
120 LOG_GETLASTERROR(ERROR) << "Failed to duplicate the desktop process handle";
117 return false; 121 return false;
118 } 122 }
119 123
124 // |desktop_pipe| is a handle in the desktop process. It will be duplicated
125 // by the network process directly from the desktop process.
120 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached( 126 SendToNetwork(new ChromotingDaemonNetworkMsg_DesktopAttached(
121 terminal_id, desktop_process_for_transit, desktop_pipe)); 127 terminal_id, desktop_process_for_transit, desktop_pipe));
122 return true; 128 return true;
123 } 129 }
124 130
125 void DaemonProcessWin::DoStop() { 131 void DaemonProcessWin::DoStop() {
126 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 132 DCHECK(caller_task_runner()->BelongsToCurrentThread());
127 133
128 network_launcher_.reset(); 134 network_launcher_.reset();
129 DaemonProcess::DoStop(); 135 DaemonProcess::DoStop();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 167 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
162 const base::Closure& stopped_callback) { 168 const base::Closure& stopped_callback) {
163 scoped_ptr<DaemonProcessWin> daemon_process( 169 scoped_ptr<DaemonProcessWin> daemon_process(
164 new DaemonProcessWin(caller_task_runner, io_task_runner, 170 new DaemonProcessWin(caller_task_runner, io_task_runner,
165 stopped_callback)); 171 stopped_callback));
166 daemon_process->Initialize(); 172 daemon_process->Initialize();
167 return daemon_process.PassAs<DaemonProcess>(); 173 return daemon_process.PassAs<DaemonProcess>();
168 } 174 }
169 175
170 } // namespace remoting 176 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698