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

Side by Side 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: fixed build error 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 unified diff | Download patch
« ipc/ipc_channel_handle.h ('K') | « ipc/ipc_channel_handle.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ipc/ipc_channel_win.h" 5 #include "ipc/ipc_channel_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // static 107 // static
108 const std::wstring Channel::ChannelImpl::PipeName( 108 const std::wstring Channel::ChannelImpl::PipeName(
109 const std::string& channel_id) { 109 const std::string& channel_id) {
110 std::string name("\\\\.\\pipe\\chrome."); 110 std::string name("\\\\.\\pipe\\chrome.");
111 return ASCIIToWide(name.append(channel_id)); 111 return ASCIIToWide(name.append(channel_id));
112 } 112 }
113 113
114 bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle, 114 bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle,
115 Mode mode) { 115 Mode mode) {
116 DCHECK_EQ(INVALID_HANDLE_VALUE, pipe_); 116 DCHECK_EQ(INVALID_HANDLE_VALUE, pipe_);
117 const std::wstring pipe_name = PipeName(channel_handle.name); 117 const std::wstring pipe_name = PipeName(channel_handle.name);
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 pipe_name needs to move down. Another idea is to c
118 if (mode & MODE_SERVER_FLAG) { 118 // If we already have a valid pipe for channel just copy it.
119 if (channel_handle.pipe.IsValid()) {
120 DuplicateHandle(GetCurrentProcess(),
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 On duplicate failure pipe_ what value does it cont
121 channel_handle.pipe,
122 GetCurrentProcess(),
123 &pipe_,
124 0,
125 FALSE,
126 DUPLICATE_SAME_ACCESS);
127 } else if (mode & MODE_SERVER_FLAG) {
119 pipe_ = CreateNamedPipeW(pipe_name.c_str(), 128 pipe_ = CreateNamedPipeW(pipe_name.c_str(),
120 PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | 129 PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
cpu_(ooo_6.6-7.5) 2012/01/19 20:56:05 indentation seems weird
121 FILE_FLAG_FIRST_PIPE_INSTANCE, 130 FILE_FLAG_FIRST_PIPE_INSTANCE,
122 PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 131 PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
123 1, 132 1,
124 Channel::kReadBufferSize, 133 Channel::kReadBufferSize,
125 Channel::kReadBufferSize, 134 Channel::kReadBufferSize,
126 5000, 135 5000,
127 NULL); 136 NULL);
128 } else if (mode & MODE_CLIENT_FLAG) { 137 } else if (mode & MODE_CLIENT_FLAG) {
129 pipe_ = CreateFileW(pipe_name.c_str(), 138 pipe_ = CreateFileW(pipe_name.c_str(),
130 GENERIC_READ | GENERIC_WRITE, 139 GENERIC_READ | GENERIC_WRITE,
131 0, 140 0,
132 NULL, 141 NULL,
133 OPEN_EXISTING, 142 OPEN_EXISTING,
134 SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION | 143 SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
135 FILE_FLAG_OVERLAPPED, 144 FILE_FLAG_OVERLAPPED,
136 NULL); 145 NULL);
137 } else { 146 } else {
138 NOTREACHED(); 147 NOTREACHED();
139 } 148 }
149
140 if (pipe_ == INVALID_HANDLE_VALUE) { 150 if (pipe_ == INVALID_HANDLE_VALUE) {
141 // If this process is being closed, the pipe may be gone already. 151 // If this process is being closed, the pipe may be gone already.
142 LOG(WARNING) << "Unable to create pipe \"" << pipe_name << 152 LOG(WARNING) << "Unable to create pipe \"" << pipe_name <<
143 "\" in " << (mode == 0 ? "server" : "client") 153 "\" in " << (mode == 0 ? "server" : "client")
144 << " mode. Error :" << GetLastError(); 154 << " mode. Error :" << GetLastError();
145 return false; 155 return false;
146 } 156 }
147 157
148 // Create the Hello message to be sent when Connect is called 158 // Create the Hello message to be sent when Connect is called
149 scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE, 159 scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bool Channel::Send(Message* message) { 434 bool Channel::Send(Message* message) {
425 return channel_impl_->Send(message); 435 return channel_impl_->Send(message);
426 } 436 }
427 437
428 // static 438 // static
429 bool Channel::IsNamedServerInitialized(const std::string& channel_id) { 439 bool Channel::IsNamedServerInitialized(const std::string& channel_id) {
430 return ChannelImpl::IsNamedServerInitialized(channel_id); 440 return ChannelImpl::IsNamedServerInitialized(channel_id);
431 } 441 }
432 442
433 } // namespace IPC 443 } // namespace IPC
OLDNEW
« 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