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

Unified Diff: remoting/host/win/launch_process_with_token.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/win/launch_process_with_token.h ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/launch_process_with_token.cc
diff --git a/remoting/host/win/launch_process_with_token.cc b/remoting/host/win/launch_process_with_token.cc
index cd1d752b508c057c18c8f10994764a497200fddf..3619a55454ffff9f4e6656e25490ad00b06ae93c 100644
--- a/remoting/host/win/launch_process_with_token.cc
+++ b/remoting/host/win/launch_process_with_token.cc
@@ -15,12 +15,15 @@
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/scoped_native_library.h"
+#include "base/single_thread_task_runner.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
#include "base/win/scoped_process_information.h"
#include "base/win/windows_version.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_channel.h"
using base::win::ScopedHandle;
@@ -409,6 +412,56 @@ namespace remoting {
// a pipe name.
const char kChromePipeNamePrefix[] = "\\\\.\\pipe\\chrome.";
+bool CreateConnectedIpcChannel(
+ const std::string& channel_name,
+ const std::string& pipe_security_descriptor,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ IPC::Listener* delegate,
+ base::win::ScopedHandle* client_out,
+ scoped_ptr<IPC::ChannelProxy>* server_out) {
+ // Create the server end of the channel.
+ ScopedHandle pipe;
+ if (!CreateIpcChannel(channel_name, pipe_security_descriptor, &pipe)) {
+ return false;
+ }
+
+ // Wrap the pipe into an IPC channel.
+ scoped_ptr<IPC::ChannelProxy> server(new IPC::ChannelProxy(
+ IPC::ChannelHandle(pipe),
+ IPC::Channel::MODE_SERVER,
+ delegate,
+ io_task_runner));
+
+ // Convert the channel name to the pipe name.
+ std::string pipe_name(remoting::kChromePipeNamePrefix);
+ pipe_name.append(channel_name);
+
+ SECURITY_ATTRIBUTES security_attributes;
+ security_attributes.nLength = sizeof(security_attributes);
+ security_attributes.lpSecurityDescriptor = NULL;
+ security_attributes.bInheritHandle = TRUE;
+
+ // Create the client end of the channel. This code should match the code in
+ // IPC::Channel.
+ ScopedHandle client;
+ client.Set(CreateFile(UTF8ToUTF16(pipe_name).c_str(),
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ &security_attributes,
+ OPEN_EXISTING,
+ SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
+ FILE_FLAG_OVERLAPPED,
+ NULL));
+ if (!client.IsValid()) {
+ LOG_GETLASTERROR(ERROR) << "Failed to connect to '" << pipe_name << "'";
+ return false;
+ }
+
+ *client_out = client.Pass();
+ *server_out = server.Pass();
+ return true;
+}
+
bool CreateIpcChannel(
const std::string& channel_name,
const std::string& pipe_security_descriptor,
@@ -501,15 +554,6 @@ bool CreateSessionToken(uint32 session_id, ScopedHandle* token_out) {
return true;
}
-// Generates a unique IPC channel name.
-std::string GenerateIpcChannelName(void* client) {
- // Generate the pipe name. This code is copied from
- // src/content/common/child_process_host_impl.cc
- return base::StringPrintf("%d.%p.%d",
- base::GetCurrentProcId(), client,
- base::RandInt(0, std::numeric_limits<int>::max()));
-}
-
bool LaunchProcessWithToken(const FilePath& binary,
const CommandLine::StringType& command_line,
HANDLE user_token,
« no previous file with comments | « remoting/host/win/launch_process_with_token.h ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698