| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_proxy.h" | 5 #include "ipc/ipc_channel_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 return channel_send_thread_safe_; | 345 return channel_send_thread_safe_; |
| 346 } | 346 } |
| 347 | 347 |
| 348 //----------------------------------------------------------------------------- | 348 //----------------------------------------------------------------------------- |
| 349 | 349 |
| 350 // static | 350 // static |
| 351 scoped_ptr<ChannelProxy> ChannelProxy::Create( | 351 scoped_ptr<ChannelProxy> ChannelProxy::Create( |
| 352 const IPC::ChannelHandle& channel_handle, | 352 const IPC::ChannelHandle& channel_handle, |
| 353 Channel::Mode mode, | 353 Channel::Mode mode, |
| 354 Listener* listener, | 354 Listener* listener, |
| 355 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | 355 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
| 356 AttachmentBroker* broker) { | |
| 357 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); | 356 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); |
| 358 channel->Init(channel_handle, mode, true, broker); | 357 channel->Init(channel_handle, mode, true); |
| 359 return channel.Pass(); | 358 return channel.Pass(); |
| 360 } | 359 } |
| 361 | 360 |
| 362 // static | 361 // static |
| 363 scoped_ptr<ChannelProxy> ChannelProxy::Create( | 362 scoped_ptr<ChannelProxy> ChannelProxy::Create( |
| 364 scoped_ptr<ChannelFactory> factory, | 363 scoped_ptr<ChannelFactory> factory, |
| 365 Listener* listener, | 364 Listener* listener, |
| 366 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { | 365 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
| 367 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); | 366 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); |
| 368 channel->Init(factory.Pass(), true); | 367 channel->Init(factory.Pass(), true); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 387 } | 386 } |
| 388 | 387 |
| 389 ChannelProxy::~ChannelProxy() { | 388 ChannelProxy::~ChannelProxy() { |
| 390 DCHECK(CalledOnValidThread()); | 389 DCHECK(CalledOnValidThread()); |
| 391 | 390 |
| 392 Close(); | 391 Close(); |
| 393 } | 392 } |
| 394 | 393 |
| 395 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, | 394 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
| 396 Channel::Mode mode, | 395 Channel::Mode mode, |
| 397 bool create_pipe_now, | 396 bool create_pipe_now) { |
| 398 AttachmentBroker* broker) { | |
| 399 #if defined(OS_POSIX) | 397 #if defined(OS_POSIX) |
| 400 // When we are creating a server on POSIX, we need its file descriptor | 398 // When we are creating a server on POSIX, we need its file descriptor |
| 401 // to be created immediately so that it can be accessed and passed | 399 // to be created immediately so that it can be accessed and passed |
| 402 // to other processes. Forcing it to be created immediately avoids | 400 // to other processes. Forcing it to be created immediately avoids |
| 403 // race conditions that may otherwise arise. | 401 // race conditions that may otherwise arise. |
| 404 if (mode & Channel::MODE_SERVER_FLAG) { | 402 if (mode & Channel::MODE_SERVER_FLAG) { |
| 405 create_pipe_now = true; | 403 create_pipe_now = true; |
| 406 } | 404 } |
| 407 #endif // defined(OS_POSIX) | 405 #endif // defined(OS_POSIX) |
| 408 Init(ChannelFactory::Create(channel_handle, mode, broker), create_pipe_now); | 406 Init(ChannelFactory::Create(channel_handle, mode), create_pipe_now); |
| 409 } | 407 } |
| 410 | 408 |
| 411 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory, | 409 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory, |
| 412 bool create_pipe_now) { | 410 bool create_pipe_now) { |
| 413 DCHECK(CalledOnValidThread()); | 411 DCHECK(CalledOnValidThread()); |
| 414 DCHECK(!did_init_); | 412 DCHECK(!did_init_); |
| 415 | 413 |
| 416 if (create_pipe_now) { | 414 if (create_pipe_now) { |
| 417 // Create the channel immediately. This effectively sets up the | 415 // Create the channel immediately. This effectively sets up the |
| 418 // low-level pipe so that the client can connect. Without creating | 416 // low-level pipe so that the client can connect. Without creating |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 return channel->TakeClientFileDescriptor(); | 516 return channel->TakeClientFileDescriptor(); |
| 519 } | 517 } |
| 520 #endif | 518 #endif |
| 521 | 519 |
| 522 void ChannelProxy::OnChannelInit() { | 520 void ChannelProxy::OnChannelInit() { |
| 523 } | 521 } |
| 524 | 522 |
| 525 //----------------------------------------------------------------------------- | 523 //----------------------------------------------------------------------------- |
| 526 | 524 |
| 527 } // namespace IPC | 525 } // namespace IPC |
| OLD | NEW |