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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_.get(), | 477 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_.get(), |
478 make_scoped_refptr(filter))); | 478 make_scoped_refptr(filter))); |
479 } | 479 } |
480 | 480 |
481 void ChannelProxy::ClearIPCTaskRunner() { | 481 void ChannelProxy::ClearIPCTaskRunner() { |
482 DCHECK(CalledOnValidThread()); | 482 DCHECK(CalledOnValidThread()); |
483 | 483 |
484 context()->ClearIPCTaskRunner(); | 484 context()->ClearIPCTaskRunner(); |
485 } | 485 } |
486 | 486 |
| 487 base::ProcessId ChannelProxy::GetPeerPID() const { |
| 488 return context_->peer_pid_; |
| 489 } |
| 490 |
| 491 void ChannelProxy::OnSetAttachmentBrokerEndpoint() { |
| 492 context()->set_attachment_broker_endpoint(is_attachment_broker_endpoint()); |
| 493 } |
| 494 |
487 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) | 495 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) |
488 // See the TODO regarding lazy initialization of the channel in | 496 // See the TODO regarding lazy initialization of the channel in |
489 // ChannelProxy::Init(). | 497 // ChannelProxy::Init(). |
490 int ChannelProxy::GetClientFileDescriptor() { | 498 int ChannelProxy::GetClientFileDescriptor() { |
491 DCHECK(CalledOnValidThread()); | 499 DCHECK(CalledOnValidThread()); |
492 | 500 |
493 Channel* channel = context_.get()->channel_.get(); | 501 Channel* channel = context_.get()->channel_.get(); |
494 // Channel must have been created first. | 502 // Channel must have been created first. |
495 DCHECK(channel) << context_.get()->channel_id_; | 503 DCHECK(channel) << context_.get()->channel_id_; |
496 return channel->GetClientFileDescriptor(); | 504 return channel->GetClientFileDescriptor(); |
497 } | 505 } |
498 | 506 |
499 base::ScopedFD ChannelProxy::TakeClientFileDescriptor() { | 507 base::ScopedFD ChannelProxy::TakeClientFileDescriptor() { |
500 DCHECK(CalledOnValidThread()); | 508 DCHECK(CalledOnValidThread()); |
501 | 509 |
502 Channel* channel = context_.get()->channel_.get(); | 510 Channel* channel = context_.get()->channel_.get(); |
503 // Channel must have been created first. | 511 // Channel must have been created first. |
504 DCHECK(channel) << context_.get()->channel_id_; | 512 DCHECK(channel) << context_.get()->channel_id_; |
505 return channel->TakeClientFileDescriptor(); | 513 return channel->TakeClientFileDescriptor(); |
506 } | 514 } |
507 #endif | 515 #endif |
508 | 516 |
509 void ChannelProxy::SetAttachmentBrokerEndpoint(bool is_endpoint) { | |
510 context()->set_attachment_broker_endpoint(is_endpoint); | |
511 } | |
512 | |
513 //----------------------------------------------------------------------------- | 517 //----------------------------------------------------------------------------- |
514 | 518 |
515 } // namespace IPC | 519 } // namespace IPC |
OLD | NEW |