| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void ChannelProxy::Context::ClearIPCTaskRunner() { | 52 void ChannelProxy::Context::ClearIPCTaskRunner() { |
| 53 ipc_task_runner_ = NULL; | 53 ipc_task_runner_ = NULL; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ChannelProxy::Context::CreateChannel(scoped_ptr<ChannelFactory> factory) { | 56 void ChannelProxy::Context::CreateChannel(scoped_ptr<ChannelFactory> factory) { |
| 57 base::AutoLock l(channel_lifetime_lock_); | 57 base::AutoLock l(channel_lifetime_lock_); |
| 58 DCHECK(!channel_); | 58 DCHECK(!channel_); |
| 59 channel_id_ = factory->GetName(); | 59 channel_id_ = factory->GetName(); |
| 60 channel_ = factory->BuildChannel(this); | 60 channel_ = factory->BuildChannel(this); |
| 61 channel_send_thread_safe_ = channel_->IsSendThreadSafe(); | 61 channel_send_thread_safe_ = channel_->IsSendThreadSafe(); |
| 62 channel_->set_attachment_broker_endpoint(attachment_broker_endpoint_); | 62 channel_->SetAttachmentBrokerEndpoint(attachment_broker_endpoint_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool ChannelProxy::Context::TryFilters(const Message& message) { | 65 bool ChannelProxy::Context::TryFilters(const Message& message) { |
| 66 DCHECK(message_filter_router_); | 66 DCHECK(message_filter_router_); |
| 67 #ifdef IPC_MESSAGE_LOG_ENABLED | 67 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 68 Logging* logger = Logging::GetInstance(); | 68 Logging* logger = Logging::GetInstance(); |
| 69 if (logger->Enabled()) | 69 if (logger->Enabled()) |
| 70 logger->OnPreDispatchMessage(message); | 70 logger->OnPreDispatchMessage(message); |
| 71 #endif | 71 #endif |
| 72 | 72 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_.get(), | 482 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_.get(), |
| 483 make_scoped_refptr(filter))); | 483 make_scoped_refptr(filter))); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void ChannelProxy::ClearIPCTaskRunner() { | 486 void ChannelProxy::ClearIPCTaskRunner() { |
| 487 DCHECK(CalledOnValidThread()); | 487 DCHECK(CalledOnValidThread()); |
| 488 | 488 |
| 489 context()->ClearIPCTaskRunner(); | 489 context()->ClearIPCTaskRunner(); |
| 490 } | 490 } |
| 491 | 491 |
| 492 base::ProcessId ChannelProxy::GetPeerPID() const { |
| 493 return context_->peer_pid_; |
| 494 } |
| 495 |
| 496 void ChannelProxy::OnSetAttachmentBrokerEndpoint() { |
| 497 context()->set_attachment_broker_endpoint(is_attachment_broker_endpoint()); |
| 498 } |
| 499 |
| 492 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) | 500 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) |
| 493 // See the TODO regarding lazy initialization of the channel in | 501 // See the TODO regarding lazy initialization of the channel in |
| 494 // ChannelProxy::Init(). | 502 // ChannelProxy::Init(). |
| 495 int ChannelProxy::GetClientFileDescriptor() { | 503 int ChannelProxy::GetClientFileDescriptor() { |
| 496 DCHECK(CalledOnValidThread()); | 504 DCHECK(CalledOnValidThread()); |
| 497 | 505 |
| 498 Channel* channel = context_.get()->channel_.get(); | 506 Channel* channel = context_.get()->channel_.get(); |
| 499 // Channel must have been created first. | 507 // Channel must have been created first. |
| 500 DCHECK(channel) << context_.get()->channel_id_; | 508 DCHECK(channel) << context_.get()->channel_id_; |
| 501 return channel->GetClientFileDescriptor(); | 509 return channel->GetClientFileDescriptor(); |
| 502 } | 510 } |
| 503 | 511 |
| 504 base::ScopedFD ChannelProxy::TakeClientFileDescriptor() { | 512 base::ScopedFD ChannelProxy::TakeClientFileDescriptor() { |
| 505 DCHECK(CalledOnValidThread()); | 513 DCHECK(CalledOnValidThread()); |
| 506 | 514 |
| 507 Channel* channel = context_.get()->channel_.get(); | 515 Channel* channel = context_.get()->channel_.get(); |
| 508 // Channel must have been created first. | 516 // Channel must have been created first. |
| 509 DCHECK(channel) << context_.get()->channel_id_; | 517 DCHECK(channel) << context_.get()->channel_id_; |
| 510 return channel->TakeClientFileDescriptor(); | 518 return channel->TakeClientFileDescriptor(); |
| 511 } | 519 } |
| 512 #endif | 520 #endif |
| 513 | 521 |
| 514 void ChannelProxy::SetAttachmentBrokerEndpoint(bool is_endpoint) { | |
| 515 context()->set_attachment_broker_endpoint(is_endpoint); | |
| 516 } | |
| 517 | |
| 518 void ChannelProxy::OnChannelInit() { | 522 void ChannelProxy::OnChannelInit() { |
| 519 } | 523 } |
| 520 | 524 |
| 521 //----------------------------------------------------------------------------- | 525 //----------------------------------------------------------------------------- |
| 522 | 526 |
| 523 } // namespace IPC | 527 } // namespace IPC |
| OLD | NEW |