| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/profiler/scoped_tracker.h" | 16 #include "base/profiler/scoped_tracker.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 //----------------------------------------------------------------------------- | 353 //----------------------------------------------------------------------------- |
| 353 | 354 |
| 354 // static | 355 // static |
| 355 scoped_ptr<ChannelProxy> ChannelProxy::Create( | 356 scoped_ptr<ChannelProxy> ChannelProxy::Create( |
| 356 const IPC::ChannelHandle& channel_handle, | 357 const IPC::ChannelHandle& channel_handle, |
| 357 Channel::Mode mode, | 358 Channel::Mode mode, |
| 358 Listener* listener, | 359 Listener* listener, |
| 359 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { | 360 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
| 360 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); | 361 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); |
| 361 channel->Init(channel_handle, mode, true); | 362 channel->Init(channel_handle, mode, true); |
| 362 return channel.Pass(); | 363 return channel; |
| 363 } | 364 } |
| 364 | 365 |
| 365 // static | 366 // static |
| 366 scoped_ptr<ChannelProxy> ChannelProxy::Create( | 367 scoped_ptr<ChannelProxy> ChannelProxy::Create( |
| 367 scoped_ptr<ChannelFactory> factory, | 368 scoped_ptr<ChannelFactory> factory, |
| 368 Listener* listener, | 369 Listener* listener, |
| 369 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { | 370 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
| 370 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); | 371 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); |
| 371 channel->Init(factory.Pass(), true); | 372 channel->Init(std::move(factory), true); |
| 372 return channel.Pass(); | 373 return channel; |
| 373 } | 374 } |
| 374 | 375 |
| 375 ChannelProxy::ChannelProxy(Context* context) | 376 ChannelProxy::ChannelProxy(Context* context) |
| 376 : context_(context), | 377 : context_(context), |
| 377 did_init_(false) { | 378 did_init_(false) { |
| 378 #if defined(ENABLE_IPC_FUZZER) | 379 #if defined(ENABLE_IPC_FUZZER) |
| 379 outgoing_message_filter_ = NULL; | 380 outgoing_message_filter_ = NULL; |
| 380 #endif | 381 #endif |
| 381 } | 382 } |
| 382 | 383 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 413 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory, | 414 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory, |
| 414 bool create_pipe_now) { | 415 bool create_pipe_now) { |
| 415 DCHECK(CalledOnValidThread()); | 416 DCHECK(CalledOnValidThread()); |
| 416 DCHECK(!did_init_); | 417 DCHECK(!did_init_); |
| 417 | 418 |
| 418 if (create_pipe_now) { | 419 if (create_pipe_now) { |
| 419 // Create the channel immediately. This effectively sets up the | 420 // Create the channel immediately. This effectively sets up the |
| 420 // low-level pipe so that the client can connect. Without creating | 421 // low-level pipe so that the client can connect. Without creating |
| 421 // the pipe immediately, it is possible for a listener to attempt | 422 // the pipe immediately, it is possible for a listener to attempt |
| 422 // to connect and get an error since the pipe doesn't exist yet. | 423 // to connect and get an error since the pipe doesn't exist yet. |
| 423 context_->CreateChannel(factory.Pass()); | 424 context_->CreateChannel(std::move(factory)); |
| 424 } else { | 425 } else { |
| 425 context_->ipc_task_runner()->PostTask( | 426 context_->ipc_task_runner()->PostTask( |
| 426 FROM_HERE, base::Bind(&Context::CreateChannel, context_.get(), | 427 FROM_HERE, base::Bind(&Context::CreateChannel, context_.get(), |
| 427 base::Passed(&factory))); | 428 base::Passed(&factory))); |
| 428 } | 429 } |
| 429 | 430 |
| 430 // complete initialization on the background thread | 431 // complete initialization on the background thread |
| 431 context_->ipc_task_runner()->PostTask( | 432 context_->ipc_task_runner()->PostTask( |
| 432 FROM_HERE, base::Bind(&Context::OnChannelOpened, context_.get())); | 433 FROM_HERE, base::Bind(&Context::OnChannelOpened, context_.get())); |
| 433 | 434 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return channel->TakeClientFileDescriptor(); | 521 return channel->TakeClientFileDescriptor(); |
| 521 } | 522 } |
| 522 #endif | 523 #endif |
| 523 | 524 |
| 524 void ChannelProxy::OnChannelInit() { | 525 void ChannelProxy::OnChannelInit() { |
| 525 } | 526 } |
| 526 | 527 |
| 527 //----------------------------------------------------------------------------- | 528 //----------------------------------------------------------------------------- |
| 528 | 529 |
| 529 } // namespace IPC | 530 } // namespace IPC |
| OLD | NEW |