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

Side by Side Diff: ipc/ipc_channel_posix.cc

Issue 5139001: Revert 66350 - Add named testing interface. This allows you to connect to a p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « ipc/ipc_channel.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_posix.h" 5 #include "ipc/ipc_channel_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 } // namespace 268 } // namespace
269 //------------------------------------------------------------------------------ 269 //------------------------------------------------------------------------------
270 270
271 Channel::ChannelImpl::ChannelImpl(const std::string& channel_id, Mode mode, 271 Channel::ChannelImpl::ChannelImpl(const std::string& channel_id, Mode mode,
272 Listener* listener) 272 Listener* listener)
273 : mode_(mode), 273 : mode_(mode),
274 is_blocked_on_write_(false), 274 is_blocked_on_write_(false),
275 message_send_bytes_written_(0), 275 message_send_bytes_written_(0),
276 uses_fifo_( 276 uses_fifo_(CommandLine::ForCurrentProcess()->HasSwitch(
277 CommandLine::ForCurrentProcess()->HasSwitch(switches::kIPCUseFIFO) || 277 switches::kIPCUseFIFO)),
278 mode == MODE_NAMED_SERVER || mode == MODE_NAMED_CLIENT),
279 server_listen_pipe_(-1), 278 server_listen_pipe_(-1),
280 pipe_(-1), 279 pipe_(-1),
281 client_pipe_(-1), 280 client_pipe_(-1),
282 #if !defined(OS_MACOSX) 281 #if !defined(OS_MACOSX)
283 fd_pipe_(-1), 282 fd_pipe_(-1),
284 remote_fd_pipe_(-1), 283 remote_fd_pipe_(-1),
285 #endif 284 #endif
286 listener_(listener), 285 listener_(listener),
287 waiting_connect_(true), 286 waiting_connect_(true),
288 factory_(this) { 287 factory_(this) {
289 if (mode_ == MODE_NAMED_SERVER) 288 if (!CreatePipe(channel_id, mode)) {
290 mode_ = MODE_SERVER;
291 if (mode_ == MODE_NAMED_CLIENT)
292 mode_ = MODE_CLIENT;
293
294 if (!CreatePipe(channel_id, mode_)) {
295 // The pipe may have been closed already. 289 // The pipe may have been closed already.
296 PLOG(WARNING) << "Unable to create pipe named \"" << channel_id 290 PLOG(WARNING) << "Unable to create pipe named \"" << channel_id
297 << "\" in " << (mode_ == MODE_SERVER ? "server" : "client") 291 << "\" in " << (mode == MODE_SERVER ? "server" : "client")
298 << " mode"; 292 << " mode";
299 } 293 }
300 } 294 }
301 295
302 Channel::ChannelImpl::~ChannelImpl() { 296 Channel::ChannelImpl::~ChannelImpl() {
303 Close(); 297 Close();
304 } 298 }
305 299
306 // static 300 // static
307 void AddChannelSocket(const std::string& name, int socket) { 301 void AddChannelSocket(const std::string& name, int socket) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 339
346 bool Channel::ChannelImpl::CreatePipe(const std::string& channel_id, 340 bool Channel::ChannelImpl::CreatePipe(const std::string& channel_id,
347 Mode mode) { 341 Mode mode) {
348 DCHECK(server_listen_pipe_ == -1 && pipe_ == -1); 342 DCHECK(server_listen_pipe_ == -1 && pipe_ == -1);
349 343
350 if (uses_fifo_) { 344 if (uses_fifo_) {
351 // This only happens in unit tests; see the comment above PipeMap. 345 // This only happens in unit tests; see the comment above PipeMap.
352 // TODO(playmobil): We shouldn't need to create fifos on disk. 346 // TODO(playmobil): We shouldn't need to create fifos on disk.
353 // TODO(playmobil): If we do, they should be in the user data directory. 347 // TODO(playmobil): If we do, they should be in the user data directory.
354 // TODO(playmobil): Cleanup any stale fifos. 348 // TODO(playmobil): Cleanup any stale fifos.
355 pipe_name_ = channel_id; 349 pipe_name_ = "/var/tmp/chrome_" + channel_id;
356 if (mode == MODE_SERVER) { 350 if (mode == MODE_SERVER) {
357 if (!CreateServerFifo(pipe_name_, &server_listen_pipe_)) { 351 if (!CreateServerFifo(pipe_name_, &server_listen_pipe_)) {
358 return false; 352 return false;
359 } 353 }
360 } else { 354 } else {
361 if (!ClientConnectToFifo(pipe_name_, &pipe_)) { 355 if (!ClientConnectToFifo(pipe_name_, &pipe_)) {
362 return false; 356 return false;
363 } 357 }
364 waiting_connect_ = false; 358 waiting_connect_ = false;
365 } 359 }
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1076
1083 bool Channel::Send(Message* message) { 1077 bool Channel::Send(Message* message) {
1084 return channel_impl_->Send(message); 1078 return channel_impl_->Send(message);
1085 } 1079 }
1086 1080
1087 int Channel::GetClientFileDescriptor() const { 1081 int Channel::GetClientFileDescriptor() const {
1088 return channel_impl_->GetClientFileDescriptor(); 1082 return channel_impl_->GetClientFileDescriptor();
1089 } 1083 }
1090 1084
1091 } // namespace IPC 1085 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698