OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" |
10 #include "ipc/ipc_logging.h" | 10 #include "ipc/ipc_logging.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 | 301 |
302 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, | 302 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
303 Channel::Mode mode, MessageLoop* ipc_thread_loop, | 303 Channel::Mode mode, MessageLoop* ipc_thread_loop, |
304 bool create_pipe_now) { | 304 bool create_pipe_now) { |
305 #if defined(OS_POSIX) | 305 #if defined(OS_POSIX) |
306 // When we are creating a server on POSIX, we need its file descriptor | 306 // When we are creating a server on POSIX, we need its file descriptor |
307 // to be created immediately so that it can be accessed and passed | 307 // to be created immediately so that it can be accessed and passed |
308 // to other processes. Forcing it to be created immediately avoids | 308 // to other processes. Forcing it to be created immediately avoids |
309 // race conditions that may otherwise arise. | 309 // race conditions that may otherwise arise. |
310 if (mode == Channel::MODE_SERVER || mode == Channel::MODE_NAMED_SERVER) { | 310 if (mode & Channel::MODE_SERVER_FLAG) { |
311 create_pipe_now = true; | 311 create_pipe_now = true; |
312 } | 312 } |
313 #endif // defined(OS_POSIX) | 313 #endif // defined(OS_POSIX) |
314 | 314 |
315 if (create_pipe_now) { | 315 if (create_pipe_now) { |
316 // Create the channel immediately. This effectively sets up the | 316 // Create the channel immediately. This effectively sets up the |
317 // low-level pipe so that the client can connect. Without creating | 317 // low-level pipe so that the client can connect. Without creating |
318 // the pipe immediately, it is possible for a listener to attempt | 318 // the pipe immediately, it is possible for a listener to attempt |
319 // to connect and get an error since the pipe doesn't exist yet. | 319 // to connect and get an error since the pipe doesn't exist yet. |
320 context_->CreateChannel(channel_handle, mode); | 320 context_->CreateChannel(channel_handle, mode); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 Channel *channel = context_.get()->channel_.get(); | 374 Channel *channel = context_.get()->channel_.get(); |
375 // Channel must have been created first. | 375 // Channel must have been created first. |
376 DCHECK(channel) << context_.get()->channel_id_; | 376 DCHECK(channel) << context_.get()->channel_id_; |
377 return channel->GetClientFileDescriptor(); | 377 return channel->GetClientFileDescriptor(); |
378 } | 378 } |
379 #endif | 379 #endif |
380 | 380 |
381 //----------------------------------------------------------------------------- | 381 //----------------------------------------------------------------------------- |
382 | 382 |
383 } // namespace IPC | 383 } // namespace IPC |
OLD | NEW |