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

Unified Diff: ipc/ipc_channel_win.cc

Issue 9150030: Initialize IPC:ChannelHandle from existing HANDLE (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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
« ipc/ipc_channel_handle.h ('K') | « ipc/ipc_channel_handle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_win.cc
diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc
index cd313d21a96fbd83af6189696ba60960091d8870..047690e30c72c9dc622e92a028ecf1ee6ed8cb2e 100644
--- a/ipc/ipc_channel_win.cc
+++ b/ipc/ipc_channel_win.cc
@@ -115,16 +115,25 @@ bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle,
Mode mode) {
DCHECK_EQ(INVALID_HANDLE_VALUE, pipe_);
const std::wstring pipe_name = PipeName(channel_handle.name);
- if (mode & MODE_SERVER_FLAG) {
+ // If we already have a valid pipe for channel just copy it.
+ if (channel_handle.pipe.IsValid()) {
+ DuplicateHandle(GetCurrentProcess(),
+ channel_handle.pipe,
+ GetCurrentProcess(),
+ &pipe_,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS);
+ } else if (mode & MODE_SERVER_FLAG) {
pipe_ = CreateNamedPipeW(pipe_name.c_str(),
- PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
+ PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
FILE_FLAG_FIRST_PIPE_INSTANCE,
- PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
- 1,
- Channel::kReadBufferSize,
- Channel::kReadBufferSize,
- 5000,
- NULL);
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
+ 1,
+ Channel::kReadBufferSize,
+ Channel::kReadBufferSize,
+ 5000,
+ NULL);
} else if (mode & MODE_CLIENT_FLAG) {
pipe_ = CreateFileW(pipe_name.c_str(),
GENERIC_READ | GENERIC_WRITE,
@@ -137,6 +146,7 @@ bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle,
} else {
NOTREACHED();
}
+
if (pipe_ == INVALID_HANDLE_VALUE) {
// If this process is being closed, the pipe may be gone already.
LOG(WARNING) << "Unable to create pipe \"" << pipe_name <<
« ipc/ipc_channel_handle.h ('K') | « ipc/ipc_channel_handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698